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

Messaging.SharedInstance.FetchToken expects the wrong delegate MessagingDeleteFcmTokenCompletionHandler #544

@lbulegato

Description

@lbulegato

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) =>
{

}));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions