Flutter IOS FCM推送通知未进入通知栏 [英] Flutter IOS FCM push notification not coming into notification bar

查看:353
本文介绍了Flutter IOS FCM推送通知未进入通知栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Flutter和IOS的新手.我正在为Android和IOS配置FCM推送通知.对于android来说,它的工作正常.我已经通过引用此链接

I am new to Flutter and IOS. I am configuring FCM push notifications for both Android and IOS.For android its working fine.I have done by referring this link https://medium.com/@jun.chenying/flutter-tutorial-part3-push-notification-with-firebase-cloud-messaging-fcm-2fbdd84d3a5e . For IOS, if the app is opened and if I send FCM from Firebase Console at the same time , Flutter on message is called (See the screenshot , logs are there) . But if I close the app , notification is not coming to notification bar but I am receiving in Android App, I don't know where is the problem , Problem with Apple Profiles or Flutter .

IOS内部版本设置和签名与签名;功能

IOS Build Settings and Signing & Capabilities

这是我的代码,

    class FirebaseNotifications {
       FirebaseMessaging _firebaseMessaging;
       SharedPreferences _sharedPreferences;

       void setUpFirebase() {
         _firebaseMessaging = FirebaseMessaging();
         initializeSharedPreferences();
         firebaseCloudMessaging_Listeners();
        }

        void initializeSharedPreferences() async {
        _sharedPreferences = await SharedPreferences.getInstance();
        }

        void firebaseCloudMessaging_Listeners() {
        if (Platform.isIOS) iOS_Permission();
        _firebaseMessaging.getToken().then((token) {
        _sharedPreferences.setString(Preferences.device_token, token);
         print('Token'+token);
         });

         _firebaseMessaging.configure(
          onMessage: (Map<String, dynamic> message) async {
          print('on message $message');
         },
          onResume: (Map<String, dynamic> message) async {
          print('on resume $message');
         },
         onLaunch: (Map<String, dynamic> message) async {
         print('on launch $message');
         },
       );
     }

     void iOS_Permission() {
     _firebaseMessaging.requestNotificationPermissions(
     IosNotificationSettings(sound: true, badge: true, alert: true));
     _firebaseMessaging.onIosSettingsRegistered
     .listen((IosNotificationSettings settings) {
     print("Settings registered: $settings");
    });
   }
  }

推荐答案

在这个问题上您并不孤单-尝试

You are not alone in this problem - try this solution.

还要检查它是否不能同时在应用程序的调试版本和发行版本中使用-应用程序的调试版本可能无法解析通知.

Also, check if it not working both on debug and release builds of the application - there is a possibility of notifications not parsed by the debug variant of app.

这篇关于Flutter IOS FCM推送通知未进入通知栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆