简体   繁体   English

FCM 令牌在一段时间后刷新

[英]FCM token get refreshed after some time

I have developed an iOS App using Xamarin and integrated FCM (Firebase Cloud Messaging) for push notifications.我开发了一个使用 Xamarin 和集成 FCM(Firebase Cloud Messaging)的 iOS 应用程序,用于推送通知。 Its working fine on development phase, but on beta testing through test flight, the FCM token automatically regenerates or refreshes after some time (in between 5-10 minutes).它在开发阶段工作正常,但在通过试飞进行 Beta 测试时,FCM 令牌会在一段时间(5-10 分钟之间)后自动重新生成或刷新。

void TokenRefreshNotification(object sender, NSNotificationEventArgs e)
    {
        // This method will be fired everytime a new token is generated, including the first
        // time. So if you need to retrieve the token as soon as it is available this is where that
        // should be done.
        //var refreshedToken = InstanceId.SharedInstance.Token;
        var token = InstanceId.SharedInstance.Token;
        WriteLog("Token Refresh");
        ConnectToFCM();

        // TODO: If necessary send token to application server.
    }
    public static void ConnectToFCM()
    {
        Messaging.SharedInstance.Connect(error =>
        {
            if (InstanceId.SharedInstance.Token != null)
            {
                var token = InstanceId.SharedInstance.Token;
                //                    FIRInstanceID.instanceID().setAPNSToken(deviceToken, type: FIRInstanceIDAPNSTokenType.Unknown)

                //                    ApnsTokenType = ApnsTokenType.Unknown;
                if (!Settings.DeviceId.Equals(token))
                {
                    Settings.DeviceId = token;
                    Console.WriteLine("Token Updated");
                }
            }

            Console.WriteLine($"Token: {InstanceId.SharedInstance.Token}");
        });
    }

Solved.解决了。 My Observation is from same API 2 different App is installed that's causing the problem.我的观察来自相同的 API 2 安装了导致问题的不同应用程序。 When i uninstalled one App(which is previous one only bundle ID is different) now its working fine.当我卸载一个应用程序(这是前一个唯一的捆绑 ID 不同)时,它现在工作正常。 No token refreshed automatically after few minutes.几分钟后不会自动刷新令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM