0

我正在尝试使用 Android上的 PushWoosh 插件运行基于 Apache Cordova 的应用程序。为了避免 Android 上的碎片问题,我们使用MobileChromeApps来构建我们的 Android 版本的应用程序。但是,我无法通过 PushWoosh 为设备注册推送消息。该代码在 iOS 上完美运行。

一旦我运行,错误就会发生plugins.pushNotification.registerDevice

这就是adb logcat给我的:

D/PushNotifications(17915): Plugin Called
W/System.err(17915): java.lang.NullPointerException
W/System.err(17915):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.internalRegister(PushNotifications.java:189)
W/System.err(17915):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.execute(PushNotifications.java:390)
W/System.err(17915):    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:82)
W/System.err(17915):    at org.apache.cordova.PluginManager.exec(PluginManager.java:128)
W/System.err(17915):    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
W/System.err(17915):    at org.apache.cordova.engine.crosswalk.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
W/System.err(17915):    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err(17915):    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
W/System.err(17915):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(17915):    at android.os.Looper.loop(Looper.java:137)
W/System.err(17915):    at android.os.HandlerThread.run(HandlerThread.java:60)

看起来 Java 代码以某种方式失败了——但为什么以及如何失败,我不知道(网络开发人员的心,我不知道 Java)。该应用程序从不调用任何远程资源,因此错误必须在应用程序设置中的某个位置。

有任何想法吗?感谢所有帮助(如果您在哥本哈根,甚至可能会获得啤酒奖励)。

编辑:更详细的研究adb logcat -s System.err表明初始化也失败了,可能导致另一个错误

W/System.err( 7439): org.json.JSONException: No value for projectid
W/System.err( 7439):    at org.json.JSONObject.get(JSONObject.java:354)
W/System.err( 7439):    at org.json.JSONObject.getString(JSONObject.java:510)
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.initialize(PushNotifications.java:174)
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.execute(PushNotifications.java:384)
W/System.err( 7439):    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:82)
W/System.err( 7439):    at org.apache.cordova.PluginManager.exec(PluginManager.java:128)
W/System.err( 7439):    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
W/System.err( 7439):    at org.apache.cordova.engine.crosswalk.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
W/System.err( 7439):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 7439):    at android.os.Looper.loop(Looper.java:137)
W/System.err( 7439):    at android.os.HandlerThread.run(HandlerThread.java:60)
W/System.err( 7439): java.lang.NullPointerException
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.internalRegister(PushNotifications.java:190)
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.execute(PushNotifications.java:393)
W/System.err( 7439):    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:82)
W/System.err( 7439):    at org.apache.cordova.PluginManager.exec(PluginManager.java:128)
W/System.err( 7439):    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
W/System.err( 7439):    at org.apache.cordova.engine.crosswalk.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
W/System.err( 7439):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 7439):    at android.os.Looper.loop(Looper.java:137)
W/System.err( 7439):    at android.os.HandlerThread.run(HandlerThread.java:60)
W/System.err( 7439): java.lang.NullPointerException
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.internalRegister(PushNotifications.java:190)
W/System.err( 7439):    at com.pushwoosh.plugin.pushnotifications.PushNotifications.execute(PushNotifications.java:393)
W/System.err( 7439):    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:82)
W/System.err( 7439):    at org.apache.cordova.PluginManager.exec(PluginManager.java:128)
W/System.err( 7439):    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:63)
W/System.err( 7439):    at org.apache.cordova.engine.crosswalk.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err( 7439):    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:28)
W/System.err( 7439):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 7439):    at android.os.Looper.loop(Looper.java:137)
W/System.err( 7439):    at android.os.HandlerThread.run(HandlerThread.java:60)

太感谢了!

Github 问题在这里

4

2 回答 2

1

您似乎没有提供推送通知的凭据。它应该在您的 AndroidManifest.xml 中

在此处查看第 4 步:https ://www.pushwoosh.com/programming-push-notification/android/native-android-sdk-integration/

或在 onDeviceReady 函数中,请参见此处: https ://github.com/Pushwoosh/phonegap-3-sample-app/blob/master/www/js/PushwooshAndroid.js

于 2015-03-08T08:40:45.520 回答
0

(从答案开始,因为我没有足够的声誉来发表评论)

您是否在模拟器上测试推送通知?(你在 Github 问题中提到了“测试设备”,所以只是确认)

我问,因为模拟器既不能订阅也不能接收推送通知。

于 2015-03-07T20:19:10.047 回答