Add extra key called "NotificationId" and its value to capture in android main activity
Changes proposed in this pull request:
Add extra key called "NotificationId" and its value to possibility to override the method "OnNewIntent" and check this key and value in MainActivity.
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
// Add the line above
OnNewIntent(Intent);
}
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
if (intent.HasExtra(LocalNotificationsImplementation.LocalNotificationIntentKey))
{
// Do something with the notification Id...
}
}
}
Hi @rdrscan I got this code working thanks to you, but I don't know why when I have more than one notification on the OnNewIntent always get me the last notification Id and not the one I am click in it.
Solved just update public void Show(string title, string body, int id, DateTime notifyTime) this line var pendingIntent = PendingIntent.GetBroadcast(Application.Context, 0, intent, PendingIntentFlags.CancelCurrent);
to this var pendingIntent = PendingIntent.GetBroadcast(Application.Context, id, intent, PendingIntentFlags.CancelCurrent);