【问题标题】:how to get android device token with phonegap and pushbots如何使用 phonegap 和 pushbots 获取 android 设备令牌
【发布时间】:2015-11-19 01:46:16
【问题描述】:

如何通过 phonegap 和 pushbots 获取 android 设备令牌?

我正在尝试使用此代码,但仍然无法正常工作!

 onDeviceReady: function() {
    app.receivedEvent('deviceready');

if(PushbotsPlugin.isiOS()){
PushbotsPlugin.initializeiOS("");
 }
 if(PushbotsPlugin.isAndroid()){
PushbotsPlugin.initializeAndroid("", "");
 }

 alert("outside alert");

 PushbotsPlugin.getToken(function(token){
  console.log(token);
  alert(token);
 });


}

资源: https://github.com/pushbots/phonegap

【问题讨论】:

  • 不工作怎么办?您收到错误消息了吗?

标签: android cordova get token device


【解决方案1】:

这不是一个简单的错误,您需要在初始化方法中包含推送机器人应用程序 ID 和 GCM 代码。即

PushbotsPlugin.initializeiOS("5614a0fd1779591xxxxxxxxxx");

PushbotsPlugin.initializeAndroid("5614a0fd1779591xxxxxxxxxx", "65xxxxxxxxxx");

此外,他们刚刚更新了 phonegap npm 上的插件,因此请将 config.xml 中的当前行替换为(如果您使用的是 phonegap 构建):

这应该可以解决问题!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-15
    • 2012-10-02
    • 1970-01-01
    • 1970-01-01
    • 2017-04-13
    相关资源
    最近更新 更多