Reset the SDK state
This topic describes how to reset the SDK state.
Reset the SDK state
Resetting the SDK state implies the removal of cached data from memory. Access tokens will be removed and the user will be logged out. It won't, however
delete the refresh token nor will it remove any saved data. The SDK will be in the similar state as after application restart.
In case of failure a OneginiResetError
will be returned, to read more about errors and how to handle them please read the Error handling
chapter.
Example code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | public void reset() {
OneginiSDK.getOneginiClient(this).reset(new OneginiResetHandler() {
@Override
public void onSuccess(@NotNull final Set<UserProfile> removedUserProfiles) {
removeUserProfiles(removedUserProfiles);
}
@Override
public void onError(@NotNull final OneginiResetError error) {
@OneginiResetError.ResetErrorType final int errorType = error.getErrorType();
if (errorType == OneginiInitializationError.DEVICE_DEREGISTERED) {
// Reset failed due to missing device credentials. Register app once again.
new DeregistrationUtil(DashboardActivity.this).onDeviceDeregistered();
}
}
private void removeUserProfiles(final Set<UserProfile> removedUserProfiles) {
for (final UserProfile userProfile : removedUserProfiles) {
userStorage.removeUser(userProfile);
}
}
});
}
|