Уведомление fcm не достигает в Samsung Note 9 - PullRequest
0 голосов
/ 28 ноября 2018

я использую уведомления FCM в своем приложении, я использовал облачную функцию для прослушивания определенного узла и отправки уведомлений по темам и подписки на темы в Android для получения сообщения

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {


    String notificationTitle = null, notificationBody = null;

    // Check if message contains a notification payload.
    if (remoteMessage.getNotification() != null) {
        Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
        notificationTitle = remoteMessage.getNotification().getTitle();
        notificationBody = remoteMessage.getNotification().getBody();
    }


    createNotification(notificationTitle,notificationBody);
}


private NotificationManager notifManager;
public void createNotification(String  title,String aMessage) {
    final int NOTIFY_ID = 0; // ID of notification
    String id = "asd";// default_channel_id
     // Default Channel
    Intent intent;
    PendingIntent pendingIntent;
    NotificationCompat.Builder builder;
    if (notifManager == null) {
        notifManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        int importance = NotificationManager.IMPORTANCE_HIGH;
        NotificationChannel mChannel = notifManager.getNotificationChannel(id);
        if (mChannel == null) {
            mChannel = new NotificationChannel(id, title, importance);
            mChannel.enableVibration(true);
            mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
            notifManager.createNotificationChannel(mChannel);
        }
        builder = new NotificationCompat.Builder(this, id);
        intent = new Intent(this, HomeActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
        builder.setContentTitle(title)                            // required
                .setSmallIcon(android.R.drawable.ic_popup_reminder)   // required
                .setContentText(aMessage) // required
                .setDefaults(Notification.DEFAULT_ALL)
                .setAutoCancel(true)
                .setContentIntent(pendingIntent)
                .setTicker(aMessage)
                .setVibrate(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
    }
    else {
        builder = new NotificationCompat.Builder(this, id);
        intent = new Intent(this, HomeActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
        builder.setContentTitle(title)                            // required
                .setSmallIcon(android.R.drawable.ic_popup_reminder)   // required
                .setContentText(aMessage) // required
                .setDefaults(Notification.DEFAULT_ALL)
                .setAutoCancel(true)
                .setContentIntent(pendingIntent)
                .setTicker(aMessage)
                .setVibrate(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400})
                .setPriority(Notification.PRIORITY_HIGH)
                .setLargeIcon(BitmapFactory.decodeResource
                        (getResources(), R.drawable.logo))
                .setBadgeIconType(R.drawable.logo)
                .setStyle(new NotificationCompat.BigTextStyle().setBigContentTitle(title).bigText(aMessage));
        ;
    }
    Notification notification = builder.build();
    notifManager.notify(NOTIFY_ID, notification);
}

это хорошо работает на многих устройствах, которыеподдерживает Oreo, но не работает в Samsung note 9, если приложение находится на переднем плане и в фоновом режиме какая-либо помощь?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...