我正在使用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的推送)。但我沒有找到解決方案。 我想知道是否有人經歷過類似的事情,並找到了解決方案,或者如果有人看到我的清單有問題。