Support Topics Documentation Slack YouTube Blog

Getting error token on some devices


(zeev mindali) #1

i getting on some android devices the error code:
detail: ‘Not existing user token - 57A47111-A7DC-20C3-FF92-869259679500. Relogin user to update your user token’, extendedData: ‘{}’

why??

i have the following code:

List<String> city = new ArrayList<>();
city.add(pushCity);
city.add(“repo”);
Backendless.initApp(this, appID,&#32androidId);
//unregister and do exit
try {
Backendless.Messaging.unregisterDevice();
} catch (Exception e) {
Log.e(“user”, “registerDevice: user not register to channel”);
}

try {
Backendless.UserService.logout();
} catch (Exception e){
Log.e(“login”, “registerDevice: user not logged” );
}

Log.e(“logout”, “registerDevice: finish unregister and logout”);
Log.e(“register”, “registerDevice: start register”);
Backendless.Messaging.registerDevice(city, new AsyncCallback<DeviceRegistrationResult>() {
@Override
public void handleResponse(DeviceRegistrationResult response) {
Backendless.Messaging.getDeviceRegistration(new AsyncCallback<DeviceRegistration>() {
@Override
public void handleResponse(DeviceRegistration response) {
MainActivity.deviceId = response.getDeviceId();
Log.e(“ID”, "deviceID: " + response.getDeviceId());
mobileID = response.getDeviceId();
SmartLocation.with(context).location().stop();
//handle user registreation
BackendlessUser user = new BackendlessUser();
user.setProperty(“name”, response.getDeviceId());
user.setProperty(“cell”, “repoAndroid”);
user.setPassword(“Repo1234!”);
Backendless.UserService.register(user, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser response) {
userLogin();
}

@Override
public void handleFault(BackendlessFault fault) {
Log.e(“userReg”, "user_registerError: " + fault.getCode());
if (fault.getCode().equals(“3033”)) {
userLogin();
}
}
});

}

@Override
public void handleFault(BackendlessFault fault) {
Log.e(“register”, "handleFault zeev: " + fault.getDetail());
}
});

}

@Override
public void handleFault(BackendlessFault fault) {
Log.e(“register”, "handleFault zeev2: " + fault.getMessage());
}
});


(Mark Piller) #2

The error indicates there is a user-token stored on the client side from a previous login. When you use the login API and set the stayLoggedIn argument to true, the user token is stored on the client and is sent to the server with every API call. In your case that API call happens to be unregisterDevice. Try to do the logout before any other call to clear the user token.

Regards,
Mark


(zeev mindali) #3

hi mark,

i do logout in blocking method before i do the login


(zeev mindali) #4

that is what i do for logout


(Mark Piller) #5

Yeah, do the logout as the very first call after initApp. The code you posted earlier shows that you do unregisterDevice as the very first call.


(zeev mindali) #6

done that, not helped.

moved to async call for logout, fixed the problem.

don’t use blocking method, don’t use blocking method!!!


(Mark Piller) #7

Blocking methods on the main UI thread in Android are not allowed