【发布时间】:2017-12-02 04:01:54
【问题描述】:
我有一个使用 firebase 和 cordova-plugin-badge 的 Ionic3 应用程序。 如果应用程序在前台运行并且我收到推送通知,则徽章编号会增加。
import { Badge } from '@ionic-native/badge';
declare let FCMPlugin;
constructor(private badge: Badge) {
this.platform.ready().then(() => {
FCMPlugin.onNotification((data) => {
this.badge.increase(1); // works when app is in foreground
if (data.wasTapped) {
//Notification was received on device tray and tapped by the user.
this.handleNotificationsWhenInBackground(data);
} else {
//Notification was received in foreground. Maybe the user needs to be notified.
this.handleNotificationsWhenInForeground(data);
}
},
(msg) => {
},
function (err) {
});
});
}
当应用程序处于后台但徽章编号未增加时,我会收到推送通知。如果我在应用程序处于后台时单击在 android 上收到的推送通知,则徽章编号会增加。因此,只有在应用处于前台时才会调用增加徽章编号的代码。
我的问题是:当应用程序在后台并且我收到推送通知时如何增加徽章编号。
【问题讨论】:
标签: android firebase cordova-plugins ionic3 badge