Unregistered Registration Token in Firebase

后端 未结 2 1136
走了就别回头了
走了就别回头了 2021-01-04 01:56

I got unregistered registration token even I am sure my token is correct and I check it in my log I am using master token FirebaseInstanceId.Instance.Token.

相关标签:
2条回答
  • 2021-01-04 02:17

    In my case i had used Emulator and the Firewall was blocking it. I used my mobile, enabled the developer options and it got worked.

    Hope this helps.

    0 讨论(0)
  • 2021-01-04 02:34

    The reason why this issue fired cause that token is unregistered

    The registration token may change when:
    
    The app deletes Instance ID
    The app is restored on a new device
    The user uninstalls/reinstall the app
    The user clears app data.
    

    Reference

    and this happen in debug mode only so dont worry in release mode every thing will be fine.

    How you can fix the issue ?

    its easy just force to refresh token call this method in your landing activity (MainActivity , Login ) , this method force firebase to call OnTokenRefresh()

    private void ConfigureFireBase()
            {
    
    #if DEBUG
    
                Task.Run(() =>
                {
                    var instanceId = FirebaseInstanceId.Instance;
                    instanceId.DeleteInstanceId();
                    Android.Util.Log.Debug("TAG", "{0} {1}", instanceId?.Token?.ToString(), instanceId.GetToken(GetString(Resource.String.gcm_defaultSenderId), Firebase.Messaging.FirebaseMessaging.InstanceIdScope));
    
                });
    
                // For debug mode only - will accept the HTTPS certificate of Test/Dev server, as the HTTPS certificate is invalid /not trusted
                ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;
    
    
    #endif
            }
    

    Hope this help any one face same issue

    0 讨论(0)
提交回复
热议问题