Notifications 未触发本地通知
我在我的ionic应用程序中添加了本地通知,因为我引用了这个博客,但是我在我的手机中看不到任何通知,在我的控制台中我找到了日志 错误:Notifications 未触发本地通知,notifications,ionic-framework,local,Notifications,Ionic Framework,Local,我在我的ionic应用程序中添加了本地通知,因为我引用了这个博客,但是我在我的手机中看不到任何通知,在我的控制台中我找到了日志 错误: TypeError: Cannot read property 'plugins' of undefined at Object.schedule (ng-cordova.min.js:8) at Scope.$scope.add (controllers.js:2789) at $parseFunction
TypeError: Cannot read property 'plugins' of undefined
at Object.schedule (ng-cordova.min.js:8)
at Scope.$scope.add (controllers.js:2789)
at $parseFunctionCall (ionic.bundle.js:21172)
at ionic.bundle.js:53674
at Scope.$eval (ionic.bundle.js:23228)
at Scope.$apply (ionic.bundle.js:23327)
at HTMLButtonElement.<anonymous> (ionic.bundle.js:53673)
at HTMLButtonElement.eventHandler (ionic.bundle.js:11841)
at triggerMouseEvent (ionic.bundle.js:2865)
at tapClick (ionic.bundle.js:2854)(anonymous function)
@ ionic.bundle.js:20434(anonymous function)
@ ionic.bundle.js:17384Scope.$apply
@ ionic.bundle.js:23329(anonymous function)
@ ionic.bundle.js:53673eventHandler
@ ionic.bundle.js:11841triggerMouseEvent
@ ionic.bundle.js:2865tapClick
@ ionic.bundle.js:2854tapMouseUp
@ ionic.bundle.js:2927
看法
尝试但无法解决,帮助我,提前谢谢。希望你尝试在移动设备上测试这一点….?是的,我直接运行我的mobileadd插件:cordova plugin添加de.appplant.cordova.plugin.local-notification,并将ng-cordova.min.js文件包含在你的项目的www/js目录中如果你已经这样做了..根据你提供的链接..你将成功的我已经运行了你的代码..它正在工作..发出通知。。!我们需要特定的移动安卓版本,我正在尝试操作系统“安卓5.1”,但仍然没有收到通知,你能把你的代码和你的代码贴在一起吗。
.controller('LocalNotificationCtrl',function($scope,$cordovaLocalNotification){
console.log('Notification entering');
$scope.add = function() {
var alarmTime = new Date();
alarmTime.setMinutes(alarmTime.getMinutes() + 1);
$cordovaLocalNotification.schedule({
id: "1234",
date: alarmTime,
message: "This is a message",
title: "This is a title",
autoCancel: true,
sound: null
}).then(function () {
console.log("The notification has been set");
});
};
$scope.isScheduled = function() {
$cordovaLocalNotification.isScheduled("1234").then(function(isScheduled) {
alert("Notification 1234 Scheduled: " + isScheduled);
});
}
})
<ion-content ng-controller="LocalNotificationCtrl">
<button class="button" ng-click="add()">Add notification</button>
<button class="button" ng-click="isScheduled()">Is Scheduled</button>
</ion-content>
angular.module('Mobile_App', ['ionic','ngCordova','Mobile_App.controllers','Mobile_App.services'])
.run(function($cordovaToast,$ionicHistory,$ionicPlatform, $rootScope) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});