简体   繁体   English

iOS本地通知不适用于PhoneGap

[英]IOS Local Notifications not working with PhoneGap

I'm having trouble with displaying local notifications in my iOS PhoneGap-app. 我在iOS PhoneGap-app中显示本地通知时遇到问题。 I have tried both the Katzer Local Notifications plugin ( https://github.com/katzer/cordova-plugin-local-notifications#schedule-local-notifications ) and the Wizcorp local notifications plugin ( https://github.com/Wizcorp/phonegap-plugin-localNotifications ) but neither works for me. 我已经尝试过Katzer本地通知插件( https://github.com/katzer/cordova-plugin-local-notifications#schedule-local-notifications )和Wizcorp本地通知插件( https://github.com/Wizcorp / phonegap-plugin-localNotifications ),但都不适合我。 After installing both plugins I can access their respective JavaScript objects and with the Wizcorp plugin I can even manipulate the application badge, but I cant seem to add a local notification. 安装两个插件后,我可以访问它们各自的JavaScript对象,并且使用Wizcorp插件,我什至可以操纵应用程序徽章,但是似乎无法添加本地通知。 This makes me believe that the problem lies elsewhere in my application/installation. 这使我相信问题出在我的应用程序/安装中。

I've tried both plugins on both the ios emulator and the Phonegap developer app. 我已经在ios模拟器和Phonegap开发人员应用程序上尝试了这两个插件。

EDIT: I am currently just trying to get this working with the plugin example code: 编辑:我目前正试图使此与插件示例代码一起工作:

    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
});

Make sure that you have registered your app for local notifications. 确保您已为本地通知注册了应用程序。 This is not done automatically when you add the plugin. 添加插件时,这不会自动完成。

For example (in the app delegate application:didFinishLaunchingWithOptions: method): 例如(在应用程序委托application:didFinishLaunchingWithOptions:方法中):

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM