changeUserId method
Use it when user login or logout, to change the userId that associated to the current device. Another use case could be, verify user token when initialize the application, if the token expired, change the external ID
Implementation
@override
Future<DataResult> changeUserId(String userId, {bool reRegister = false}) async{
final newUserId = userId;
final oldUserId = _userId;
this._userId = userId;
if(!match(newUserId, oldUserId)){
return registerPushDeviceForUser(deviceToken: await getUserID());
}
else{
if(reRegister == true){
return registerPushDeviceForUser(deviceToken: await getUserID());
}
return DataResult(
success: true,
message: "User ID changed with the same value",
code: NUIPushCode.USER_ID_SAME.name
);
}
}