PhoneGap构建推送通知(Android)

 张力宏智荣琬郁_271 发布于 2023-01-18 15:30

我无法接收任何类型的回调用于phonegap构建的推送通知插件,我已将该插件包含在config.xml中.

我已经注册了GCM并获得了pushNotification.register()所需的项目编号.

我也可以访问window.plugins.pushNotification对象,所以我知道它包含了插件.

PhoneGap Build版本: 3.1

保湿:禁用

调试:启用

设备:三星Tab 2

我的index.html js文件包括:








我的config.xml插件包括:

// plugins







// access to external domains

我的app.js调用pushNotification.register()

var app = {
init: function() {
    document.addEventListener("deviceready", this.onDeviceReady, false);
    },

    onDeviceReady: function(){
       // DO STUFF
       // ....

       // ENABLE PUSH
       this.push_init();
    },

    push_init: function(){
        app.SENDER_ID = 123456789; // replaced by my actual GCM project no

        var pushNotification = window.plugins.pushNotification;

        pushNotification.register( 
            function(){alert('Push: win');}, // never called
            function(){alert('Push: Error');},  // never called
            { senderID: app.SENDER_ID, ecb: "app.push_android" }
        );
    },
   // never called
   push_android: function(e){
       alert('connection established...');
   console.log( 'successfully started android' );
   console.log( e );
   }

};

// start the app
app.init();

在调用之后,没有执行任何操作,app.push_android()是app对象的一个​​功能.

如果我没有输入senderID,我会收到错误,说明没有发件人ID,所以我知道某些内容正在运行.这是多么令人沮丧的想法?

PS - 我也注意到一些奇怪的东西,当我调试window.log window.plugins.pushNotification它返回一个空对象,但是我仍然可以调用window.plugins.pushNotification.register(),但我想我会在控制台内看到日志.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有