This repository was archived by the owner on May 1, 2024. It is now read-only.

Description
In Xamarin.Firebase.Messaging version 122.0.0.3 (latest stable)
Messaging.SharedInstance.FetchToken expects the wrong delegate as you can see here
|
void FetchToken (MessagingDeleteFcmTokenCompletionHandler completion); |
it expects the MessagingDeleteFcmTokenCompletionHandler when the right one should be MessagingFcmTokenFetchCompletionHandler
so when you try to use that method, app crashes because of a bad casting in this way
System.InvalidCastException: Specified cast is not valid.
at (wrapper castclass) System.Object.__castclass_with_cache(object,intptr,intptr)
at ObjCRuntime.Runtime.ConstructNSObject[T] (System.IntPtr ptr, System.Type type, ObjCRuntime.Runtime+MissingCtorResolution missingCtorResolution) [0x00046] in <fcda640e026f4864b2a4260e052b2f9c>:0
at ObjCRuntime.Runtime.GetNSObject[T] (System.IntPtr ptr) [0x000d2] in <fcda640e026f4864b2a4260e052b2f9c>:0
at ObjCRuntime.Trampolines+SDMessagingDeleteFcmTokenCompletionHandler.Invoke (System.IntPtr block, System.IntPtr error) [0x00016] in <5e3a5b9193224769818a359723bf4f98>:0
at (wrapper native-to-managed) ObjCRuntime.Trampolines+SDMessagingDeleteFcmTokenCompletionHandler.Invoke(intptr,intptr)
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
You can easily replicate the crash with the following code
Messaging.SharedInstance.FetchToken(new MessagingDeleteFcmTokenCompletionHandler((error) =>
{
}));