【问题标题】:cordova - android app crashes when receive one push notificationcordova - 收到一个推送通知时,android应用程序崩溃
【发布时间】:2015-04-02 18:00:08
【问题描述】:

我使用 Cordova 3.0 和 Visual Studio 2013 制作了一个安卓应用;在这个应用程序中,我将这个 Push Notification 插件与 Google Cloud Messaging Service 一起使用。

注册应用程序工作正常,因为我从 GCM 获得了 te RegID,并且我的 Web 服务器中的注册也工作正常,但是,当我向设备发送任何通知时出现问题:应用程序在收到推送时崩溃,并且什么也不显示。

我没有日志,因为应用程序在 Cordova 上,而 Visual Studio 无法调试此应用程序类型。

请帮我解决这个问题。

提前谢谢你。来自墨西哥的问候。

【问题讨论】:

  • 发布错误控制台崩溃报告...
  • 你得到了什么错误信息?
  • 我很确定您可以使用 Visual Studio 2013 和 2015 调试 phonegap 应用程序

标签: android cordova push-notification visual-studio-cordova


【解决方案1】:

嗯,确实,经过大量研究,我终于可以在 VS 中调试我的应用程序(我在启动 adb.exe 时遇到了问题)。在日志中,我可以看到我的代码在创建接收器时存在错误,这是错误:Unable to instantiate receiver com.myapp.GcmBroadcastReceiver

我查看了一下,发现我的 AndroidManifest.xml 中可能有错误;然后我完全按照 Cordova 的文档中的说明进行操作,然后……这有效!

这是 Android Manifest 权限和更多 (Here is the Docs):

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="$PACKAGE_NAME.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="$PACKAGE_NAME.permission.C2D_MESSAGE" />

<activity android:name="com.plugin.gcm.PushHandlerActivity"/>
<receiver android:name="com.plugin.gcm.CordovaGCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
    <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category android:name="$PACKAGE_NAME" />
    </intent-filter>
</receiver>
<service android:name="com.plugin.gcm.GCMIntentService" />

谢谢大家

【讨论】:

    猜你喜欢
    • 2014-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多