xamarin / GooglePlayServicesComponents

Other
313 stars 145 forks source link

Can't retrieve Firebase Token #869

Closed JimAIT closed 1 month ago

JimAIT commented 1 month ago

Updated for Xamarin to MAUI. I used to get the firebase token via FirebaseInstanceId.Instance.Token That doesn't exist anymore.

It now says to use FirebaseMessaging.Instance.GetToken() When I try it use that, I get the error Default FirebaseApp is not initialized in this process. Make sure to call FirebaseApp.initializeApp(Context) first.

So I added the following first: FirebaseApp.InitializeApp(Android.App.Application.Context); Still get the same error message. I can't find a simple example on how to get this token now like I used to.

jpobst commented 1 month ago

Ultimately, all these packages do is provide generated wrappers that allow you to call Google’s API. We do not have much expertise in how to use those API’s properly.

You will likely need to use the Google's API documentation and relevant forums to determine how to write code for your desired outcome.

JimAIT commented 1 month ago

So in the upgrade to MAUI, it looks like I missed the google-services.json file. After I added that to my MAUI project. I was able to get the token via string FirebaseToken = FirebaseMessaging.Instance.GetToken().Result.ToString();