【Ionic】---Using Local Notifications In Your Ionic Framework App

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);
        });
    }
 
});
posted @ 2015-07-30 09:53  IT姑凉  阅读(690)  评论(0编辑  收藏  举报