我在Android应用程序中使用FCM。当应用程序在后台运行但从后台终止后,通知运行正常。
我的手机是 oppo f9 pro
我手动启用了自动启动功能,并在后台启用了允许。
在后台启用
我的Firebase服务
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "myFirebaseMsgService";
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Log.d(TAG, "From : " + remoteMessage.getFrom());
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message Data : " + remoteMessage.getData());
}
if (remoteMessage.getNotification() != null) {
}
}
}
发送有效载荷
{
"notification":{"title":"testing of notification - new ","body":"body of notification ","sound":"Enabled"
},
"data":{
"id":74,
"callFrom":"test",
"other_info":"other detail in other info"
},
"to":"c5V-l4poMYI:APA91bFk8DO6upFN9dSXjI3d9UXpRUvmdzPo9OyUV9LnLJhCA6vBQ4y6TuXWHg1vaGM0SV6bEOLDW38UFEsVhcHFRvT7oIkGNmtd2v6516ABh6MyvkuoFP7gwUJWOPQRCaPsVg8_O2ot"
}