Dinesh Falwadiya
Dinesh Falwadiya

Reputation: 809

App Center Install Id is returning null for push notification?

I am using App Center for Push Notification in xamarin forms.

I have followed all the steps required for App Center as well as Firebase.

But still i am getting null value for install id

var guid = AppCenter.GetInstallIdAsync().Result

Need your help to debug this.

Upvotes: 0

Views: 357

Answers (1)

GiampaoloGabba
GiampaoloGabba

Reputation: 1458

InstallId on Xamarin Android is null if called before the start method of the SDK.

Dont forget to update Appcenter Nuget packages, there was a specific old version with a bug on the GetInstallIdAsync method

Another thing: dont use .Result. Await the method in your Onstart method like this:

    protected override async void OnStart()
    {
        AppCenter.Start("ios=-----;android=----", typeof(Push));
        var guid = await AppCenter.GetInstallIdAsync();
    }

Since OnStart is just an event, and nothing is waiting for it’s return, using async void is acceptable here.

I'm doing this in my apps and it works

Upvotes: 1

Related Questions