【问题标题】:Pushnotifications in not working on 2.3.3 and working on 4.x devices无法在 2.3.3 和 4.x 设备上运行的推送通知
【发布时间】:2013-12-08 14:33:48
【问题描述】:

我在此文档http://developer.android.com/google/gcm/client.html 的帮助下编写了一个推送通知示例。它适用于 4.x 设备,不适用于 2.3.3 设备。

这是我的许可:

<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />

<permission
    android:name="com.example.testing.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.testing.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.google.android.c2dm.permission.REGISTRATION" />


   <receiver
        android:name="com.example.testing.GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>

            <!-- Receives the actual messages. -->
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

            <category android:name="com.example.testing" />
        </intent-filter>
    </receiver>

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

【问题讨论】:

  • 您在 2.3.3 设备上遇到什么错误?发布你的 Logcat
  • 能否请您更准确地说您遇到了什么错误?相当于说“我的应用程序不工作,怎么了?”
  • in onReceive() String messageType = gcm.getMessageType(intent);总是返回 null。

标签: android push-notification


【解决方案1】:

查看文档:

作为 GCM 的 android.permission.GET_ACCOUNTS 权限需要 Google 帐户(仅当设备运行的版本低于 Android 4.0.4 时才需要)

示例中没有此权限。

【讨论】:

  • 是的,我添加了该权限。
猜你喜欢
  • 1970-01-01
  • 2018-05-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多