簡體   English   中英

如何在 Xamarin 中同時使用 Firebase Cloud Messaging 和 Firebase Auth?

[英]How to use both Firebase Cloud Messaging and Firebase Auth in Xamarin?

我正在開發 Xamarin Android 本機應用程序,當我嘗試同時使用 FCM 和 Firebase 身份驗證時遇到問題。

我首先將 FCM 包添加到我的應用程序(最新版本 v71.1740),我使用 FirebaseMessagingService 和 google-services.json 並且它運行良好,每次新安裝時都會觸發 OnNewToken 方法。

然后我添加了 Firebase-Authentication Nuget 包 (v71.16) 而不修改我的代碼中的任何內容。 我卸載了應用程序並重新啟動,但我從未收到任何推送令牌。

如果我刪除 Auth 包,則會觸發 OnNewToken 方法。

用這兩個模塊初始化 Firebase 有什么關系還是 Xamarin 錯誤? 謝謝

在我的項目中,我意識到 OnNewToken 斷點沒有觸發,但令牌正常更新。 我知道這是因為 LOG 顯示我。 那是我的代碼:

namespace MyApp
{
   [Service]
    [IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
    public class MyFirebaseMessagingService : FirebaseMessagingService
    {
        const string TAG = "Firebase";

        public override void OnNewToken(string token)
        {
            base.OnNewToken(token);

            Log.Debug(TAG, "Update Token: " + token);

            Preferences.Set("TokenFirebase", token);            
        }

        public override void OnMessageReceived(RemoteMessage message)
        {
            
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM