I'm sending data
payloads through FCM
and handling them in the onMessageReceived()
method of FirebaseMessagingService
. The problem is, when the app is in the background, the push notifications seem to be popping up each time the device handles them. I'd like them to be silent similar to how Android delivers notification
payloads.
How do I make sure the notifications do not create this popup effect? I'm on Android 9.
Here's how the notification is generated on the client:
var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
var notificationBuilder = new NotificationCompat.Builder(this, myChannelId)
.SetContentTitle(title)
.SetContentText(body)
.SetSmallIcon(Resource.Mipmap.ic_launcher)
.SetAutoCancel(true)
.SetContentIntent(pendingIntent);
and this is how it's notified:
if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
notificationBuilder.SetChannelId(myChannelId);
var notificationManager = NotificationManager.FromContext(this);
notificationManager.Notify(myId, notificationBuilder.Build());