I am receiving push notifications but when I click it its not going inside the app .
My Firebase class
public override void OnMessageReceived(RemoteMessage message)
{
try
{
var body = message.GetNotification().Body;
SendNotification(body, message.Data);
Preferences.Set("NotificationIconUpdate", true);
Intent intent = new Intent();
intent.SetAction("");
intent.PutExtra("", "");
SendBroadcast(intent);
}
catch (Exception ex)
{
global.ShowToast(ex);
}
}
void SendNotification(string messageBody, IDictionary<string, string> data)
{
try
{ GetString(Resource.String.pushNotification));
intent.AddFlags(ActivityFlags.NewTask);
intent.AddFlags(ActivityFlags.SingleTop);
foreach (var key in data.Keys)
{
string value = data[key];
intent.PutExtra(key, value);
}
var flag = Build.VERSION.SdkInt >= BuildVersionCodes.O
? PendingIntentFlags.UpdateCurrent | PendingIntentFlags.Immutable
: PendingIntentFlags.UpdateCurrent;
var pendingIntent = PendingIntent.GetActivity(this, SplashActivity.NOTIFICATION_ID, intent, flag);
var notificationBuilder = new NotificationCompat.Builder(this, SplashActivity.CHANNEL_ID)
.SetContentTitle(Constants.eGoldFax)
.SetContentText(messageBody)
.SetAutoCancel(true)
.SetContentIntent(pendingIntent)
.SetSmallIcon(Resource.Drawable.ic_notification)
.SetPriority(NotificationCompat.PriorityDefault) // Set the correct priority here
.SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)) // Specify the sound URI
.SetColor(ContextCompat.GetColor(Application.Context, Android.Resource.Color.Transparent));
var notificationManager = NotificationManagerCompat.From(this);
notificationManager.Notify(SplashActivity.NOTIFICATION_ID, notificationBuilder.Build());
StartForeground(SplashActivity.NOTIFICATION_ID, notificationBuilder.Build());
}
catch (Exception ex)
{
global.ShowToast(ex);
}
}
My create channel in main Launcher Page
if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
{
var channel = new NotificationChannel(CHANNEL_ID, "FCM Notifications", NotificationImportance.Default)
{
Description = "Firebase Cloud Messages appear in this channel",
Importance = NotificationImportance.Max
};
var notificationManager = (NotificationManager)GetSystemService(Android.Content.Context.NotificationService);
notificationManager.CreateNotificationChannel(channel);
}
When I click the notification its not going inside the app in Android API 33.
When I click the push notification I need it to navigate to the app but the notification vanishes and not taking me inside the app.