標籤:
Using Local Notifications In Your Ionic Framework App
配置好ng-cordova先
<script src="lib/ngCordova/dist/ng-cordova.js"></script>
<script src="cordova.js"></script>
var ionicApp = angular.module("ionic", ["ionic", "ngCordova"]);
然後
cordova plugin add de.appplant.cordova.plugin.local-notification
ionicApp.controller("ExampleController", function($scope, $cordovaLocalNotification) { $scope.add = function() { var alarmTime = new Date(); alarmTime.setMinutes(alarmTime.getMinutes() + 1); $cordovaLocalNotification.add({ 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); }); } });
【Ionic】---Using Local Notifications In Your Ionic Framework App