TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
220 stars 49 forks source link

Found a potential bug in FirebaseCloudMessagingImplementation #84

Closed leungkimming closed 2 years ago

leungkimming commented 2 years ago

In HandleShowLocalNotification, PendingIntentFlags shoud include UpdateCurrent apart from Imutable.

    private static void HandleShowLocalNotification(FCMNotification notification)  {
       . . .
       var pendingIntent = AndroidApp.PendingIntent.GetActivity(_context, 0, intent,
            AndroidApp.PendingIntentFlags.Immutable | AndroidApp.PendingIntentFlags.UpdateCurrent);

As in my previous post, without the UpdateCurrent flag, the new Intent's extra will not be updated to the pending Intent and the below code always returns the earliest extra.

    public static FCMNotification GetNotificationFromExtras(this Intent intent, string extraName)  {
        if(intent.HasExtra(extraName)) {
            return = intent.GetBundleExtra(extraName).ToFCMNotification();

References: https://developer.android.com/reference/android/app/PendingIntent.html#FLAG_UPDATE_CURRENT http://pilhuhn.blogspot.com/2010/12/pitfall-in-pendingintent-with-solution.html

Dear owner, if the above is correct, please update the nuget package accordingly!