【发布时间】:2020-01-09 04:23:22
【问题描述】:
我在后台模式下使用 FCM 推送通知启动服务,但应用程序在终止应用程序后不会收到任何通知。而且我只在vivo设备中遇到了这个问题。在其他设备上,它工作正常。
当我手动启用自动启动时,它会正常工作。但如果没有启用自动启动,它将无法正常工作。
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent intent = new Intent(ACTION_MAIN);
intent.setClass(this, LinphoneService.class);
intent.putExtra("PushNotification", true);
startForegroundService(intent);
} else {
Intent intent = new Intent(ACTION_MAIN);
intent.setClass(this, LinphoneService.class);
intent.putExtra("PushNotification", true);
startService(intent);
}
每当应用在所有设备中收到 Firebase 推送通知时,我都需要启动我的服务,而无需启用自动启动。
【问题讨论】:
标签: android firebase firebase-cloud-messaging