0

I follow this tutorial to integrate firebase to my Xamarin project

I face issue in step of adding google-services.json file to .csproj project

after adding this file and restart visual studio , project not responding and keep frizzing

after research I found answer saying file is necessary for Xamarin projects.

so I removed json file and replaced it with my code to initiate firebase

private void ConfigureFireBase()
        {
            var options = new FirebaseOptions.Builder()
            .SetApplicationId(GetString(Resource.String.applicationId))
            .SetApiKey(GetString(Resource.String.applicationId))
            //.SetDatabaseUrl("Firebase-Database-Url")
            .SetGcmSenderId(GetString(Resource.String.applicationId))
            .Build();

            var firebaseApp = FirebaseApp.InitializeApp(this, options);

            Task.Run(() =>
            {
                var instanceId = FirebaseInstanceId.Instance;
                instanceId.DeleteInstanceId();
                //Android.Util.Log.Debug("TAG", "{0} {1}", instanceId.Token, instanceId.GetToken(GetString(Resource.String.applicationId), Firebase.Messaging.FirebaseMessaging.InstanceIdScope));
            });

            }

but till now cant receive token

Community
  • 1
  • 1
Mina Fawzy
  • 20,852
  • 17
  • 133
  • 156
  • Not entirely familiar with Xamarin, but why is `DeleteInstanceId()` being called after it's being initialized? Shouldn't you just be calling `GetToken()`? – AL. Mar 01 '17 at 04:33
  • Could you please follow the [official process](https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote-notifications-with-fcm/)? – Elvis Xia - MSFT Mar 01 '17 at 07:46

0 Answers0