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

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

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

        Firebase 云消息传递:FCM 令牌过期

        Firebase Cloud Messaging : Expiration of FCM token(Firebase 云消息传递:FCM 令牌过期)

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

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

        2. <legend id='HUBlp'><style id='HUBlp'><dir id='HUBlp'><q id='HUBlp'></q></dir></style></legend>
            <bdo id='HUBlp'></bdo><ul id='HUBlp'></ul>

                  <tfoot id='HUBlp'></tfoot>
                1. 本文介绍了Firebase 云消息传递:FCM 令牌过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我了解,如果发生以下任一情况,FCM 令牌会自行更新.

                  I understand that the FCM token renews itself if one of the following happens.

                  -应用删除Instance ID
                  - 应用程序在新设备上恢复
                  - 用户卸载/重新安装应用程序
                  - 用户清除应用数据.

                  -The app deletes Instance ID
                  -The app is restored on a new device
                  -The user uninstalls/reinstall the app
                  -The user clears app data.

                  App端可以使用以下方式监控Token更新.

                  The following can be used at the App side to monitor Token renewal.

                  监控令牌生成

                  每当生成新令牌时都会触发 onTokenRefreshcallback,因此在其上下文中调用 getToken 可确保您正在访问一个当前可用的注册令牌.确保您已添加服务到您的清单,然后在上下文中调用 getTokenonTokenRefresh,并记录如下所示的值:

                  The onTokenRefreshcallback fires whenever a new token is generated, so calling getToken in its context ensures that you are accessing a current, available registration token. Make sure you have added the service to your manifest, then call getToken in the context of onTokenRefresh, and log the value as shown:

                  @Override
                  public void onTokenRefresh() {
                      // Get updated InstanceID token.
                      String refreshedToken = FirebaseInstanceId.getInstance().getToken();
                      Log.d(TAG, "Refreshed token: " + refreshedToken);
                  
                      // If you want to send messages to this application instance or
                      // manage this apps subscriptions on the server side, send the
                      // Instance ID token to your app server.
                      sendRegistrationToServer(refreshedToken);
                  }
                  

                  我的问题是,当应用程序终止时,令牌过期并且 FCM 服务器无法知道设备的新令牌是什么(如果存在).因此,当我向此设备发送通知/数据消息时,服务器无法将其发送到设备,因为它不知道将其发送到哪里(因为没有有效的令牌).如何确保在这种情况下我可以通知设备?我不进行客户令牌生成.所以它似乎不时刷新令牌.如何提高我的令牌的有效性?

                  My question is, when the app is terminated, the token expires and there is no way for the FCM server to know what the new token is for the device (if exist). So when I send a notification/data message to this device, the server fails to send it to the device as it doesn't know where to send it to (as there is no valid token). How do I make sure that in such situations I can notify the device ? I dont do a customer token generation. So the it seems to refresh the token now and then. How do I increase the validity of my token ?

                  推荐答案

                  发送消息时需要检查错误,注意错误码,如在文档中列出.如果收到错误 messaging/registration-token-not-registered,则应停止使用令牌.

                  You will need to check for an error when sending the message, and pay attention to the error codes, as listed in the documentation. You should stop using the token if you get the error messaging/registration-token-not-registered.

                  这篇关于Firebase 云消息传递:FCM 令牌过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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)
                    <legend id='ucT1K'><style id='ucT1K'><dir id='ucT1K'><q id='ucT1K'></q></dir></style></legend>

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

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

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

                        <tbody id='ucT1K'></tbody>

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