IOS本地通知不能与PhoneGap一起工作

IOS Local Notifications not working with PhoneGap

本文关键字:PhoneGap 一起 工作 不能 通知 IOS      更新时间:2023-09-26

我在iOS phonegap应用程序中显示本地通知时有问题。我试过Katzer本地通知插件(https://github.com/katzer/cordova-plugin-local-notifications#schedule-local-notifications)和Wizcorp本地通知插件(https://github.com/Wizcorp/phonegap-plugin-localNotifications),但都不适合我。安装这两个插件后,我可以访问它们各自的JavaScript对象,使用Wizcorp插件,我甚至可以操作应用程序徽章,但我似乎无法添加本地通知。这让我相信问题出在我的应用程序/安装的其他地方。

我已经在ios模拟器和Phonegap开发者应用程序上尝试了两个插件。

编辑:我目前只是试图得到这个工作与插件示例代码:

    var now                  = new Date().getTime(),
    _60_seconds_from_now = new Date(now + 60*1000);
window.plugin.notification.local.add({
    id:      1,
    title:   'Reminder',
    message: 'Dont forget to buy some flowers.',
    repeat:  'weekly',
    date:    _60_seconds_from_now
});

确保你已经为应用注册了本地通知。当你添加插件时,这不会自动完成。

例如(在app delegate application中:didFinishLaunchingWithOptions: method):

        [application registerUserNotificationSettings:
            [UIUserNotificationSettings settingsForTypes:
                UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];