【发布时间】:2018-11-03 05:01:36
【问题描述】:
在摩托罗拉测试应用程序,三星在应用程序被杀死时工作正常。但是当我在vivo中测试应用程序时,如果应用程序被破坏,oppo就无法工作。
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.e(TAG, "From: " + remoteMessage.getFrom());
if (remoteMessage == null)
return;
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.e(TAG, "Notification Body: " + remoteMessage.getNotification().getBody());
// handleNotification(remoteMessage.getNotification().getBody());
}
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.e(TAG, "Data Payload: " + remoteMessage.getData().toString());
try {
JSONObject json = new JSONObject(remoteMessage.getData().toString());
handleDataMessage(json);
} catch (Exception e) {
Log.e(TAG, "Exception: " + e.getMessage());
}
}
}
Android 清单 xml:
<service
android:name="notification.MyFirebaseMessagingService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="notification.MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
在vivo的情况下我没有收到消息,建议oppo任何帮助。
【问题讨论】:
-
以vivo为例,oppo的android os版本是多少?
-
@Arpan os 是奥利奥。
-
不同之处在于,摩托罗拉和三星只是从“Recents”中清除应用程序,它的后台服务仍在运行,其中之一是 FCM 服务。而“vivo”和“oppo”强制关闭应用程序,同时关闭所有后台服务,因此它的 FCM 服务也关闭,该服务处理应用程序的自定义通知。
-
@Harish 我遇到了同样的问题,检查一下我的解决方案stackoverflow.com/a/52943903/7666442
-
@Nilesh Rathod 我会试试这个,但不会进入 oppo 手机。
标签: android firebase push-notification firebase-cloud-messaging