signUpOrLoginByMobilePhone static method

Future<LCUser> signUpOrLoginByMobilePhone(
  1. String mobile,
  2. String code
)

Signs up or signs in a LCUser with their mobile number and verification code.

Implementation

static Future<LCUser> signUpOrLoginByMobilePhone(
    String mobile, String code) async {
  if (isNullOrEmpty(mobile)) {
    throw ArgumentError.notNull('mobile');
  }
  if (isNullOrEmpty(code)) {
    throw ArgumentError.notNull('code');
  }
  Map<String, dynamic> response = await LeanCloud._httpClient.post(
      'usersByMobilePhone',
      data: {'mobilePhoneNumber': mobile, 'smsCode': code});
  _LCObjectData objectData = _LCObjectData.decode(response);
  _currentUser = LCUser._fromObjectData(objectData);
  await _saveToLocal();
  return _currentUser!;
}