0
如何在科爾多瓦應用程序(混合應用程序)中自動增加推送通知徽章。 我正在使用Ionic框架來開發應用程序。科爾多瓦應用程序(混合應用程序)中的自動增量推送通知徽章
當我從服務器獲取推送通知。我想自動更新徽章計數。
如何在科爾多瓦應用程序(混合應用程序)中自動增加推送通知徽章。 我正在使用Ionic框架來開發應用程序。科爾多瓦應用程序(混合應用程序)中的自動增量推送通知徽章
當我從服務器獲取推送通知。我想自動更新徽章計數。
$ rootScope。$ apply();需要 才能反映您的更改。使用rootScope變量來反映通知計數。
$ionicPlatform.ready(function() {
FCMPlugin.getToken(function(token) {
console.log('Device Token : ' + token);
DataSharingService.setItem('deviceToken', token);
});
//FCMPlugin.onNotification(onNotificationCallback(data), successCallback(msg), errorCallback(err))
//Here you define your application behaviour based on the notification data.
FCMPlugin.onNotification(function(data) {
console.log('Recived data : ' + JSON.stringify(data));
**$rootScope.notificationCountValue = $rootScope.notificationCountValue + 1;**
$rootScope.notificationArray.push(data);
DataSharingService.setItem('notificationData', $rootScope.notificationArray);
**$rootScope.$apply();**
if (data.wasTapped) {
//Notification was received on device tray and tapped by the user.
console.log(JSON.stringify(data));
App.go('notifications', { obj: data });
} else {
//Notification was received in foreground. Maybe the user needs to be notified.
console.log(JSON.stringify(data));
}
});
});