Log in with UID

Last Updated on : 2024-11-22 02:19:32download

User ID (UID) login uses an integrated API for both registration and login. Login with UID applies when you already have a user system. The UID is a unique identifier to identify a user in your system.

API description

  • Users who already have an account will be logged in automatically.
  • Users who do not have an account will be registered and logged in automatically.
- (void)loginOrRegisterWithCountryCode:(NSString *)countryCode
                                   uid:(NSString *)uid
                              password:(NSString *)password
                            createHome:(BOOL)createHome
                               success:(nullable ThingSuccessID)success
                               failure:(nullable ThingFailureError)failure;

Parameter description

Parameter Description
countryCode The country code, for example, 86.
uid An anonymous ID, uniquely identifying a user, with no specific format requirements.
password A unique random identifier assigned to each user ID. It is not the user’s actual password.
createHome Specifies whether to create a default home.
success The success callback.
failure The failure callback. An error message is returned to indicate the cause.

Example

Objective-C:

[[ThingSmartUser sharedInstance] loginOrRegisterWithCountryCode:@"your_country_code" uid:@"your_uid" password:@"your_password" createHome:YES success:^(id result) {
        NSLog(@"loginOrRegisterWithCountryCode success: %@", result);
} failure:^(NSError *error) {
        NSLog(@"loginOrRegisterWithCountryCode failure: %@", error);
}];

Swift:

ThingSmartUser.sharedInstance()?.loginOrRegisterWithCountryCode("your_country_code", uid: "your_uid", password: "your_password", createHome: true, success: { (result) in
        print("loginOrRegisterWithCountryCode success: \(result)")
}, failure: { (error) in
        if let e = error {
            print("loginOrRegisterWithCountryCode failure: \(e)")
    }
})