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

      • <bdo id='vI0i4'></bdo><ul id='vI0i4'></ul>

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

    1. <tfoot id='vI0i4'></tfoot>

    2. <legend id='vI0i4'><style id='vI0i4'><dir id='vI0i4'><q id='vI0i4'></q></dir></style></legend>

    3. Flutter 中的 Firebase (FCM) 注册令牌

      时间:2024-08-24
      <tfoot id='G8fj2'></tfoot>
        • <bdo id='G8fj2'></bdo><ul id='G8fj2'></ul>

              <tbody id='G8fj2'></tbody>
          • <small id='G8fj2'></small><noframes id='G8fj2'>

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

                本文介绍了Flutter 中的 Firebase (FCM) 注册令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试将通知从 Java Rest Api(使用 Firebase Admin sdk)发送到我的 Flutter 应用程序 似乎它需要设备令牌来发送通知,我找不到如何获取该令牌.我是 Flutter 和 android 的新手,可能缺少任何关键步骤.如果可以,请你帮助我.谢谢.

                I am trying to send notification from Java Rest Api (using Firebase Admin sdk) to my Flutter application and it seems it requires device token to send notification and I cannot find how to get that token. I am new to Flutter and android and may be missing any of the crucial step. Please help me if you can. Thanks.

                推荐答案

                将这个添加到你的包的 pubspec.yaml 文件中:

                Add this to your package's pubspec.yaml file:

                dependencies:
                  firebase_messaging: ^6.0.16
                

                您可以从命令行安装软件包:

                You can install packages from the command line:

                使用颤振:

                $ flutter packages get
                

                现在在你的 Dart 代码中,你可以使用:

                Now in your Dart code, you can use:

                import 'package:firebase_messaging/firebase_messaging.dart';
                

                实施:

                FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
                
                
                
                @override
                void initState() {
                  super.initState();
                  firebaseCloudMessaging_Listeners();
                }
                
                void firebaseCloudMessaging_Listeners() {
                  if (Platform.isIOS) iOS_Permission();
                
                  _firebaseMessaging.getToken().then((token){
                    print(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");
                  });
                }
                

                有关详细信息,请参阅 这个链接

                For more details step by information please refer this link

                希望对你有帮助

                这篇关于Flutter 中的 Firebase (FCM) 注册令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Spring Data JPA - 是否可以对计算的属性进行排序? 下一篇:通过 FCM onMessageReceived 方法从 RemoteMessage 获取值

                相关文章

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

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

                    <tfoot id='GQ8Vt'></tfoot>
                      <bdo id='GQ8Vt'></bdo><ul id='GQ8Vt'></ul>
                  1. <legend id='GQ8Vt'><style id='GQ8Vt'><dir id='GQ8Vt'><q id='GQ8Vt'></q></dir></style></legend>