LCUser

Objective-C

@interface LCUser : LCObject <LCSubclassing>

Swift

class LCUser : LCObject, LCSubclassing

User

Accessing the Current User */

  • Undocumented

    Declaration

    Objective-C

    + (nullable instancetype)currentUser;

    Swift

    class func current() -> Self?
  • Undocumented

    Declaration

    Objective-C

    + (void)changeCurrentUser:(LCUser *_Nullable)newUser save:(BOOL)save;

    Swift

    class func changeCurrentUser(_ newUser: LCUser?, save: Bool)
  • The session token for the LCUser. This is set by the server upon successful authentication.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSString *sessionToken;

    Swift

    var sessionToken: String? { get set }
  • Whether the LCUser was just created from a request. This is only set after a Facebook or Twitter login.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isNew;

    Swift

    var isNew: Bool { get }
  • Undocumented

    Declaration

    Objective-C

    - (void)isAuthenticatedWithSessionToken:(nonnull NSString *)sessionToken
                                   callback:(nonnull LCBooleanResultBlock)callback;

    Swift

    func isAuthenticated(withSessionToken sessionToken: String, callback: @escaping LCBooleanResultBlock)

Creating a New User */

  • Undocumented

    Declaration

    Objective-C

    + (nonnull instancetype)user;
  • Undocumented

    Declaration

    Objective-C

    + (void)enableAutomaticUser;

    Swift

    class func enableAutomaticUser()
  • The username for the LCUser.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSString *username;

    Swift

    var username: String? { get set }
  • The password for the LCUser. This will not be filled in from the server with the password. It is only meant to be set.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSString *password;

    Swift

    var password: String? { get set }
  • Email of the user. If enable “Enable Email Verification” option in the console, when register a user, will send a verification email to the user. Otherwise, only save the email to the server.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSString *email;

    Swift

    var email: String? { get set }
  • Mobile phone number of the user. Can be set when registering. If enable the “Enable Mobile Phone Number Verification” option in the console, when register a user, will send an sms message to the phone. Otherwise, only save the mobile phone number to the server.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSString *mobilePhoneNumber;

    Swift

    var mobilePhoneNumber: String? { get set }
  • Mobile phone number verification flag. Read-only. if calling verifyMobilePhone:withBlock: succeeds, the server will set this value YES.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL mobilePhoneVerified;

    Swift

    var mobilePhoneVerified: Bool { get }
  • 请求重发验证邮件 如果用户邮箱没有得到验证或者用户修改了邮箱, 通过本方法重新发送验证邮件.

    Warning

    为防止滥用,同一个邮件地址,1分钟内只能发1次!

    Declaration

    Objective-C

    + (void)requestEmailVerify:(nonnull NSString *)email
                     withBlock:(nonnull LCBooleanResultBlock)block;

    Swift

    class func requestEmailVerify(_ email: String, with block: @escaping LCBooleanResultBlock)

    Parameters

    email

    邮件地址

    block

    回调结果

  • Undocumented

    Declaration

    Objective-C

    - (nullable NSArray<LCRole *> *)getRoles:(NSError *_Nullable *_Nullable)error;

    Swift

    func getRoles() throws -> [LCRole]
  • Undocumented

    Declaration

    Objective-C

    - (nullable NSArray<LCRole *> *)getRolesAndThrowsWithError:
        (NSError *_Nullable *_Nullable)error;

    Swift

    func getRolesAndThrows() throws -> [LCRole]
  • Undocumented

    Declaration

    Objective-C

    - (void)getRolesInBackgroundWithBlock:
        (nonnull void (^)(NSArray<LCRole *> *_Nullable, NSError *_Nullable))block;

    Swift

    func rolesInBackground() async throws -> [LCRole]
  • Undocumented

    Declaration

    Objective-C

    - (BOOL)signUp:(NSError *_Nullable *_Nullable)error;

    Swift

    func signUp() throws
  • Undocumented

    Declaration

    Objective-C

    - (BOOL)signUpAndThrowsWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func signUpAndThrows() throws
  • Undocumented

    Declaration

    Objective-C

    - (void)signUpInBackgroundWithBlock:(nonnull LCBooleanResultBlock)block;

    Swift

    func signUpInBackground() async throws -> Bool
  • Undocumented

    Declaration

    Objective-C

    - (void)updatePassword:(nonnull NSString *)oldPassword
               newPassword:(nonnull NSString *)newPassword
                     block:(nonnull LCIdResultBlock)block;

    Swift

    func updatePassword(_ oldPassword: String, newPassword: String, block: @escaping LCIdResultBlock)
  • Undocumented

    Declaration

    Objective-C

    - (void)refreshSessionTokenWithBlock:(nonnull LCBooleanResultBlock)block;

    Swift

    func refreshSessionToken() async throws -> Bool
  • Undocumented

    Declaration

    Objective-C

    + (nullable instancetype)logInWithUsername:(nonnull NSString *)username
                                      password:(nonnull NSString *)password
                                         error:(NSError *_Nullable *_Nullable)error;

    Swift

    class func logIn(withUsername username: String, password: String) throws -> Self
  • Undocumented

    Declaration

    Objective-C

    + (void)logInWithUsernameInBackground:(nonnull NSString *)username
                                 password:(nonnull NSString *)password
                                    block:(nonnull LCUserResultBlock)block;

    Swift

    class func logInWithUsername(inBackground username: String, password: String, block: @escaping LCUserResultBlock)
  • Login by email and password.

    Declaration

    Objective-C

    + (void)loginWithEmail:(nonnull NSString *)email
                  password:(nonnull NSString *)password
                     block:(nonnull LCUserResultBlock)block;

    Swift

    class func login(withEmail email: String, password: String, block: @escaping LCUserResultBlock)

    Parameters

    email

    The email string.

    password

    The password string.

    block

    callback.

  • Undocumented

    Declaration

    Objective-C

    + (nullable instancetype)
        logInWithMobilePhoneNumber:(nonnull NSString *)phoneNumber
                          password:(nonnull NSString *)password
                             error:(NSError *_Nullable *_Nullable)error;

    Swift

    class func logIn(withMobilePhoneNumber phoneNumber: String, password: String) throws -> Self
  • Undocumented

    Declaration

    Objective-C

    + (void)logInWithMobilePhoneNumberInBackground:(nonnull NSString *)phoneNumber
                                          password:(nonnull NSString *)password
                                             block:(nonnull LCUserResultBlock)block;

    Swift

    class func logInWithMobilePhoneNumber(inBackground phoneNumber: String, password: String, block: @escaping LCUserResultBlock)
  • Undocumented

    Declaration

    Objective-C

    + (void)requestLoginSmsCode:(nonnull NSString *)phoneNumber
                      withBlock:(nonnull LCBooleanResultBlock)block;

    Swift

    class func requestLoginSmsCode(_ phoneNumber: String, with block: @escaping LCBooleanResultBlock)
  • Request a login code for a phone number.

    Declaration

    Objective-C

    + (void)requestLoginCodeForPhoneNumber:(nonnull NSString *)phoneNumber
                                   options:
                                       (nullable LCUserShortMessageRequestOptions *)
                                           options
                                  callback:(nonnull LCBooleanResultBlock)callback;

    Swift

    class func requestLoginCode(forPhoneNumber phoneNumber: String, options: LCUserShortMessageRequestOptions?, callback: @escaping LCBooleanResultBlock)

    Parameters

    phoneNumber

    The phone number of an user who will login later.

    options

    The short message request options.

    callback

    The callback of request.

  • Undocumented

    Declaration

    Objective-C

    + (nullable instancetype)
        logInWithMobilePhoneNumber:(nonnull NSString *)phoneNumber
                           smsCode:(nonnull NSString *)code
                             error:(NSError *_Nullable *_Nullable)error;

    Swift

    class func logIn(withMobilePhoneNumber phoneNumber: String, smsCode code: String) throws -> Self
  • Undocumented

    Declaration

    Objective-C

    + (void)logInWithMobilePhoneNumberInBackground:(nonnull NSString *)phoneNumber
                                           smsCode:(nonnull NSString *)code
                                             block:(nonnull LCUserResultBlock)block;

    Swift

    class func logInWithMobilePhoneNumber(inBackground phoneNumber: String, smsCode code: String, block: @escaping LCUserResultBlock)
  • Undocumented

    Declaration

    Objective-C

    + (nullable instancetype)
        signUpOrLoginWithMobilePhoneNumber:(nonnull NSString *)phoneNumber
                                   smsCode:(nonnull NSString *)code
                                     error:(NSError *_Nullable *_Nullable)error;

    Swift

    class func signUpOrLogin(withMobilePhoneNumber phoneNumber: String, smsCode code: String) throws -> Self
  • Undocumented

    Declaration

    Objective-C

    + (void)signUpOrLoginWithMobilePhoneNumberInBackground:
                (nonnull NSString *)phoneNumber
                                                   smsCode:(nonnull NSString *)code
                                                     block:
                                                         (nonnull LCUserResultBlock)
                                                             block;

    Swift

    class func signUpOrLoginWithMobilePhoneNumber(inBackground phoneNumber: String, smsCode code: String, block: @escaping LCUserResultBlock)
  • Use mobile phone number & SMS code & password to sign up or login.

    Declaration

    Objective-C

    + (void)
        signUpOrLoginWithMobilePhoneNumberInBackground:
            (nonnull NSString *)phoneNumber
                                               smsCode:(nonnull NSString *)smsCode
                                              password:(nonnull NSString *)password
                                                 block:(nonnull LCUserResultBlock)
                                                           block;

    Swift

    class func signUpOrLoginWithMobilePhoneNumber(inBackground phoneNumber: String, smsCode: String, password: String, block: @escaping LCUserResultBlock)

    Parameters

    phoneNumber

    Phone number.

    smsCode

    SMS code.

    password

    Password.

    block

    Result callback.

  • Clearing local persistent cache data of the current user and set it to nil. It will also clearing local persistent cache of anonymous id.

    Declaration

    Objective-C

    + (void)logOut;

    Swift

    class func logOut()
  • Clearing local persistent cache data of the current user and set it to nil.

    Declaration

    Objective-C

    + (void)logOutWithClearingAnonymousId:(BOOL)clearingAnonymousId;

    Swift

    class func logOut(withClearingAnonymousId clearingAnonymousId: Bool)

    Parameters

    clearingAnonymousId

    true means clearing local persistent cache of anonymous id, false means NOT.

Requesting a Password Reset */

Querying for Users */

  • Undocumented

    Declaration

    Objective-C

    + (nonnull LCQuery *)query;

    Swift

    class func query() -> LCQuery
  • Request a SMS code to verify phone number.

    Declaration

    Objective-C

    + (void)requestMobilePhoneVerify:(nonnull NSString *)phoneNumber
                           withBlock:
                               (nonnull void (^)(BOOL, NSError *_Nullable))block;

    Swift

    class func requestMobilePhoneVerify(_ phoneNumber: String, with block: @escaping (Bool, Error?) -> Void)

    Parameters

    phoneNumber

    The phone number to receive SMS code.

    block

    The result callback.

  • Request a SMS code to verify phone number.

    Declaration

    Objective-C

    + (void)requestVerificationCodeForPhoneNumber:(nonnull NSString *)phoneNumber
                                          options:(LCUserShortMessageRequestOptions
                                                       *_Nullable)options
                                         callback:
                                             (nonnull void (^)(
                                                 BOOL, NSError *_Nullable))callback;

    Swift

    class func requestVerificationCode(forPhoneNumber phoneNumber: String, options: LCUserShortMessageRequestOptions?, callback: @escaping (Bool, Error?) -> Void)

    Parameters

    phoneNumber

    The phone number to receive SMS code.

    options
    callback

    The result callback.

  • Verify a phone number with the SMS code.

    Declaration

    Objective-C

    + (void)verifyCodeForPhoneNumber:(nonnull NSString *)phoneNumber
                                code:(nonnull NSString *)code
                               block:(nonnull void (^)(BOOL,
                                                       NSError *_Nullable))block;

    Swift

    class func verifyCode(forPhoneNumber phoneNumber: String, code: String, block: @escaping (Bool, Error?) -> Void)

    Parameters

    phoneNumber

    The phone number to be verified.

    code

    The verification code.

    block

    The result callback.

  • Request a SMS code to bind or update phone number.

    Declaration

    Objective-C

    + (void)
        requestVerificationCodeForUpdatingPhoneNumber:
            (nonnull NSString *)phoneNumber
                                              options:
                                                  (LCUserShortMessageRequestOptions
                                                       *_Nullable)options
                                                block:(nonnull void (^)(
                                                          BOOL,
                                                          NSError *_Nullable))block;

    Swift

    class func requestVerificationCode(forUpdatingPhoneNumber phoneNumber: String, options: LCUserShortMessageRequestOptions?, block: @escaping (Bool, Error?) -> Void)

    Parameters

    phoneNumber

    The phone number to receive SMS code.

    options
    block

    The result callback.

  • Verify a phone number with the SMS code to bind or update phone number.

    Declaration

    Objective-C

    + (void)verifyCodeToUpdatePhoneNumber:(nonnull NSString *)phoneNumber
                                     code:(nonnull NSString *)code
                                    block:
                                        (nonnull void (^)(BOOL,
                                                          NSError *_Nullable))block;

    Swift

    class func verifyCode(toUpdatePhoneNumber phoneNumber: String, code: String, block: @escaping (Bool, Error?) -> Void)

    Parameters

    phoneNumber

    The phone number to be bound or updated.

    code

    The verification code.

    block

    The result callback.

  • Login use auth data.

    Declaration

    Objective-C

    - (void)loginWithAuthData:(nonnull NSDictionary *)authData
                   platformId:(nonnull NSString *)platformId
                      options:(LCUserAuthDataLoginOption *_Nullable)options
                     callback:(nonnull void (^)(BOOL, NSError *_Nullable))callback;

    Swift

    func login(withAuthData authData: [AnyHashable : Any], platformId: String, options: LCUserAuthDataLoginOption?, callback: @escaping (Bool, Error?) -> Void)

    Parameters

    authData

    Get from third platform, data format e.g. { “id” : “id_string”, “access_token” : “access_token_string”, … … }.

    platformId

    The key for the auth data, to identify auth data.

    options

    See LCUserAuthDataLoginOption.

    callback

    Result callback.

  • Associate auth data to the LCUser instance.

    Declaration

    Objective-C

    - (void)associateWithAuthData:(nonnull NSDictionary *)authData
                       platformId:(nonnull NSString *)platformId
                          options:(LCUserAuthDataLoginOption *_Nullable)options
                         callback:
                             (nonnull void (^)(BOOL, NSError *_Nullable))callback;

    Swift

    func associate(withAuthData authData: [AnyHashable : Any], platformId: String, options: LCUserAuthDataLoginOption?, callback: @escaping (Bool, Error?) -> Void)

    Parameters

    authData

    Get from third platform, data format e.g. { “id” : “id_string”, “access_token” : “access_token_string”, … … }.

    platformId

    The key for the auth data, to identify auth data.

    options

    See LCUserAuthDataLoginOption.

    callback

    Result callback.

  • Disassociate auth data from the LCUser instance.

    Declaration

    Objective-C

    - (void)disassociateWithPlatformId:(nonnull NSString *)platformId
                              callback:(nonnull void (^)(BOOL, NSError *_Nullable))
                                           callback;

    Swift

    func disassociate(withPlatformId platformId: String, callback: @escaping (Bool, Error?) -> Void)

    Parameters

    platformId

    The key for the auth data, to identify auth data.

    callback

    Result callback.

  • Login anonymously.

    Declaration

    Objective-C

    + (void)loginAnonymouslyWithCallback:
        (nonnull void (^)(LCUser *_Nullable, NSError *_Nullable))callback;

    Swift

    class func loginAnonymously(callback: @escaping (LCUser?, Error?) -> Void)

    Parameters

    callback

    Result callback.

  • Check whether the instance of LCUser is anonymous.

    Declaration

    Objective-C

    - (BOOL)isAnonymous;

    Swift

    func isAnonymous() -> Bool

    Return Value

    Result.

  • More restrictive on query conditions to find user. Constraints: NOT support skip; NOT support the protected fields; NOT support inQuery

    Declaration

    Objective-C

    + (void)strictlyFindWithQuery:(nonnull LCQuery *)query
                         callback:(nonnull void (^)(NSArray<LCUser *> *_Nullable,
                                                    NSError *_Nullable))callback;

    Swift

    class func strictlyFind(with query: LCQuery, callback: @escaping ([LCUser]?, Error?) -> Void)

    Parameters

    query

    The query conditions.

    callback

    Result callback.

  • Undocumented

    Declaration

    Objective-C

    + (void)retrieveShortTokenWithCallback:(void (^)(NSString * _Nullable jwt, NSError * _Nullable error))callback;

    Swift

    class func retrieveShortToken(callback: @escaping (String?, Error?) -> Void)

好友关系 */