Ionic framework $CORDOVAPUSHONV5通知未触发

Ionic framework $CORDOVAPUSHONV5通知未触发,ionic-framework,cordova-plugins,phonegap-pushplugin,Ionic Framework,Cordova Plugins,Phonegap Pushplugin,我正在尝试使用$cordovaPushV5在Ionic V1中实现推送通知,但我无法开始工作。我能够获得设备注册ID,但当我使用Firebase云消息测试通知时,它不起作用。下面是app.js代码- // ionic Starter App // angular.module is a global place for creating, registering and retrieving Angular modules // 'starter' is the name

我正在尝试使用$cordovaPushV5在Ionic V1中实现推送通知,但我无法开始工作。我能够获得设备注册ID,但当我使用Firebase云消息测试通知时,它不起作用。下面是app.js代码-

   // ionic Starter App
    // angular.module is a global place for creating, registering and retrieving Angular modules
    // 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
    // the 2nd parameter is an array of 'requires'
    // 'starter.controllers' is found in controllers.js
    var app = angular.module('starter', ['ionic', 'ngCordova'])
        .run(function ($ionicPlatform, $cordovaPushV5, $rootScope, $cordovaLocalNotification) {
        $ionicPlatform.ready(function () {
            // hide the accessory bar by default (remove this to show the accessory bar above the keyboard
            // for form inputs)
            if (cordova.platformId === 'ios' && window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
                cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
                cordova.plugins.Keyboard.disableScroll(true);
            }
            if (window.StatusBar) {
                // org.apache.cordova.statusbar required
                window.StatusBar.styleLightContent();
            }
            console.log('app.js');
            var options = {
                android: {
                    senderID: "981686413111"
                },
                ios: {
                    alert: "true",
                    badge: "true",
                    sound: "true"
                },
                windows: {}
            };
            $cordovaPushV5.initialize(options).then(function (result) {
                // start listening for new notifications
                $cordovaPushV5.onNotification();
                // start listening for errors
                $cordovaPushV5.onError();
                // register to get registrationId
                $cordovaPushV5.register().then(function (registrationId) {
                    // save `registrationId` somewhere;
                    console.log(registrationId);
                    localStorage.setItem('deviceID', registrationId);
                }, function (err) {
                    console.log(err);
                });
            });
            $rootScope.$on('$cordovaPushV5:notificationReceived', function (event, data) {
                console.log(data);
            });
            $rootScope.$on('$cordovaPushV5:errorOccurred', function (event, error) {
                console.log("notification error occured");
                console.log("event object: ", event);
                console.log("error object: ", error);
            });
            $cordovaPushV5.finish().then(function (result) {
                // OK finished - works only with the dev-next version of pushV5.js in ngCordova as of February 8, 2016
            }, function (err) {
                // handle error
                console.log('finish error');
            });
            //$cordovaPushV5.unregister();
        });
    });

    //# sourceMappingURL=app.js.map
//ionic Starter应用程序
//angular.module是创建、注册和检索angular模块的全局位置
//“starter”是此角度模块示例的名称(也在index.html中的属性中设置)
//第二个参数是“requires”的数组
//可以在controllers.js中找到“starter.controllers”
var app=angular.module('starter',['ionic','ngCordova']))
.run(函数($ionicPlatform、$cordovaPushV5、$rootScope、$cordovaLocalNotification){
$ionicPlatform.ready(函数(){
//默认情况下隐藏附件栏(删除此选项可在键盘上方显示附件栏)
//表格输入)
if(cordova.platformId=='ios'&&window.cordova&&window.cordova.plugins&&window.cordova.plugins&&window.cordova.plugins.Keyboard){
插件键盘hideKeyboardAccessoryBar(真);
插件。键盘。禁用滚动(真);
}
如果(窗口状态栏){
//需要org.apache.cordova.statusbar
window.StatusBar.styleLightContent();
}
console.log('app.js');
变量选项={
安卓:{
森德里德:“981686413111”
},
ios:{
警告:“正确”,
徽章:“正确”,
声音:“真的”
},
窗口:{}
};
$cordovaPushV5.初始化(选项)。然后(函数(结果){
//开始侦听新通知
$cordovaPushV5.onNotification();
//开始监听错误
$cordovaPushV5.onError();
//注册以获取注册ID
$cordovaPushV5.register().then(函数(registrationId){
//将'registrationId'保存在某处;
console.log(注册ID);
setItem('deviceID',registrationId);
},函数(err){
控制台日志(err);
});
});
$rootScope.$on(“$cordovaPushV5:notificationReceived”,函数(事件、数据){
控制台日志(数据);
});
$rootScope.$on(“$cordovaPushV5:erroroccurrent”,函数(事件,错误){
console.log(“发生通知错误”);
日志(“事件对象:”,事件);
log(“错误对象:”,错误);
});
$cordovaPushV5.finish().then(函数(结果){
//OK finished-自2016年2月8日起,仅适用于ngCordova中的下一版本pushV5.js
},函数(err){
//处理错误
log('finisherror');
});
//$cordovaPushV5.unregister();
});
});
//#sourceMappingURL=app.js.map
这是我的FCM历史截图-

我遵循以下链接来实现-


我遗漏了什么?

你找到什么了吗?Me too$cordovaPushV5.onNotification()在接收通知时不会被激发。这就是我所做的,我在脚本中保留了PushV5的代码,并添加了OneSignal的代码。我尝试了一个信号推送测试,收到了两个通知。一个来自一个信号事件,另一个来自PushV5。我猜FCM推送测试不起作用。我不知道发生了什么,所以我放弃了pushV5,使用了OneSignal。你找到什么了吗?Me too$cordovaPushV5.onNotification()在接收通知时不会被激发。这就是我所做的,我在脚本中保留了PushV5的代码,并添加了OneSignal的代码。我尝试了一个信号推送测试,收到了两个通知。一个来自一个信号事件,另一个来自PushV5。我猜FCM推送测试不起作用。我不确定发生了什么,所以我放弃了pushV5,使用了OneSignal。