1
A
回答
3
當然,你要尋找的插件是http://ngcordova.com/docs/plugins/localNotification/
只需添加插件
cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications.git
,並看看這個例子:
module.controller('MyCtrl',
['$scope', '$rootScope', '$ionicPlatform', '$cordovaLocalNotification',
function($scope, $rootScope, $ionicPlatform, $cordovaLocalNotification) {
$ionicPlatform.ready(function() {
// ========== Scheduling
$scope.scheduleSingleNotification = function() {
$cordovaLocalNotification.schedule({
id: 1,
title: 'Title here',
text: 'Text here',
data: {
customProperty: 'custom value'
}
}).then(function (result) {
// ...
});
};
$scope.scheduleMultipleNotifications = function() {
$cordovaLocalNotification.schedule([
{
id: 1,
title: 'Title 1 here',
text: 'Text 1 here',
data: {
customProperty: 'custom 1 value'
}
},
{
id: 2,
title: 'Title 2 here',
text: 'Text 2 here',
data: {
customProperty: 'custom 2 value'
}
},
{
id: 3,
title: 'Title 3 here',
text: 'Text 3 here',
data: {
customProperty: 'custom 3 value'
}
}
]).then(function (result) {
// ...
});
};
$scope.scheduleDelayedNotification = function() {
var now = new Date().getTime();
var _10SecondsFromNow = new Date(now + 10 * 1000);
$cordovaLocalNotification.schedule({
id: 1,
title: 'Title here',
text: 'Text here',
at: _10SecondsFromNow
}).then(function (result) {
// ...
});
};
$scope.scheduleEveryMinuteNotification = function() {
$cordovaLocalNotification.schedule({
id: 1,
title: 'Title here',
text: 'Text here',
every: 'minute'
}).then(function (result) {
// ...
});
};
// =========/ Scheduling
// ========== Update
$scope.updateSingleNotification = function() {
$cordovaLocalNotification.update({
id: 1,
title: 'Title - UPDATED',
text: 'Text - UPDATED'
}).then(function (result) {
// ...
});
};
$scope.updateMultipleNotifications = function() {
$cordovaLocalNotification.update([
{
id: 1,
title: 'Title 1 - UPDATED',
text: 'Text 1 - UPDATED'
},
{
id: 2,
title: 'Title 2 - UPDATED',
text: 'Text 2 - UPDATED'
},
{
id: 3,
title: 'Title 3 - UPDATED',
text: 'Text 3 - UPDATED'
}
]).then(function (result) {
// ...
});
};
// =========/ Update
// ========== Cancelation
$scope.cancelSingleNotification = function() {
$cordovaLocalNotification.cancel(1).then(function (result) {
// ...
});
};
$scope.cancelMultipleNotifications = function() {
$cordovaLocalNotification.cancel([1, 2]).then(function (result) {
// ...
});
};
$scope.cancelAllNotifications = function() {
$cordovaLocalNotification.cancelAll().then(function (result) {
// ...
});
};
// =========/ Cancelation
// ========== Events
$rootScope.$on('$cordovaLocalNotification:schedule',
function (event, notification, state) {
// ...
});
$rootScope.$on('$cordovaLocalNotification:trigger',
function (event, notification, state) {
// ...
});
$rootScope.$on('$cordovaLocalNotification:update',
function (event, notification, state) {
// ...
});
$rootScope.$on('$cordovaLocalNotification:clear',
function (event, notification, state) {
// ...
});
$rootScope.$on('$cordovaLocalNotification:clearall',
function (event, state) {
// ...
});
$rootScope.$on('$cordovaLocalNotification:cancel',
function (event, notification, state) {
// ...
});
$rootScope.$on('$cordovaLocalNotification:cancelall',
function (event, state) {
// ...
});
$rootScope.$on('$cordovaLocalNotification:click',
function (event, notification, state) {
// ...
});
// =========/ Events
});
}]);
相關問題
- 1. Can Ionic能否接收推送通知而沒有推送服務?
- 2. 沒有從推到服務器端的推送通知
- 3. Ionic 2 - 沒有提供推送服務
- 4. iOS的Ionic推送通知
- 5. 使用PHP服務器端在IONIC 2上推送通知
- 6. 在ios中發送無推送通知但沒有APNS服務器的通知
- 7. 從服務器發送推送通知
- 8. 有沒有辦法,從通知中心獲取挖掘推送通知? (從服務器推送通知)
- 9. 推送銳沒有發送通知和沒有回撥推送服務
- 10. 沒有服務器部分的自動推送通知
- 11. Ionic 1推送通知
- 12. 蘋果推送通知服務 - 設備上沒有通知
- 13. Android中是否有推送通知服務,例如Apple推送通知服務?
- 14. Java中的推送通知服務器
- 15. Angular 2推送器的通知服務
- 16. Android推送通知 - 沒有設備在服務器註冊
- 17. 通知其他客戶沒有自己的服務器推送通知?
- 18. BB推送通知服務
- 19. 推送通知服務
- 20. 爲推送通知購買服務器
- 21. iOS推送通知服務器
- 22. 推送通知服務器問題
- 23. 服務器推送通知實現
- 24. 推送通知服務器實現
- 25. WP7推送通知服務器設置
- 26. 從服務器推送通知
- 27. xamarin.forms推送通知服務器端
- 28. Python服務器端iphone推送通知
- 29. 推送通知與PHP服務器?
- 30. 在服務器推送通知安裝
謝謝!它啓動 –
如何從webservice加載動態數據 –
@ R.Anandan:到目前爲止您嘗試過了什麼? – Nikola