String userToken = UserTokenStorageFactory.instance().getStorage().get();
if (userToken == null || userToken.equals(""))
showLoginActivity();
else
{
BackendlessUser user = Backendless.UserService.CurrentUser();
... some code here ...
}
But UserService.CurrentUser() is null even if UserTokenStorageFactory returns not empty token.
How to retreive/update current BackendlessUser without calling UserService.login()?
May be I can automatically relogin by existing token or something like this?
The presence of userToken in UserTokenStorageFactory doesnât mean that the CurrentUser is loaded. But when it is present, it is guaranteed that objectId of the logged in user is also present. So you can load it calling
There does not appear to be an equivalent of Backendless.UserService.loggedInUser() on iOS. How would I replicate this functionality on that platform (get ID of logged in user from prior session)?
I am looking at the implementation of the client-side User Service proxy. It looks like all the information is there, but there is no simple accessor. I will open an internal ticket to add that method.
In iOS you have your persistent user in backendless.userService.currentUser property just after your app have been loaded, and you can simply use it, for example, in viewDidLoad method:
The fix is made.
Now if setStayLogged = YES the property backendless.userService.currentUser saves ALL user properties which they loaded and changed when user logged.
Well, this must be the method I was talking about - the one to set the token automatically after the login. As I said, the developers are not supposed to use it directly, thatâs why itâs not covered in the documentation.