下面的代码是从google引用来支持GCM的,
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.example.gcm" />
</intent-filter>
</receiver>
<service
android:name="com.example.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.example.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
查询 1. 根据谷歌文档,后台执行限制对 Android Oreo 的上述任何影响?或者它会按预期工作而无需更改任何代码?
此外,正如谷歌在下面建议的那样,
如果您在应用开发中以 Android 8.0(API 级别 26)或更高版本为目标,请使用 Firebase Cloud Messaging (FCM)。否则,使用 JobIntentService 类而不是 IntentService 来处理令牌刷新。
查询 2. 基于上述陈述,以下方法是否正确?
@Override
public void onTokenRefresh() {
if (Build.VERSION.SDK_INT >= 26) {
//start JobIntentService
} else {
// start intent service
}
如果是,那么 enqueueWork 的调用者是谁?
注意:由于某些限制,无法迁移到 FCM。