Skip to content

Email Address

This section introduces how to use an email address to register and log in an account.

Feature Description

objc
#import <QuecUserKit/QuecUserKit.h>
///Initialization.
[QuecUserService sharedInstance]

Log in with Email Address and Password

API

Log in with email address and password.

objc
 */
- (void)loginByEmail:(NSString *)email 
            password:(NSString *)password
             success:(QuecVoidBlock)success
             failure:(QuecErrorBlock)failure;

Description

ParameterRequiredDescription
emailYEmail address.
passwordYPassword.
successNCallback function of successful request.
failureNCallback function of failed request, and error is is the failure reason.

Example

objc
[[QuecUserService sharedInstance] loginByEmail:@"email" password:@"password" success:^{
    ///Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Register with Email Address and Password

API

Register with email address and password. The verification code should be obtained before registration.

objc
- (void)registerByEmail:(NSString *)email 
                   code:(NSString *)code
               password:(NSString *)password
            nationality:(NSInteger)nationality
                   lang:(NSInteger)lang
               timezone:(NSInteger)timezone
                success:(QuecVoidBlock)success
                failure:(QuecErrorBlock)failure;

Description

ParameterRequiredDescription
emailYEmail address.
codeYVerification code.
passwordYPassword.
nationalityNNationality.
langNLanguage.
timezoneNTime zone.
successNCallback function of successful request.
failureNCallback function of failed request, and error is is the failure reason.

Example

objc
[[QuecUserService sharedInstance] registerByEmail:@""
                                             code:@""
                                         password:@""
                                      nationality:0
                                             lang:0
                                         timezone:0
                                          success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Send Email to Obtain Verification Code

API

Send an email to obtain verification code for account registration, password reset or deregistration.

objc
 - (void)sendEmailWithType:(QuecEmailCodeType)type 
                     email:(NSString *)email
                   success:(QuecVoidBlock)success
                   failure:(QuecErrorBlock)failure;

Description

ParameterRequiredDescription
typeYQuecEmailCodeType.
emailYRecipient's email address.
successNCallback function of successful request.
failureNCallback function of failed request, and error is is the failure reason.
objc
typedef NS_ENUM(NSUInteger, QuecEmailCodeType)
{
    QuecEmailCodeTypeRegister = 1 ,  //Verification code for registration.
    QuecEmailCodeTypeReset = 2,      //Verification code for password reset.
    QuecEmailCodeTypeLogout = 5      //Verification code for deregistration.
};

Example

objc
[[QuecUserService sharedInstance] sendEmailWithType:QuecEmailCodeTypeRegister email:@"email" success:^{
    ///Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Verify Email Verification Code Sent by the User

API

Verify the email verification code sent by the user. The verification code should be obtained before verification.

objc
- (void)validateEmailCodeByUserEmail:(NSString *)email 
                                  code:(NSString *)code
                            isDisabled:(NSInteger)isDisabled
                               success:(QuecVoidBlock)success
                               failure:(QuecErrorBlock)failure;

Description

ParameterRequiredDescription
emailYRecipient's email address.
codeYVerification code.
isDisabledYWhether the verification code is invalid after verification. Default: 1.
1- Invalid
2-Valid
successNCallback function of successful request.
failureNCallback function of failed request, and error is is the failure reason.

Example

objc
[[QuecUserService sharedInstance] validateEmailCodeByUserEmail:@"email" code:@"code" isDisabled:1 success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Reset Password with Email Address and Password

API

Reset the password with email address and password.

objc
- (void)resetPasswordByEmail:(NSString *)email 
                        code:(NSString *)code
           internationalCode:(NSString *)internationalCode
                    password:(NSString *)password
                     success:(QuecVoidBlock)success
                     failure:(QuecErrorBlock)failure;

Description

ParameterRequiredDescription
emailYEmail address.
codeYVerification code.
internationalCodeNCountry code to be used in conjunction with the phone number. Default: +86.
passwordNThe reset password. If not entered, the default value is 12345678.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[[QuecUserService sharedInstance] resetPasswordByEmail:@"email" code:@"code" internationalCode:@"countryCode" password:@"password" success:^{
    /// Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];

Query Whether Email Address is Registerd

API

Query whether the email address is registered.

objc
- (void)checkEmailRegister:(NSString *)email
                   success:(void(^)(BOOL isRegister))success
                   failure:(QuecErrorBlock)failure;

Description

ParameterRequiredDescription
emailYEmail address.
successNCallback function of successful request.
failureNCallback function of failed request.

Example

objc
[[QuecUserService sharedInstance] checkEmailRegister:@"account" success:^(BOOL isRegister) {
    ///Next Action
} failure:^(NSError *error) {
    NSLog(@"check error: %@", error);
}];