FirebasePushNotification plugin iOS - token not refreshing

Stesvis 1,041 Reputation points
2021-01-30T05:15:27.947+00:00

I am using the FirebasePushNotification plugin, and in iOS i have always issues.
In debug mode it works ok, but in release it never fires the OnTokenRefresh event (i know because i set messages boxes and I also print it on the screen).

What could be the cause of this? I am so frustrated, I've tried everything, just not working in Release mode.

Thank you!

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,254 questions
0 comments No comments
{count} votes

Accepted answer
  1. Stesvis 1,041 Reputation points
    2021-02-04T23:35:42.72+00:00

    So I finally got it to work!

    I upgraded the plugin to the latest version, and also installed these in the iOS project manually:

    • Xamarin.Firebase.iOS.CloudMessaging
    • Xamarin.Firebase.iOS.Core
    • Xamarin.Firebase.iOS.InstanceID

    Then, I reuploaded the APNs certificate in Firebase. The Auth APN Key file is recommended, however it only started to work when I chose the other option and uploaded the APN certificate.

    Thanks for the help.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-01-30T06:55:47.157+00:00

    Hello,

    Welcome to Microsoft Q&A!

    It's a known issue and has been reported here : https://github.com/CrossGeeks/FirebasePushNotificationPlugin/issues/361 .

    Workaround : downgrade the plugin to v3.1.6 also downgrade its dependencies .

    Thank you.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Stesvis 1,041 Reputation points
    2021-01-30T22:33:03.82+00:00

    @Cole Xia (Shanghai Wicresoft Co,.Ltd.) I downgraded the plugin and i was able to get the token.
    However, the iOS app does not receive them.

    I sent a notification thru Postman and it completed successfully:

       {  
           "multicast_id": 4267051523857827808,  
           "success": 1,  
           "failure": 0,  
           "canonical_ids": 0,  
           "results": [  
               {  
                   "message_id": "0:1612045674651933%9166abc09166abc0"  
               }  
           ]  
       }  
    

    But the app did not fire the received notification event.
    On the other hand, in the output window I got this log:

    [Firebase/Messaging][I-FCM002019] FIRMessaging received data-message, but FIRMessagingDelegate's-messaging:didReceiveMessage: not implemented

    But i did implement that method as per instructions:

       // To receive notifications in foregroung on iOS 9 and below.  
               // To receive notifications in background in any iOS version  
               public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)  
               {  
                   // If you are receiving a notification message while your app is in the background,  
                   // this callback will not be fired 'till the user taps on the notification launching the application.  
         
                   // If you disable method swizzling, you'll need to call this method.   
                   // This lets FCM track message delivery and analytics, which is performed  
                   // automatically with method swizzling enabled.  
                   FirebasePushNotificationManager.DidReceiveMessage(userInfo);  
                   // Do your magic to handle the notification data  
                   System.Console.WriteLine(userInfo);  
         
                   completionHandler(UIBackgroundFetchResult.NewData);  
               }  
    

    I really do not understand what to do to make this work...