'I'm not getting the FCM with buttons when app in background...?
I'm not getting the FCM with buttons when app in background, I'm getting FCM in background but without buttons, in foreground it's working.
This is the code I use:
builder = new NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.drawable.app_icon)
.setContentTitle(title)
// .setPriority(NotificationCompat.PRIORITY_MAX)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentText(body)
.setAutoCancel(true)
.setSound(defaultSoundUri)
// .setVibrate(new long[]{500})
.setFullScreenIntent(pendingIntent,true)
.setDefaults(NotificationCompat.DEFAULT_VIBRATE)
.addAction(R.drawable.ic_launcher_foreground, "Accept", pendingIntent)
.addAction(R.drawable.ic_launcher_foreground, "Reject", pendingIntent)
.setContentIntent(pendingIntent);
NotificationManager manager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId,
"Default channel",
NotificationManager.IMPORTANCE_HIGH);
channel.setShowBadge(true);
channel.setLockscreenVisibility(VISIBILITY_PUBLIC);
// channel.setVibrationPattern(new long[]{500});
// channel.enableVibration(true);
manager.createNotificationChannel(channel);
// manager.notify(0,builder.build());
}
manager.notify(0, builder.build());
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|