• <small id='hFJvW'></small><noframes id='hFJvW'>

  • <legend id='hFJvW'><style id='hFJvW'><dir id='hFJvW'><q id='hFJvW'></q></dir></style></legend>
      <bdo id='hFJvW'></bdo><ul id='hFJvW'></ul>

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

        Firebase 实例 ID:在 21.0.0 中弃用 getId()

        Firebase instance id: deprecation of getId() in 21.0.0(Firebase 实例 ID:在 21.0.0 中弃用 getId())
          <tbody id='Hf9H0'></tbody>
      1. <tfoot id='Hf9H0'></tfoot>

        <legend id='Hf9H0'><style id='Hf9H0'><dir id='Hf9H0'><q id='Hf9H0'></q></dir></style></legend>

            <bdo id='Hf9H0'></bdo><ul id='Hf9H0'></ul>

            • <small id='Hf9H0'></small><noframes id='Hf9H0'>

                <i id='Hf9H0'><tr id='Hf9H0'><dt id='Hf9H0'><q id='Hf9H0'><span id='Hf9H0'><b id='Hf9H0'><form id='Hf9H0'><ins id='Hf9H0'></ins><ul id='Hf9H0'></ul><sub id='Hf9H0'></sub></form><legend id='Hf9H0'></legend><bdo id='Hf9H0'><pre id='Hf9H0'><center id='Hf9H0'></center></pre></bdo></b><th id='Hf9H0'></th></span></q></dt></tr></i><div id='Hf9H0'><tfoot id='Hf9H0'></tfoot><dl id='Hf9H0'><fieldset id='Hf9H0'></fieldset></dl></div>
                  本文介绍了Firebase 实例 ID:在 21.0.0 中弃用 getId()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  随着最近发布的 FirebaseInstanceId 和 FirebaseCloudMessaging (21.0.0) Firebase 已弃用 iid 包以及 getToken()>getId() 方法现已弃用.

                  With the recent release of FirebaseInstanceId and FirebaseCloudMessaging (21.0.0) Firebase has deprecated iid package and both getToken() and getId() methods are now deprecated.

                  根据 Firebase 发行说明 方法 getToken() 移至 FirebaseMessaging

                  之前:

                  FirebaseInstanceId.getInstance().getToken()
                  

                  之后:

                  FirebaseMessaging.getInstance().getToken()
                  

                  使用 fcmToken,但要检索 instance id,FirebaseMessaging 和 FirebaseInstanceId 中没有可用的方法.

                  Which gives use the fcmToken, but to retrieve instance id, there's no method available in FirebaseMessaging nor FirebaseInstanceId.

                  那么instance_id是否被认为是无用的id,不应该再使用了?还是有替代品?

                  So, Is instance_id considered a useless id and should no longer be used? or is there a replacement for this?

                  推荐答案

                  FirebaseInstanceId 类已弃用,获取令牌使用 FirebaseMessagingClass.可以使用以下代码生成令牌:

                  FirebaseInstanceId class is deprecated, to get token use FirebaseMessagingClass. The token can be generated using the following code:

                  FirebaseMessaging.getInstance().getToken()
                  .addOnCompleteListener(new OnCompleteListener<String>() {
                      @Override
                      public void onComplete(@NonNull Task<String> task) {
                        if (!task.isSuccessful()) {
                          Log.w(TAG, "Fetching FCM registration token failed", task.getException());
                          return;
                        }
                  
                        // Get new FCM registration token
                        String token = task.getResult();
                  
                        // Log and toast
                        String msg = getString(R.string.msg_token_fmt, token);
                        Log.d(TAG, msg);
                        Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
                      }
                  });
                  

                  关于Firebase InstanceId,官方文档是这样说的:

                  Regarding the Firebase InstanceId, this is what the official document says:

                  公共任务getInstanceId()->此方法已弃用.对于实例标识符,请改用 FirebaseInstallations.getId().对于 FCM 注册令牌,请改用 FirebaseMessaging.getToken().

                  public Task getInstanceId () -> This method is deprecated. For an instance identifier, use FirebaseInstallations.getId() instead. For an FCM registration token, use FirebaseMessaging.getToken() instead.

                  这篇关于Firebase 实例 ID:在 21.0.0 中弃用 getId()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  When does a FCM token expire?(FCM 令牌何时到期?)
                  Firebase Cloud Messaging (FCM) - Launch Activity when user clicks the notification with extras(Firebase Cloud Messaging (FCM) - 当用户点击带有附加功能的通知时启动活动)
                  Implement Firebase inside of a Library(在库中实现 Firebase)
                  Firebase Backward compatibility with GCM(Firebase 与 GCM 的向后兼容性)
                  Receiving the FCM notifications multiple times on Nougat(在 Nougat 上多次接收 FCM 通知)
                  Push Notifications are delivered but didReceiveRemoteNotification is never called Swift(推送通知已交付,但 didReceiveRemoteNotification 从未被称为 Swift)

                      <bdo id='CaAQu'></bdo><ul id='CaAQu'></ul>
                          <tbody id='CaAQu'></tbody>

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

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