我正在使用Android Studio。我在我的应用中实施了推送服务。它正在与所有类型的设备与较新的Android版本,但它不会与Android 2.3.6 Galaxy S2迷你工作。 该设备通过Urban Airship图书馆接收其他应用的推送。IntentReceiver未使用Android版本调用<4.1
舱单的相关部分:
<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="com.my_app.app.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.my_app.app.permission.C2D_MESSAGE" />
<receiver
android:name=".IntentReceiver"
android:permission="com.google.android.c2dm.permission.SEND"
>
<intent-filter
android:priority="100">
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<action android:name="com.google.android.c2dm.intent.C2D_MESSAGE" />
<category android:name="com.my_app.app" />
</intent-filter>
</receiver>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<service android:name=".GCMIntentService"
android:enabled="true"/>
IntentReceiver.java:
import android.support.v4.content.WakefulBroadcastReceiver;
public class IntentReceiver extends WakefulBroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//doing some stuff & starting my service here,
//never gets called with said device
}
}
设备获取与推送注册。我必须在返回id之前调用它两次,但正确的Id保存在我的后端(我手动发送推送,所以不应该是问题)。当应用程序处于前台时,我还从代码注册了第二个接收器,但没有一个被调用。
如果我在我的清单中添加<uses-permission android:name="android.permission.C2D_MESSAGE" />
,我会在发送推送时收到com.google.android.c2dm.intent.REGISTRATION
操作。
我与Galaxy Tab有同样的问题。在更新之前,每次推送都会收到"com.google.android.c2dm.intent.REGISTRATION"
(使用intent.getStringExtra(“未注册”))。因此,与其获得RECEIVE一样,它只是未注册,就像Galaxy Mini一样。然后我将它更新到4.2.2。它现在每次推送都会收到RECEIVE。 我很少读到这个问题(没有收到< 4.1的推送)。但我没有找到解决方案。 我想知道是否有人经历过类似的事情,并找到了解决方案,或者如果有人看到我的清单有问题。