Android FCM通知不是在后台接收,而是在前台接收。对背景有什么建议(应用程序被终止时)?

Android FCM通知不是在后台接收,而是在前台接收。对背景有什么建议(应用程序被终止时)?,android,firebase-cloud-messaging,android-8.0-oreo,Android,Firebase Cloud Messaging,Android 8.0 Oreo,我已经为奥利奥制作了高优先级的频道。我在前台收到来自oreo firebase控制台的通知,但不是在后台(当应用程序从RAM中被杀死时)。 奥利奥以下一切都很好 //fcm onMessage @Override public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { Intent intent=new Intent(this,HomeActivity.class); intent.setF

我已经为奥利奥制作了高优先级的频道。我在前台收到来自oreo firebase控制台的通知,但不是在后台(当应用程序从RAM中被杀死时)。 奥利奥以下一切都很好

//fcm onMessage


 @Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
    Intent intent=new Intent(this,HomeActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent=PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
    final String title=remoteMessage.getData().get("title");
    final String msg=remoteMessage.getData().get("body");
    if( title!=null && msg!=null){
        final Notification not = new NotificationCompat.Builder(this, CHANNEL_WELCOME)
                .setContentTitle(title)
                .setContentText(msg)
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                .setCategory(NotificationCompat.CATEGORY_ALARM)
                .setSmallIcon(R.mipmap.ic_logo_final)
                .setContentIntent(pendingIntent)
                .build();
        NotificationManagerCompat compat = NotificationManagerCompat.from(getApplicationContext());
        compat.notify(33333, not);
    }

}

有两种类型的通知 1-通知消息,有时被认为是“显示消息”。这些消息由FCM SDK自动处理。 2-数据消息,由客户端应用程序处理 你需要同时处理这两个问题 @凌驾 收到消息时公共无效(RemoteMessage RemoteMessage){

} //if(remoteMessage.getNotification()!=null){ //Log.d(标记“Mesage body:”+remoteMessage.getNotification().getBody());
}

首先检查您的手机是否未处于节电模式,先生。然后检查您的aap的android后台服务的权限是否打开通知。选中和绿色都可以。您能详细说明吗?
    Log.d(TAG, "FROM:" + remoteMessage.getFrom());

    //Check if the message contains data
    if (remoteMessage.getData().size() > 0) {