【问题标题】:Cordova PushPlugin not working on Galaxy S2, does work on S3 (same API level)Cordova PushPlugin 在 Galaxy S2 上不工作,在 S3 上工作(相同的 API 级别)
【发布时间】:2013-10-18 10:30:55
【问题描述】:

我们已经构建了一个 PhoneGap / Cordova 应用程序并使用 PushPlugin 来处理推送通知。

在 Galaxy S3 (Android 4.1.2) 上一切正常,我们确实会收到推送通知。但是,在 Galaxy S2(也是 Android 4.1.2)上,我们不会收到推送通知(尽管我们会收到 devicetoken)。

由于两个设备都运行相同的 Android 版本,它们具有相同的 API 级别。另外因为它适用于较新的 (S3) 设备,所以我认为代码没问题。

这是我们的 AndroidManifest.xml:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="8" android:versionName="1.0.0" android:windowSoftInputMode="adjustPan" package="com.APPHQ.APPNAME" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="18" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <permission android:name="com.APPHQ.APPNAME.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.APPHQ.APPNAME.permission.C2D_MESSAGE" />
    <application android:allowBackup="true" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="APPNAME" android:theme="@android:style/Theme.Black.NoTitleBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <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="com.APPHQ.APPNAME" />
            </intent-filter>
        </receiver>
        <service android:name="com.plugin.gcm.GCMIntentService" />
    </application>
</manifest>

知道我们需要做什么才能让推送通知在 S2 上正常工作吗?

非常感谢!

罗宾

【问题讨论】:

  • 你在 s2 上使用自定义 rom 吗?
  • 电话开箱即用。但是,ROM 可以由供应商定制(例如,由运营商定制版本的电信公司、沃达丰)。
  • @A.S.有什么建议?猜猜你的问题是针对某些东西! :)
  • 嗯...抱歉,在自定义 rom 中缺少一些谷歌服务,但您的设备上有一个真正的 android。我对 s2 和推送通知没有任何问题。也许您必须通过 LogCat 检查是否调用了 s2 上的 onRecive 并且清单是否正确,或者您的 Web 服务没有调用第二个例程来推送 s2 或或或。尝试以更合适的方式调试它
  • 在 logcat 中,我们确实看到了 devicetoken 进入,但是没有触发推送消息。它们位于具有相同代码的较新设备上,例如 S3。清单应该是正确的?这真的很奇怪。 :)

标签: android cordova push-notification phonegap-plugins


【解决方案1】:

您一定已经检查过了,但仍想提醒您检查以下事项,以便 GCM 在设备上运行

  1. 设备应配置一个有效的 gmail 帐户
  2. 必须登录 Android Market(Play 商店)(您应该接受条款和许可)
  3. 数据连接工作正常

【讨论】:

  • 检查了这个,一切正常,仍然没有收到推送!
【解决方案2】:

我猜你的主包是“com.APPHQ.APPNAME”。 将您的 GCMIntentService 类放在这个包中,并在清单文件中声明它,如下所示:

<service android:name=".GCMIntentService" />

希望这会有所帮助。

【讨论】:

  • 等等。在哪里?它已经在清单中,但还需要在其他地方定义?
  • 在你的主包中添加 GCMIntentService 类而不是 com.plugin.gcm 包。
猜你喜欢
  • 2014-01-01
  • 1970-01-01
  • 2014-06-15
  • 2021-05-27
  • 2012-07-05
  • 2020-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多