Skip to content

Conversation

@rdrscan
Copy link

@rdrscan rdrscan commented Apr 18, 2017

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...
            }
        }
}

…sibility to override the method "OnNewIntent" and check this key and value.
@rdrscan rdrscan mentioned this pull request Apr 18, 2017
@santiagobiart
Copy link

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.

@santiagobiart
Copy link

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants