$cordovaLocalNotification - TypeError - 无法读取未定义的 属性 'local'

$cordovaLocalNotification - TypeError - cannot read property 'local' of undefined

我 运行 在我的 ionic 应用程序中使用 $cordovaLocalNotification 时遇到了一个问题,下面的代码产生了一条错误消息 TypeError: Cannot read 属性 'local'未定义

try{
  if($scope.active.checked){
    $cordovaLocalNotification.schedule({
      id: 1,
      title: 'Notification',
      text: 'You are currently publishing your location.'
    }).then(function(result){
      AlertService.notify('Success', 'Successfully notified customer')
    }, function(err){
      AlertService.notify('Error', 'Failed to notify customer')
    });
  } else {
    $cordovaLocalNotification.cancel(1);
  }
}catch(err){
  AlertService.notify('Issue', err)
}

因此,在阅读了一些关于需要验证 ionicPlatform.ready() 并确保插件安装正确(并验证这些不是问题)的回复后,我不知所措。我认为这个问题是由于 cordova.plugins.notification 没有被定义引起的,但我不确定为什么这个插件没有被正确加载。

从 Ionic,我有以下插件:

cordova-plugin-app-event 1.2.0 "Application Events"
cordova-plugin-camera 2.3.0 "Camera"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.4 "Console"
cordova-plugin-device 1.1.3 "Device"
cordova-plugin-geolocation 2.4.0 "Geolocation"
cordova-plugin-splashscreen 4.0.0 "Splashscreen"
cordova-plugin-statusbar 2.2.0 "StatusBar"
cordova-plugin-whitelist 1.3.0 "Whitelist"
de.appplant.cordova.plugin.local-notification 0.8.4 "LocalNotification"
ionic-plugin-keyboard 2.2.1 "Keyboard"

到目前为止,为了我自己的理智,我有:

  1. 使用 cordova plugin add de.appplant.cordova.plugin.local-notification
  2. 手动安装插件
  3. 移除平台,移除插件,然后执行ionic state restore

此外,需要注意的一件好事是我正在使用 ionicView 进行测试。 All/any 将不胜感激。

事实证明,在模拟器或物理设备上模拟这个工作正常。所以不是所有的cordova插件都运行在ionicView

是一次很好的学习体验