Vishwajit Palankar
Vishwajit Palankar

Reputation: 3083

FirebaseInstanceId.Instance is returning null

I want to get fcm token in my xamarin.android project. Nugets I am using

  <package id="Xamarin.Firebase.Common" version="71.1610.0" targetFramework="monoandroid90" />
  <package id="Xamarin.Firebase.Core" version="71.1601.0" targetFramework="monoandroid90" />
  <package id="Xamarin.Firebase.Iid" version="71.1710.0" targetFramework="monoandroid90" />
  <package id="Xamarin.Firebase.Iid.Interop" version="71.1601.0" targetFramework="monoandroid90" />

Code For retrieving the token

FirebaseInstanceId instance = FirebaseInstanceId.Instance;
Android.Gms.Tasks.Task instanceId = instance.GetInstanceId();
instanceId.AddOnSuccessListener(this, this);

But FirebaseInstanceId.Instance is always null

Upvotes: 0

Views: 693

Answers (1)

Woj
Woj

Reputation: 833

You lucky, because just recently I have came across the same issue. I assume you also use Xamarin.Firebase.Auth and all related packages to it. There is an issue with the newest version, for some reason Xamarin.Firebase.Auth and Xamarin.Firebase.Messaging don't like each other. Downgrade both version to 60.1142.1 (you will have to downgrade GoogleService.Base to the lower version, I would personally remove both packages first and re-add them using version 60.1142.1). This fixed my issue with it, which weirdly on my Xamarin on Mac resulted in push notification not working, but on windows version the Instance was null.

Upvotes: 1

Related Questions