Skip to main content

Register user

Register your app users with Shake by calling the Shake.registerUser method.

The passed user identifier argument should ideally reflect the identifier that uniquely represents the user in your database. Often it is the user's email address, but it may be their User ID, or their device's UUID. Shake's public method is intentionally called register and not logIn because user identification context is different in different apps.

Most apps communicate with their backend through the network layer which performs the URL request and asynchronously receives a callback with the request result. That callback's body is a common place where developers call the Shake.registerUser method, but maybe your context is different. Make sure to call this method at the place where it fits your app's flow perfectly.

An example of registering a User with Shake

A common case is to register users from your app's Login screen

main.dart
void logInUser(String email, String password) {
networkService.performLogin(email, password,
(User user) {
Shake.registerUser(user.getId());
handleLogin(user);
},
(String message) {
// Handle failed login
});
}