我目前正在将我的项目更新为 targetSdkVersion 26 (Android O),并从 GCM 迁移到 FCM。
目前我有:
RegistrationIntentService获取 GCM 令牌并将此令牌发布到服务器的A。MainActivity检查GooglePlayServices然后启动RegistrationIntentService.A
MyInstanceIDListenerService具有onTokenRefresh刚刚启动RegistrationIntentService.
这是基于 Google示例。
要迁移到 FCM,我只需更改MyInstanceIDListenerService为继承自FirebaseInstanceIdService,RegistrationIntentService现在用于FirebaseInstanceId获取令牌。
一切似乎都正常,我在 Android O 模拟器中对其进行了测试。
但是,我知道 Android O 正在限制后台服务。RegistrationIntentService所以,我想知道在以 Android O 为目标的应用程序中从MainActivityand开始是否仍然可以MyInstanceIDListenerService。
或者我应该将RegistrationIntentService代码移动到要由 执行的任务WorkManager吗?
谢谢。