所有我使用ionic来构建应用程序并使用firebase中的FCM插件使用推送通知功能。
它工作正常但是当我点击通知时,我需要打开我的应用并显示一条提醒并在我尝试的应用内显示通知消息,但我无法正常使用。
我附上了我的代码,请帮助如何解决这个问题我在控制台中也没有出现任何错误
var app = angular.module('starter', ['ionic'])
app.controller('AppCtrl', function ($scope) {
})
app.run(function ($ionicPlatform) {
$ionicPlatform.ready(function () {
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
debugger;
FCMPlugin.getToken(
function (token)
{
debugger;
alert('Token: ' + token);
console.log('Token: ' + token);
},
function (err) {
debugger;
alert('error retrieving token: ' + token);
console.log('error retrieving token: ' + err);
}
);
FCMPlugin.onNotification(
function (data)
{
debugger;
if (data.wasTapped) {
//Notification was received on device tray and tapped by the user.
alert("Tapped: " + JSON.stringify(data));
} else {
//Notification was received in foreground. Maybe the user needs to be notified.
alert("Not tapped: " + JSON.stringify(data));
}
},
function (msg) {
debugger;
alert('onNotification callback successfully registered: ' + msg);
console.log('onNotification callback successfully registered: ' + msg);
},
function (err) {
debugger;
alert('Error registering onNotification callback: ' + err);
console.log('Error registering onNotification callback: ' + err);
}
);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
});
})