By passing false to Auth.auth().currentUser?.getIDTokenForcingRefresh, the function does the same thing as getIDToken, except that in case when the current token is expired it will refresh the token. So isn't using getIDTokenForcingRefresh strictly better than using getIDToken? In what situation would anybody use getIDToken instead?
Yes. It's better to use
func getIDTokenForcingRefresh(_ forceRefresh: Bool, completion: AuthTokenCallback? = nil)
But you should be careful about the forceRefresh param. If you set forceRefresh to true then it will refresh the token every time you call the method.
Rather you can also use
func getIDToken(completion: AuthTokenCallback? = nil)
Calling this method will refresh your token if needed, you don't have to take care about the forceRefresh param.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With