7

我面臨的問題與GET令牌從火力(推送通知)Xamarin.android默認FirebaseApp沒有在這個過程中初始化

Default FirebaseApp is not initialized in this process com.ready_apps.Nebka.Business. Make sure to call FirebaseApp.initializeApp(Context) first. 

即使我叫FirebaseApp.InitializeApp(本);在很多地方

所有MyApplication(擴展應用),在活動,我稱之爲FirebaseInstanceId.Instance?.Token;

回答

10

編輯的的onCreate:此bug已被固定在Xamarin.Firebase版本57.1104.0-β1。

這個錯誤似乎出現在新版本的Xamarin Firebase中。截至今日,我也遇到了這個錯誤,使用最新的穩定版本42.1021.1。 (該錯誤也出現在最新的測試版本中)。

我發現已經爲問題here提交了一個錯誤報告。

正如bug報告中提到的,刪除Android項目中的/ obj和/ bin文件夾和/或在Visual Studio中清理項目應暫時解決問題,直到您更新任何可能會更改資源的資源。 Designer.cs文件。

在永久性解決方案可用之前,也可以降級到較早版本的Firebase和Google Play服務。例如,我沒有在Firebase和Google Play服務版本32.961.0上遇到此錯誤。

+0

我最近從GCM升級到FCM,我發誓一切都變得更糟。很煩人! – JMK

+0

我也面臨這個問題,即使我試圖降級谷歌播放服務版本也不起作用 –

3

只需清理一次該解決方案並再次運行應用程序。

此錯誤已報告給Xamarin。 https://bugzilla.xamarin.com/show_bug.cgi?id=56108

該解決方案在其評論主題中提供,它可能會在更新版本的xamarin NuGet包中得到修復。

0

我沒有修復它,但我發現打印機視圖在調試模式下,該問題僅

我叫這種方法的onCreate()在activit我需要請求令牌

FirebaseInstanceId.Instance?.Token 

這裏是方法

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 
     }