簡體   English   中英

Firebase flutter 推送通知不適用於 android

[英]Firebase flutter push notification not working on android

我已經注冊了我的應用程序,將 google-services.json 文件添加到我的應用程序文件夾中。 我添加了必需的 depndcies 等。當我從 firebase 控制台發送通知時,我仍然做了所有事情,無論我的應用程序是最小化還是前台,我都沒有收到。 我什至沒有在我的調試控制台中看到任何東西。 我的 AVD 也有 google play 服務。

  1. 在 firebase 網站注冊您的應用程序(請注意您的應用程序 id);
  2. 獲取 google-services.json 並將其添加到 'android -> app' 文件夾中;
  3. 更新您的應用程序 ID 並使其與 firebase 中的相同; 您可以通過添加元數據來更新應用程序圖標:
 <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/app_icon" />
  1. 添加依賴:(使用最新版本)
  firebase_core: ^1.4.0
  firebase_messaging: ^10.0.4  
  1. 在 runApp() 之上的 main 方法中添加 await Firebase.initializeApp();
  await Firebase.initializeApp();
  await FirebaseMessaging.instance
        .setForegroundNotificationPresentationOptions(
      alert: true,
      badge: true,
      sound: true,
    );

  await FirebaseMessaging.instance.requestPermission(
      alert: true,
      announcement: false,
      badge: true,
      carPlay: false,
      criticalAlert: false,
      provisional: false,
      sound: true,
    );

試試這個,希望對你有幫助。 不幸的是,我不記得所有細節。

暫無
暫無

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

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