科尔多瓦推插件:onNotificationGMC不会触发并不能获得REGID [英] Cordova Push Plugin: onNotificationGMC is not fired and cannot obtain regID

查看:189
本文介绍了科尔多瓦推插件:onNotificationGMC不会触发并不能获得REGID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我正在开发一个科尔多瓦混​​合应用程序,需要Android和iOS的推送通知服务工作,所以我安装了科尔多瓦插件的 PushPlugin

Hello everyone I'm developing a cordova Hybrid app that requires the Push Notification Service of Android and iOS to work and so I've installed the cordova plugin "PushPlugin".

下面是我的code

document.addEventListener(deviceready,deviceready,假);

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

function deviceready() {
    try {
        pushNotification = window.plugins.pushNotification;
        pushNotification.unregister(successHandler, errorHandler);
        pushNotification.register(
            successHandler,
            errorHandler, {
                "senderID": "7645XXXXXXXX",
                "ecb": "onNotificationGCM"
            });

        function successHandler(data) {
            alert("SUCCESS: " + JSON.stringify(data));
        };

        function errorHandler(e) {
            alert("ERROR" + e);
        }


        function onNotificationGCM(e) {
            alert("Done")
        }

    } catch (e) {
        alert(e);
    }
}

当我跑我的应用程序,我希望有两个提醒:succesHandler一个和onNotificationGCM之一,但它只激发succesHandler有一句话说:OK......有了这个问题,我甚至不能访问REGID参数将存储在我的服务器...

When I run my application I expect to have two alert: the succesHandler one and the onNotificationGCM one but it only fires the succesHandler one saying: "OK"... With this problem I can't even access the regID parameter that will be stored in my server...

有人可以解释我如何得到REGID ..我的所有工作都依赖于这种

Can someone please explain me how to get the regID.. All my work depend on this

我测试上的Galaxy S4迷你这个程序与Android 4.4.2。

I'm testing this app on a Galaxy S4 Mini with Android 4.4.2.

推荐答案

固定

我感动的onNotificationGCM在这样一个空的脚本标签:

I moved the onNotificationGCM in an empty script tag like this:

<script>
function onNotificationGCM(result) {
    alert(result.regid);
}
</script>

和现在给你REGID:)

And now it give you the regID :)

这篇关于科尔多瓦推插件:onNotificationGMC不会触发并不能获得REGID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆