1
發送用戶到一個特定的視圖正在努力點擊本地通知,但只有當應用程序在前臺,當我關閉應用程序,然後得到通知它發送到只有主網頁,其中在如何發送用戶到特定的頁面上點擊ngCordova本地通知當應用程序在後臺
$urlRouterProvider.otherwise("/");
例如定義,我們沒有使用WhatsApp的時候,我們得到一個新的消息通知,當我們點擊它,它把我們送到特定聊天頁面不whatsapp的主要頁面,我如何實現它?
控制器:
$ionicPlatform.ready(function() {
$scope.scheduleDelayedNotification = function() {
var now = new Date().getTime();
var _5_SecondsFromNow = new Date(now + 5 * 1000);
$cordovaLocalNotification.schedule({
id: 1,
title: 'New Notification',
text: 'Notification Message',
at: _5_SecondsFromNow
}).then(function (result) {
alert("Notification Set");
});
cordova.plugins.notification.local.on("click", function (notification, state) {
$state.go('feedback');
}, this)
};
});
app.js
var ionicApp = angular.module('starter', ['ionic', 'localNotificationModule']);
ionicApp.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
});
ionicApp.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/',
templateUrl: 'views/home.html'
})
.state('feedback', {
url: '/feedback',
templateUrl: 'views/feedback.html'
});
$urlRouterProvider.otherwise("/");
});
UPDATE:
services.js
servicesModule.service('FirstRunScheduling', ['$rootScope', '$ionicPlatform', '$cordovaLocalNotification', '$state', function($rootScope, $ionicPlatform, $cordovaLocalNotification, $state){
var ref = new Firebase("https://feedback-system.firebaseio.com/TestTimeTable");
ref.once("value", function(data) {
var TestTimeTable = data.val().TestTimeTable;
var notificationDate;
var notificationID;
if(data.val().first_run == false)
{
$ionicPlatform.ready(function() {
for(var i in TestTimeTable)
{
notificationDate = new Date(TestTimeTable[i].year, TestTimeTable[i].month, TestTimeTable[i].day, TestTimeTable[i].hour, TestTimeTable[i].minute, 0, 0);
notificationID = i + ref.getAuth().uid.split(":")[1];
$cordovaLocalNotification.schedule({
id: notificationID,
title: 'Feedback Reminder',
text: 'Please Provide Lecture Feedback',
at: notificationDate,
autoCancel: true
}).then(function (result) {
alert("Set");
});
cordova.plugins.notification.local.on("click", function (notification, state) {
$state.go('tabs.feedback');
}, this)
}
});
}
ref.update({
first_run: true,
});
});
}]);
進出口新的角度和離子,我的理解是我shud把它放在外面功能「scheduleDelayedNotification」,虐待試試吧,謝謝 –
它的工作,感謝 –
酷,很高興聽到:) – dancampers