Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.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/0/search/2.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版本8+;中未收到FCM通知;另外,未调用onMessageReceived()_Android_Firebase_Firebase Cloud Messaging - Fatal编程技术网

android版本8+;中未收到FCM通知;另外,未调用onMessageReceived()

android版本8+;中未收到FCM通知;另外,未调用onMessageReceived(),android,firebase,firebase-cloud-messaging,Android,Firebase,Firebase Cloud Messaging,这是我的代码 有人能帮我吗 firebase依赖项:实现“com.google.firebase:firebase消息传递:12.0.1” buidgradle main:classpath'com.google.gms:google服务:4.0.1' 我已经试过了你是如何发送消息的?这是fcm令牌的问题,只是因为更新了firebase依赖性。 @Override public void onMessageReceived(RemoteMessage remoteMessage) {

这是我的代码

有人能帮我吗
firebase依赖项:实现“com.google.firebase:firebase消息传递:12.0.1”

buidgradle main:classpath'com.google.gms:google服务:4.0.1'


我已经试过了

你是如何发送消息的?这是fcm令牌的问题,只是因为更新了firebase依赖性。
@Override
 public void onMessageReceived(RemoteMessage remoteMessage) {


  Intent intent = new Intent(this, SOMEACTIVITY.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
                PendingIntent.FLAG_ONE_SHOT);

        String channelId = getString(R.string.default_notification_channel_id);


        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId)
                .setContentTitle(title)
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent)
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                .setDefaults(Notification.DEFAULT_ALL);


        notificationBuilder.setSmallIcon(R.drawable.ic_notification_white_icon);

        if (image != null) {
            notificationBuilder
                    .setStyle(new NotificationCompat.BigPictureStyle()
                            .bigPicture(image).setSummaryText(messageBody));/*Notification with Image*/
        } else {
            notificationBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody));
        }

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


        // Since android Oreo notification channel is needed.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

            NotificationChannel channel = new NotificationChannel(channelId,
                    "Channel Name",
                    NotificationManager.IMPORTANCE_DEFAULT);

            notificationManager.createNotificationChannel(channel);
        }

        notificationManager.notify(0, notificationBuilder.build());

 }