$ cordovaPushV5 onNotification没有解雇

时间:2017-02-06 19:21:47

标签: 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 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

以下是我对FCM历史的截图 -

FCM History

我按照以下链接实施 - https://github.com/yafraorg/yafra/wiki/Blog-Ionic-PushV5

我错过了什么?

0 个答案:

没有答案