FCM令牌何时到期? [英] When does a FCM token expire?

查看:595
本文介绍了FCM令牌何时到期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

FCM令牌何时到期?是在6个月吗? 如果发生以下任何一种情况,系统会自动更新。


  1. - 应用程序删除实例ID
  2. -
  3. 该应用程序已在新设备上恢复

  4. - 用户卸载/重新安装应用程序

  5. - 用户清除应用程序数据。

    $ b


    监视器令牌生成

    onTokenRefreshcallback在每次生成新的标记时触发,所以
    在其上下文中调用getToken确保您正在访问
    当前可用的注册标记。确保已经将
    服务添加到您的清单中,然后在
    onTokenRefresh的上下文中调用getToken,并如图所示记录值:



      @Override 
    public void onTokenRefresh(){
    //获取更新的InstanceID标记。
    String refreshedToken = FirebaseInstanceId.getInstance()。getToken();
    Log.d(TAG,Refreshed token:+ refreshedToken);

    //如果您想发送消息到这个应用程序实例或
    //在服务器端管理这个应用程序订阅,请将
    // Instance ID令牌发送到您的应用程序服务器。
    sendRegistrationToServer(refreshedToken);
    }


    When do FCM tokens expire? Is it at 6 months?

    解决方案

    it doesn't expire tho. it renews itself if one of the following happens.

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

    Monitor token generation

    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令牌何时到期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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