Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android FCM,显示推送通知的平视显示_Android_Firebase_Push Notification_Firebase Cloud Messaging_Android Notifications - Fatal编程技术网

Android FCM,显示推送通知的平视显示

Android FCM,显示推送通知的平视显示,android,firebase,push-notification,firebase-cloud-messaging,android-notifications,Android,Firebase,Push Notification,Firebase Cloud Messaging,Android Notifications,我看得出来 public void onMessageReceived(RemoteMessage remoteMessage) 接收推送时调用(当应用程序处于后台时) 但它不显示推送通知的任何UI 我想要如下的东西 我想我已经看到了十几个这样的问题,最明显的是下面的一个,但是就像我提到的onMessageReceived已经被调用了,只是UI没有显示 我的推送显示用户界面的代码如下,除此之外我还需要做其他工作吗 Notification notification = notific

我看得出来

public void onMessageReceived(RemoteMessage remoteMessage)
接收推送时调用(当应用程序处于后台时)

但它不显示推送通知的任何UI

我想要如下的东西

我想我已经看到了十几个这样的问题,最明显的是下面的一个,但是就像我提到的
onMessageReceived
已经被调用了,只是UI没有显示

我的推送
显示
用户界面的代码如下,除此之外我还需要做其他工作吗

   Notification notification = notificationBuilder.build();
   notification.flags |= Notification.FLAG_AUTO_CANCEL;

   NotificationManager notificationManager =
     (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

   JSONObject push = notificationArgsObj.optJSONObject("push");
   if(push != null) {
     String sound = push.optString("sound");
     if(sound.equals("default")) {
       notification.sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
     }
   }

   notificationManager.notify(destination_id, notification);

你试过设置ChannelID吗

从Android 8.0(API级别26)开始,所有通知必须分配到一个频道。对于每个通道,可以设置应用于该通道中所有通知的视觉和听觉行为。然后,用户可以更改这些设置,并决定应用程序中的哪些通知频道应该是侵入性的或可见的

警告:如果你的目标是Android 8.0(API级别26)并发布 不指定通知通道的通知 通知不会出现,系统会记录错误

您构建了一个通知(
notificationBuilder.build();
),但没有设置任何其他相关数据(如内容标题/文本)。首先尝试添加它们,看看是否显示。