Update app user identifier
You can update the app user identifier you had used to register the app user. In most app flows, this is a method that's rarely called.
For example, suppose that you have registered your app user with an email. The app user would be able to subsequently change their email in app settings and still continue using your service as the same entity.
Calling Shake.updateUserId
on an already registered app user:
- Updates the app user identifier in the Shake database.
- It becomes the new app user identifier.
- You continue to pass this new app user identifier to
Shake.registerUser
on this app user's subsequent logins.
Updating the app user identifier allows various possibilities for how this feature can be used but can also lead to possibly unwanted results. Read the documentation carefully to fully understand possible usages and scenarios.
The code snippet below showcases a common scenario in which the app user identifier is updated. It's assumed that the app user was previously registered with an email:
- Objective-C
- Swift
@implementation UserManager- (void)didChangeEmail:(NSString *)newEmail {__weak typeof (SettingsViewModel) *weakSelf = self;[self.networkService updateUserEmail:newEmail completion:^(User _Nullable user, NSError * _Nullable error) {if (user && error == nil) {weakSelf.currentUser = user;[SHKShake updateUserId:newEmail];}}];}@end
func didChangeEmail(newEmail: String) {self.networkService.updateUserEmail(email: newEmail) { [weak self] user inif user {self?.currentUser = user;Shake.updateUserId(newEmail);return;}}}