changeLogin
open fun changeLogin(@NonNull activity: Activity, @NonNull forcingMappingTicket: ForcingMappingTicket, @Nullable callback: GamebaseDataCallback<AuthToken>)
Change logged in account with ForcingMappingTicket.
Example Usage:
public void changeLoginFacebook(final Activity activity) {
Gamebase.addMapping(activity, AuthProvider.FACEBOOK, null, new GamebaseDataCallback<AuthToken>() {
@Override
public void onCallback(AuthToken result, GamebaseException exception) {
// Add Mapping Success.
if (Gamebase.isSuccess(exception)) {
...
}
// If you got this error code(AUTH_ADD_MAPPING_ALREADY_MAPPED_TO_OTHER_MEMBER)
// that means this user already has another account of the idP.
// You can call this method, Gamebase.changeLogin(ForcingMappingTicket) which can change the log in account.
if (exception.getCode() == GamebaseError.AUTH_ADD_MAPPING_ALREADY_MAPPED_TO_OTHER_MEMBER) {
// Before calling the change login api,
// You should get this ForcingMappingTicket for this method parameter.
final ForcingMappingTicket ticket = ForcingMappingTicket.from(exception);
// Try to change log in account with the ForcingMappingTicket.
Gamebase.changeLogin(activity, ticket, new GamebaseDataCallback<AuthToken>() {
@Override
public void onCallback(AuthToken data, GamebaseException changeLoginException) {
if (Gamebase.isSuccess(changeLoginException)) {
// Log in account changed successfully.
Log.d(TAG, "Change login successful");
String userId = Gamebase.getUserID();
return;
}
// Change login failed.
// The UserID will not changed.
}
}
} else {
// Add Mapping Failed.
// Check the error code and handle the error appropriately.
}
}
});
}
Content copied to clipboard
Parameters
activity
The activity which is starting the login process.
forcingMappingTicket
The mapping information which is necessary to log in another account.
callback
Resume mapping result callback, returns the authentication token as a result of mapping.