Xamarin.android Default FirebaseApp is not initialized in this process

前端 未结 3 1805
攒了一身酷
攒了一身酷 2021-01-17 13:43

I face issue with get token from firebase (push notification)

Default FirebaseApp is not initialized in this process com.ready_apps.Nebka.Business. Make sure         


        
相关标签:
3条回答
  • 2021-01-17 14:08

    Just Clean the solution once and run the app again.

    This bug is already reported to Xamarin. https://bugzilla.xamarin.com/show_bug.cgi?id=56108

    This solution is provided in their comment thread, it might get fixed in the newer release of xamarin NuGet package.

    0 讨论(0)
  • 2021-01-17 14:16

    I didnt fix it but I find walkaround this issue in debug mode only

    I called this method onCreate() in activit I need to request the token

    FirebaseInstanceId.Instance?.Token
    

    here is the method

    private void ConfigureFireBase()
            {
    
    #if DEBUG
                try
                {
                Task.Run(() =>
                {
                    var instanceId = FirebaseInstanceId.Instance;
                    instanceId?.DeleteInstanceId();
                    //Log.Debug("TAG", "{0} {1}", instanceId?.Token?.ToString(), instanceId.GetToken(GetString(Resource.String.gcm_defaultSenderId), Firebase.Messaging.FirebaseMessaging.InstanceIdScope));
    
                });
    
                 // For debug mode only - will accept the HTTPS certificate of Test/Dev server, as the HTTPS certificate is invalid /not trusted
                ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;
                }catch (Exception e)
                {
                    Log.Debug("TAG", e.Message);
                }
    #endif
            }
    
    0 讨论(0)
  • 2021-01-17 14:18

    Edit: This bug has been fixed in Xamarin.Firebase version 57.1104.0-beta1.

    This error seems to be present in the newer versions of Firebase for Xamarin. I am also experiencing this error as of today, using the latest stable version 42.1021.1. (The error is also present in the latest beta build).

    I found that a bug report has been filed for the issue here.

    As mentioned in the bug report, deleting both the /obj and /bin folders in your Android project, and/or cleaning the project in Visual Studio should fix the problem temporarily until you update any resource that would change the Resource.Designer.cs file.

    Downgrading to an older version of Firebase and Google Play Services is also possible before a permanent solution is available. I did not experience this error on Firebase and Google Play Services version 32.961.0, for example.

    0 讨论(0)
提交回复
热议问题