Googleplayservicescomponents: 15.0.1: FirebaseInstanceId.Instance.GetInstanceId() doesn't return an InstanceIdResult

Created on 24 Sep 2018  路  10Comments  路  Source: xamarin/GooglePlayServicesComponents

Xamarin.Android Version (eg: 6.0):

Xamarin.Android 9.0.0.19

Operating System & Version (eg: Mac OSX 10.11):

Windows 10

Google Play Services Version (eg: 8.4.0):

15.0.1

Describe your Issue:

FirebaseInstanceId.Instance.GetInstanceId() should return a Task The obsolete FirebaseInstanceId.Instance.Token still returns a token though.

Steps to Reproduce (with link to sample solution if possible):

Include any relevant Exception Stack traces, build logs, adb logs:

Most helpful comment

@wcoder You can just do:

GetInstanceId ().AsAsync<IInstanceIdResult> ()

All 10 comments

@jahmai can you please provide a sample project to demostrate the issues that you are having.

Regards

@newky2k I'd rather not have to set up a Google Firebase account to demonstrate the issue (and not going to use my apps official keys). But it's easily observed from the code:

Here is the official docs:

public Task<InstanceIdResult> getInstanceId ()

https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId.html#getInstanceId()

Here is the signature in the binding signature:

    [Register("getInstanceId", "()Lcom/google/android/gms/tasks/Task;", "GetGetInstanceIdHandler")]
    public virtual unsafe Task GetInstanceId()
    {
      return Java.Lang.Object.GetObject<Task>(FirebaseInstanceId._members.InstanceMethods.InvokeVirtualObjectMethod("getInstanceId.()Lcom/google/android/gms/tasks/Task;", (IJavaPeerable) this, (JniArgumentValue*) null).Handle, JniHandleOwnership.TransferLocalRef);
    }

You should just be able to use JavaCast<T>() in this case and it should _just work_....

Will be fixed in a future release. For now, please use JavaCast to the correct type.

Of course, if you want to build from source otherwise you'll have to wait for a new nuget release

I'll just make it an extension method. Cheers.

Do you have updates?
As I can see in the latest Firebase.Messaging v71.1740.0 package provides only Task GetInstanceId()

@wcoder You can just do:

GetInstanceId ().AsAsync<IInstanceIdResult> ()

When I wait on GetInstanceId().AsAsync(), it never returns. What might I be missing?

Was this page helpful?
0 / 5 - 0 ratings