在离子应用

时间:2017-04-13 07:08:48

标签: azure ionic-framework push-notification

 我正在开发移动应用程序并使用fcm,azure通知中心添加推送通知功能。我在google firebase控制台中创建了项目,并获得了发件人ID和服务器密钥。然后在azure门户推送通知集线器中配置我的服务器密钥,并在带有发件人ID的app中安装推送通知插件。当我运行我的应用程序时,我得到推送注册ID,但在mobileServiceClient.push.register(' gcm',句柄,模板).done(registrationSuccess,registrationFailure)中收到错误,无法注册我的模板。 代码是:

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {  mobileServiceClient = new WindowsAzure.MobileServiceClient('url', 'server key');

pushNotification = PushNotification.init({
            "android": {
                "senderID": "*********"
            }
        });

        pushNotification.on('notification', function(data) {
            console.log(data.additionalData.docID);
        });

pushNotification.on('registration', function(data) {
            var platform = device.platform;
            var handle = data.registrationId;

            if (platform == 'android' || platform == 'Android') {
                var template = "{ \"data\" : {\"title\":\"$(title)\",\"message\":\"$(message)\",\"image\":\"$(image)\",\"channels\":\"$(channels)\",\"docID\":\"$(docID)\",\"additionalData\":\"$(additionalData)\"}}"
                $rootScope.mobileServiceClient.push.register('gcm', handle, template).done(registrationSuccess, registrationFailure);
            }
        });
                var registrationSuccess = function() {
            $rootScope.ShowToast("Registered with Server!", false);
        }
        var registrationFailure = function(error) {  
            console.log('Failed registering with Server: ' + error); // error is coming here
        } }

错误:

向服务器注册失败:错误:

0 个答案:

没有答案