侦听器“$cordovaLocalNotification:trigger”未触发,因为“$cordovaLocalNotification:scheduled”正在工作

Listener '$cordovaLocalNotification:trigger' not triggered where as '$cordovaLocalNotification:scheduled' is working

这是 angularjs 的离子(不是离子 v2)。 安排本地通知时,我看到“$cordovaLocalNotification:schedule”被触发,但没有看到“$cordovaLocalNotification:trigger”。

   $rootScope.$on('$cordovaLocalNotification:schedule',
        function (event, notification, state) {
            // ...
            alert("Local Notification scheduled");
        });

    $rootScope.$on('$cordovaLocalNotification:trigger',
        function (event, notification, state) {
            // ...
            alert("Local Notification triggered")
        });

提供以下用于触发通知的方法:

$rootScope.scheduleNotification = function (title,notificationMessage) {
    $cordovaLocalNotification.schedule({
      id: 1,
      title: title,
      text: notificationMessage,
      data: {
        customProperty: 'custom value'
      }
    }).then(function (result) {
      // ...
    });
  }; 

所有注入都已设置,我想如果没有预定的侦听器将无法工作!

谷歌搜索后发现,需要调整现有插件 katzer/cordova-plugin-local-notifications 以支持 iOS 10 项更改 推送通知和 LocalNotifications 支持新的通知中心功能。

作为临时修复,请执行以下操作:

  1. 离子插件 rm de.appplant.cordova.plugin.local-通知
  2. 离子插件添加https://github.com/spk0611/cordova-plugin-local-notifications#9ad32cf2059cdf9a54b4930b1c58ba76ef7e3a87
  3. 转到 Xcode 并确保 XCode -> 首选项 -> 位置 并检查 命令行工具是否设置为Xcode 8.(我真的不知道为什么要这样做)
  4. 在 Xcode 中,转到目标的构建设置并确保“启用模块(C 和 Objective-C)”已打开
  5. 最后,编辑 plugin.xml(它位于添加的插件文件夹中)以取消注释掉 cordova-plugman 引擎的行,以便应用程序实际可以访问该插件。

add plugin from here

Solution Source

万岁!我成功了:-)