1. Take a look at the one-click login effect picture:
Mob official documentation: www.mob.com/mobService/…
2. Second advantage
- Enhance operation value simple operation, help to register and log in/pull new retention
- Improve user experience One-click authentication to optimize user experience
- Flexible configuration You can freely determine product flows and configuration items
- Reduce client churn rate and improve user registration conversion rate
3. Check compliance
1. Make sure your APP has a Privacy Policy
You need to make sure your App has a Privacy Policy. In order to ensure that you can meet the relevant compliance requirements of the Ministry of Industry and Information Technology after integrating MobSDK, you should ensure that the Privacy Policy will pop up at the first cold startup of the App after installation and obtain the user’s consent.
######2. Add the Mob privacy protocol
You must inform the user that you choose MobSDK. Please add the following reference terms in the Privacy Policy: “We use a third party (Shanghai Youkun Information Technology Co., LTD., hereinafter referred to as” MobTech “) MobTech SecVerifySDK to provide you with one-click login function. In order to implement this function, you need to license the MobTechSDK to provide the corresponding service; MobTech will collect your personal information after you authorize it. For details about the types and purposes of information MobTech collects, as well as the rules and exit mechanism for personal information protection, please refer to the Privacy Policy (www.mob.com/about/polic…) on MobTech’s official website (www.mob.com). Terms and conditions.”
######3. Send back the privacy protocol authorization result
The user to read your “privacy policy” and obtain the user authorization, submit privacy agreement function called uploadPrivacyPermissionStatus submit privacy agreement. On the other hand, if the user does not agree to the privacy policy authorization, cannot call uploadPrivacyPermissionStatus submit privacy agreement.
#import <MOBFoundation/MobSDK+Privacy.h> [MobSDK uploadPrivacyPermissionStatus:YES onResult:^(BOOL success) { // Note that the business logic does not depend on the success result. It is recommended that the business logic write after calling the interface}];Copy the code
4. Configuration MobSDK
You need to add the MOBNetLater parameter configuration to the default plist file of the project. Set the parameter value to 2
The configuration is shown as follows:
3. Project integration
1. Add the application on Mob and obtain the corresponding AppKey and AppSecret, add the second test module and apply for second test audit.
The data recorded after passing the second inspection is shown as follows:
2. Second test flow chart
3. Project integration
- 1. Download the SDK from the official website, and then drag the SDK folder as shown in the following figure into the project (if the second testing SDK has been integrated in the project, please delete the existing SDK and import the SDK downloaded from the official website).
- 2. Add a dependency library
Necessary to addlibc++.tbd
- 3. Configure the Xcode option
Build Settings
In theOther Linker Flags
add-ObjC
.
- 4. Configure the Xcode info.plist file
(1) AddMOBAppKey
.MOBAppSecret
.App Transport Security Settings
.MOBNetLater
(2) Currently, some carriers’ interfaces are HTTP requests. If HTTP is globally disabled, you need to set the HTTP whitelist. You are advised to configure info.plist as follows:
Copy it directly to the info.plist file source code
<key>NSExceptionDomains</key> <dict> <key>cmpassport.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> <key>id6.me</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> <key>mdn.open.wo.cn</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> <key>wostore.cn</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> <key>zzx9.cn</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict>Copy the code
(3) AddmobForbidden
. If the number obtaining process fails, current error information will be collected by default and uploaded to help developers locate error information accurately. If you do not want to upload error information, set mobForbidden(default: NO) to YES in plist
# # # 4. The core code # # # # # # 1. The back user privacy authorization result (uploadPrivacyPermissionStatus)
/ * * upload privacy agreement authorized state @ param isAgree agree (result) after the user authorization * / + (void) uploadPrivacyPermissionStatus: (BOOL) isAgree onResult (void (^_Nullable)(BOOL success))handler;Copy the code
######2. Description of the preLogin interface
- This method is used to obtain the carrier number obtaining certificate in advance. When the pre-login succeeds, invoking the pull up authorization page method immediately pulls up the authorization page.
- It is recommended that you invoke this method before authorized login so that you can know in advance whether the current user’s mobile phone network meets the requirements for one-click login. After successful login, you will get a temporary certificate for one-click login. The validity period of the certificate is 60 seconds (telecom), 30 minutes (Unicom), or 60 minutes (mobile).
Code sample
/* * Pre-login * * This call will help improve the speed and success rate of pulling up the authorization page * Frequent multiple calls and after pulling up the authorization page are not recommended * The pre-login method callback is dispatch_get_global_queue(0, 0), not the main thread, * It is recommended to call this method before one-click login, such as in the viewDidLoad of one-click login VC * if (error == nil) as the basis for determining success, Instead of the return code */ + (void)preLogin:(nullable SecVerifyResultHander)handler;Copy the code
#import <SecVerify/SVSDKHyVerify.h> [SVSDKHyVerify preLogin:^(NSDictionary * _Nullable resultDic, NSError * _Nullable error) {if (error == nil && resultDic! = nil && [resultDic isKindOfClass: NSDictionary class]) {/ / success} else {/ / failure}}];Copy the code
Success Return Example
resultDic:
{
operator = CUCC;
}
Copy the code
Parameters that
ResultDic: {" operatorName ":" China Mobile "} // May return China Mobile, China Unicom, or China Telecom error: Error is nil, that is, the prefetch number is successful.Copy the code
######3. Pull up the Authorization page + One-click Login (openAuthPageWithModel) interface description
- If the prefetch number succeeds, the SDK directly pulls up the authorization page. Otherwise, prefetch the number from the SDK and pull up the authorization page.
uiConfigure
: Authorization page with SVSDKHyUIConfigure,uiConfigure.currentViewController
Will pass- To modify the style of the controls that come with the authorization page and add custom controls, set them yourself in the proxy method
- The authorization page will be displayed in system mode. Due to the present mechanism of the system, if currentViewController is not the uppermost VC, present will be invalid and there is no completion callback. Please try to use currentViewController to test present VC to see if it can be displayed normally.
openAuthPageListener
: Pulls up the authorization page callback and invokes the queue main_queue. If the callback succeeds or fails, there will be callback. If error is nil, it means success.- CancelAuthPageListener: After pulling up the authorization page, the SDK will call back the back/close button and call back the queue main_queue. Click the built-in cancel and return buttons, the SDK will automatically close the authorization page, cancel and return operations, and the SDK will regard them as failure. ResultDic =nil,error! = nil.
oneKeyLoginListener
: One-click login click fetch token callback, callback queue global_queue, does not contain checkBox unchecked events
@param cancelAuthPageListener cancelAuthPageListener cancelAuthPageListener cancelAuthPageListener Cancel login/return/log in in other ways @param oneKeyLoginListener one-click login button to obtain token */ + (void)openAuthPageWithModel:(nonnull SVSDKHyUIConfigure *)model openAuthPageListener:(SecVerifyResultHander)openAuthPageListener cancelAuthPageListener:(SecVerifyResultHander)cancelAuthPageListener oneKeyLoginListener:(SecVerifyResultHander)oneKeyLoginListenerCopy the code
Invoke the sample
-(void)openAuthPageButtonClick:(UIButton *)button{** * * dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ * [button setEnabled:YES]; *}); */ /1. Create a UI configuration object SVSDKHyUIConfigure * uiConfigure = [[SVSDKHyUIConfigure alloc]init]; //2. Set currentViewController. Please pass into the current vc or view the top vc, vc can use this callback system present can test whether the present other vc uiConfigure. CurrentViewController = self; / / 3. Optional. Set some custom properties. Eg. The developer's manual control closed uiConfigure authorization page. ManualDismiss = @ (YES); /** * 4. Optional. [SVSDKHyVerify setDelegate:self]; * Proxy examples: Receive the ViewDidLoad event through the proxy, And to set the control constraints or add custom controls * - (void) svVerifyAuthPageViewDidLoad authVC: (UIViewController *) UserInfo :(SVSDKHyProtocolUserInfo*)userInfo{* - basic control objects and related information in userInfo * - you can set the basic control style and layout, add custom controls, etc. *} */ /5. Call the pull up authorization page method, The incoming uiConfigure [SVSDKHyVerify openAuthPageWithModel: uiConfigure openAuthPageListener: ^ (NSDictionary * _Nullable ResultDic, NSError * _Nullable error) {/** * * dispatch_async(dispatch_get_main_queue(), ^{ * [button setEnabled:YES]; * }); */ if (error ! }} cancelAuthPageListener:^(NSDictionary * _Nullable resultDic, NSError * _Nullable error) {oneKeyLoginListener:^(NSDictionary *) {oneKeyLoginListener:^(NSDictionary * _Nullable resultDic, NSError * _Nullable error) { / / close the page. When uiConfigure manualDismiss = @ (YES) need to manually close this method is called. [SVSDKHyVerify finishLoginVcAnimated:YES Completion:^{ NSLog(@"%s",__func__); }]; __strong typeof(weakSelf) strongSelf = weakSelf; / if/whether to obtain token success (error = = nil) {/ * * * * access token success began to invoke the token replacement phone interface * [Tools getMobileByToken: resultDic Completion: ^ () {}]... * /} else {failed to get token / * * * * * can be customised to jump to other page [self gotoSMSLogin]; * /}}]; }Copy the code
Success Return Example
resultDic: { opToken = 7b19d948f1e9f18bb20dc66b4c08d68c953005d6c04841319918273113288705; operator = CUCC; token = "0:AAAAhQAAAIEAD261gzCYXMWXTL8rrAlRf9120a4LLQJHUw6LbV6S74dLCHHczDt54iTE3UziKY6MdKO9LONwgAseaPB+5HrPQZOsJXBvgIDSH5wtF6IiE bVmvwlzyRajVJY3KvAXSDSybH1Mch8XuuBG3zHXxpYs0IltgXAoOsc9/oB4aakwmPUAAACgbzY1oX1Ir9+DyU4R5PdpeWdQw+0IHYcfdKvpVXnXOXZ5ak0nq PNuR1FqCh1RMrPmHXu4K6IwYGOYnXFRtABIE7I7h7EU+2imu4vY9pY3z2OYjHvMFkrHLHCoeh0srZvhMPJscPP6Ue3NPV38sd/4hPH1bp4cH4IjFPpPB5AwW FkIn2N7U8fBX02SbPAxy4ejqCvr9yoxJq2c0dONsn/22Q=="; }Copy the code
Response Parameter Description
- Error: If error is nil, the login succeeds.
- ResultDic indicates the dictionary type, which is returned if the login is successful
######4. Obtain the mobile phone number
- The SDK only returns the token, and the real phone number is obtained through the token call interface. We need to pass the token to our company server to get the phone number
######5.SDK auxiliary methods
- . Close the login page manually:
/** * This method is applicable to scenarios where the login page needs to be closed manually (for example: Model manualDismiss=YES, custom view button events, etc.) */ + (void)finishLoginVcAnimated: BOOL)flag Completion:(void(^_Nullable)(void))completion;Copy the code
- Manually disable the one-click login loading provided by the authorization page:
+ (void)hideLoading;
Copy the code
- Manually set the current authorization page checkBox check status:
+ (void)setCheckBoxValue:(BOOL)isSelect;
Copy the code
- Check whether authentication can be initiated in the current network environment (the result is for reference only) :
/** * YES YES, NO NO */ + (BOOL)isVerifyEnable;Copy the code
- Get the current data card operator (results are for reference only) :
/** * CMCC: mobile CUCC: mobile CTCC: mobile UNKNOW: unknown */ (NSString *_Nullable)getCurrentOperatorType;Copy the code
- Clear the SDK internal prefetch number cache:
+ (void)clearPhoneScripCache;
Copy the code
- Enable debug mode:
/** * YES more debug logs will be printed */ + (void)setDebug:(BOOL)enable;Copy the code
- Current SDK version
+ (nonnull NSString *)sdkVersion;
Copy the code
###5. Precautions
-
- The passage-free login function is successful only when the mobile phone is enabled on the cellular network. Telecom support 4G,5G network number, mobile, Unicom support 5G,4G, 3G, 2G network number but in the case of non-5G,4G network easy to get number failure, for double card double waiting mobile phone only take the current flow card number.
-
- You can log in only after the prefetch number is successfully obtained.
-
- The login method must be passed to the Model, and the current controller must be passed to the Model.
-
- After the login succeeds, the user uses the returned two tokens and the carrier type to request information such as the mobile phone number from the server.
- Starting with V3.0.2, the standard version uses the SVSDKHyVerify class as the SDK main class. Associated header files are:
- 1. Authorization page configuration class —
SVSDKHyUIConfigure
- 2. Callback information fetch class —
SVSDKHyProtocolUserInfo
- 3. Authorization page VC class —
SVSDKVerifyOperationViewController
- 4. Authorize page nav class —
SVSDKVerifyOperationNavigationController
- 5. Authorization page Protocol page class —
SVSDKWebCarouselViewController
- License page Protocol page NAV class (used when protocol page present)–
SVSDKWebCarouselNavigationController
- 7. If the access code used string class name matching before, as shown in
SVOperationViewController, SVBaseWebViewVC, ZUOAuthViewController, UAAuthViewController, UANavigationController, EAccountAuth EnticateViewController, EAccountOPSWebViewController
Is recommended to remove the relevant code.
- 1. Authorization page configuration class —
###6. Customize the UI
- One click login page support custom UI, directly see Mob official explanation:
www.mob.com/wiki/detail…
Error code return format: external code; UserInfo {” error_code “: internal code,” error_message “: error description,” description “: local error description}
Go directly to Mob’s official list of error codes: www.mob.com/wiki/detail…