• <tfoot id='6fRss'></tfoot>

    <legend id='6fRss'><style id='6fRss'><dir id='6fRss'><q id='6fRss'></q></dir></style></legend>

      <small id='6fRss'></small><noframes id='6fRss'>

      <i id='6fRss'><tr id='6fRss'><dt id='6fRss'><q id='6fRss'><span id='6fRss'><b id='6fRss'><form id='6fRss'><ins id='6fRss'></ins><ul id='6fRss'></ul><sub id='6fRss'></sub></form><legend id='6fRss'></legend><bdo id='6fRss'><pre id='6fRss'><center id='6fRss'></center></pre></bdo></b><th id='6fRss'></th></span></q></dt></tr></i><div id='6fRss'><tfoot id='6fRss'></tfoot><dl id='6fRss'><fieldset id='6fRss'></fieldset></dl></div>

        • <bdo id='6fRss'></bdo><ul id='6fRss'></ul>
      1. 当应用程序在后台运行时调用 onMessage 方法

        时间:2023-07-30

              <tbody id='jox3h'></tbody>
            <legend id='jox3h'><style id='jox3h'><dir id='jox3h'><q id='jox3h'></q></dir></style></legend>

              <i id='jox3h'><tr id='jox3h'><dt id='jox3h'><q id='jox3h'><span id='jox3h'><b id='jox3h'><form id='jox3h'><ins id='jox3h'></ins><ul id='jox3h'></ul><sub id='jox3h'></sub></form><legend id='jox3h'></legend><bdo id='jox3h'><pre id='jox3h'><center id='jox3h'></center></pre></bdo></b><th id='jox3h'></th></span></q></dt></tr></i><div id='jox3h'><tfoot id='jox3h'></tfoot><dl id='jox3h'><fieldset id='jox3h'></fieldset></dl></div>
              <tfoot id='jox3h'></tfoot>

              <small id='jox3h'></small><noframes id='jox3h'>

                <bdo id='jox3h'></bdo><ul id='jox3h'></ul>
                  本文介绍了当应用程序在后台运行时调用 onMessage 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是颤振和飞镖的新手.我正在尝试将我的应用与 FCM.当应用程序在前台时,我创建了 flutterLocalNotificationsPlugin 并且一切正常,但是当我的应用程序在后台时,我不知道如何处理 onMessage 方法.有人知道我该如何解决吗?

                  I'm new in flutter and dart. I'm trying to connect my app with FCM. When app is in foreground I create flutterLocalNotificationsPlugin and everything works fine, but I don't how to handle onMessage method when my app is in background. Have somebody any idea how I can resolve it?

                  FirebaseMessaging firebaseMessaging = new FirebaseMessaging();
                  FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
                  
                  @override
                  void initState() {
                   super.initState();
                  
                   var androidInitSettings = new AndroidInitializationSettings('mipmap/ic_launcher');
                   var iosInitSettings = new IOSInitializationSettings();
                   var initSettings = new InitializationSettings(androidInitSettings, iosInitSettings);
                   flutterLocalNotificationsPlugin.initialize(initSettings, selectNotification: onSelectNotification);
                  
                   firebaseMessaging.configure(
                     onLaunch: (Map<String, dynamic> msg) {
                       print(" onLaunch called ${(msg)}");
                     },
                     onResume: (Map<String, dynamic> msg) {
                       print(" onResume called ${(msg)}");
                     },
                     onMessage: (Map<String, dynamic> msg) {
                       showNotification(msg);
                       print(" onMessage called ${(msg)}");
                     },
                   );
                   firebaseMessaging.requestNotificationPermissions(const IosNotificationSettings(sound: true, alert: true, badge: true));
                   firebaseMessaging.onIosSettingsRegistered.listen((IosNotificationSettings setting) {
                     print('IOS Setting Registed');
                   });
                   firebaseMessaging.getToken().then((token) {
                     update(token);
                   });
                  }
                  

                  推荐答案

                  根据上一个插件 Firebase Cloud Messaging for Flutter 版本 4.0.0+1,当你在控制台或表单上创建或编译您的推送通知确保包含

                  click_action: FLUTTER_NOTIFICATION_CLICK 
                  

                  定位 Android 设备时作为自定义数据"键值对(在高级选项"下).此选项在您的应用处于后台状态时启用 onResume.

                  as a "Custom data" key-value-pair (under "Advanced options") when targeting an Android device. This option enabling the onResume when your app is in background state.

                  这篇关于当应用程序在后台运行时调用 onMessage 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何从 Android 中的 FCM 数据消息中获取价值? 下一篇:FCM onMessageReceived 未调用 Android

                  相关文章

                1. <legend id='wxSaU'><style id='wxSaU'><dir id='wxSaU'><q id='wxSaU'></q></dir></style></legend>

                  1. <small id='wxSaU'></small><noframes id='wxSaU'>

                  2. <tfoot id='wxSaU'></tfoot>
                      <bdo id='wxSaU'></bdo><ul id='wxSaU'></ul>
                    <i id='wxSaU'><tr id='wxSaU'><dt id='wxSaU'><q id='wxSaU'><span id='wxSaU'><b id='wxSaU'><form id='wxSaU'><ins id='wxSaU'></ins><ul id='wxSaU'></ul><sub id='wxSaU'></sub></form><legend id='wxSaU'></legend><bdo id='wxSaU'><pre id='wxSaU'><center id='wxSaU'></center></pre></bdo></b><th id='wxSaU'></th></span></q></dt></tr></i><div id='wxSaU'><tfoot id='wxSaU'></tfoot><dl id='wxSaU'><fieldset id='wxSaU'></fieldset></dl></div>