setUser static method

Future<void> setUser(
  1. String userId,
  2. String? mobile,
  3. String? email
)

Implementation

static Future<void> setUser(String userId, String? mobile, String? email) async {
  //throws exception if uninitialized
  _checkIfSDKInitialized();

  //set user id
  await _setUserId(userId);

  if (userId.isEmpty || ((mobile == null || mobile.isEmpty) && (email == null || email.isEmpty))) {
    return;
  }

  //check if cached mobile/email is same as the argument
  User? currentUser = getCurrentUser();
  if (currentUser?.mobile == mobile && currentUser?.email == email) {
    return;
  }

  User user = User(userId: userId, mobile: mobile, email: email);

  await UpdateUserController().start(Prefs.getString(PREF_APP_ID, null)!, user);
}