Open TheFuzix opened 4 years ago
same issue here
I had this same issue. I solved it by manually creating the notification when implementing the CrossFirebasePushNotification.Current.OnNotificationReceived or implementing the PushNotificationHandler. My implementation on OnNotificationReceived was:
CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
{
p.Data.TryGetValue("title", out var title);
p.Data.TryGetValue("body", out var message);
Notification.Builder builder = new Notification.Builder(this, "FirebasePushNotificationChannel");
var intent = new Intent(this, typeof(Activity_Main));
intent.AddFlags(ActivityFlags.ClearTop);
PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0, intent, 0);
builder.SetContentIntent(pendingIntent)
.SetSmallIcon(Resource.Drawable.spreadFactorBlack)
.SetContentTitle((string)title)
.SetContentText((string)message)
.SetAutoCancel(true);
NotificationManager notificationManager = (NotificationManager)GetSystemService(NotificationService);
notificationManager.Notify(PUSH_NOTIFICATION_ID, builder.Build());
};
Same Issue
Same issue
I guess u need to put in the data load the "priority" key with the "high" value. This way, it shows the notification.
Hi,
The plugin is working fine for me except for one thing. I can't seem to show notification messages when the app is running in the foreground. This only happens with data messages and localized notification messages. The only way this seems to work is when using notification messages with a title and body.
For data messages: If I send a data message to my app and the app is forced closed or minimized, the notification is triggered successfully. Also, by using the localize keys the message is translated correctly. But, when the app is running in the foreground no notification is triggered. I solved this by triggering a toast with the messagingcenter, but this isn't ideal.
I also tried triggering a local notification message with a different plugin, and this will solve the issue of not triggering the notification in the foreground, but as a side effect it will trigger two notifications when the app is minimized.
For notification messages: When using a localized notification message with only the title_loc_key and body_loc_key set, the notifications are triggered correctly when the app is forced closed or minimized. But again, it's not triggered when the app is running in the foreground.
In contrast to the data message, I could solve this by using a different local notification plugin and when the app is minimized the notification isn't triggered twice. In the method CrossFirebasePushNotification.Current.OnNotificationReceived(), I check if the object contains a title_loc_key or a body_loc_key and trigger a local notification manually.
What is the best way to trigger a notification for a data message when the app is in the foreground?
Thanks!