2022.01.14 14:05:33

    iOS SDK integration

    CocoaPods integration mode

    1.Update Podfile file

     Add the following codes in the Target corresponding to the Podfile of the project
    	pod 'NTESVerifyCode'

    2.Integrate SDK

    Under the current directory of the project, run pod install or pod update

    3.Project setting

    In the project target directory, set Build Settings —> other link flags to -ObjC.
     (1). Execute pod search VerifyCode on the command line. If the version of VerifyCode displayed is not up to date, execute the pod update operation to update the contents of the local repo.
     (2). If you want to use the latest version of the SDK, execute pod update
     (3). If you project has a "Deplyment Target" lower than 8.0,Then add the following statement in front of the Podfile file.Platform :ios, '8.0'

    Manual integration

    1.Download VerifyCode SDK

    Address: https://github.com/yidun/captcha-ios-demo

     **RN Demo:** [React Native Demo](https://nos.netease.com/cloud-website-bucket/6903d3dcb564b09f3971351bf039e848.rar)

    2.Import VerifyCode.framework to XCode project:

     Drag and dropVerifyCode.frameworkfile to Xcode project(please check Copy items if needed option)

    3.Import NTESVerifyCodeResources.bundleto project:

    Go to Build Phase and in the Copy Bundle Resources option, add the NTESVerifyCodeResources.bundle file (check theCopy items if neededoption).

    4.Add dependent library

    `SystemConfiguration.framework` `JavaScriptCore.framework`、`WebKit.framework`

    5.Project setting

    In the project target directory, set Build Settings —> other link flags to -ObjC.


    (1).Ignore if the above system framework already exists
    (2).SDK minimum compatible system version iOS 8.0

    SDK usage

    Object-C project

    1.Introduce the VerifyCode SDK header file in the project that needs to use the SDK, as follows:

    	#import <VerifyCode/NTESVerifyCodeManager.h>

    2.Initialize the SDK where the page is initialized,The SDK supports both Senseless Captcha and normal Captcha. You need to apply for different captchaID on the official website, as follows:

    	- (void)viewDidLoad {
    		[super viewDidLoad];  
    		// Sdk call
    		self.manager = [NTESVerifyCodeManager getInstance];
    		self.manager.delegate = self;
    		// Set transparency
        	self.manager.alpha = 0.7;
        	// Set frame
        	self.manager.frame = CGRectNull;
     		// captchaId applied from Netease,E.g. @"a05f036b70ab447b87cc788af9a60974"
              // Normal captcha,icnclude Silde,Text click,icon click,SMS verification code
              // NSString *captchaid = @"";
              // self.manager.mode = NTESVerifyCodeNormal;
                // Senseless Captcha
            NSString *captchaid = @"";
            self.manager.mode = NTESVerifyCodeBind;

    3.In the place where verification code verification is required, call the SDK's openVerifyCodeView interface as follows:

    	[self.manager openVerifyCodeView:nil];

    4.In the place where verification code verification is required, call the SDK's openVerifyCodeView interface as follows:

           [self.manager closeVerifyCodeView:nil];

    5.If you need to handle the callback information of the VerifyCode SDK, you can implementNTESVerifyCodeManagerDelegate.

    (1) initialization completed

        * Captcha component initialization completed
    	- (void)verifyCodeInitFinish {
    		// App add your own processing logic

    (2) Initialization error

        * Captcha component initialization error
        * @param error error message
        - (void)verifyCodeInitFailed:(NSArray *)error{
          // App add your own processing logic

    (3) Verification result callback

        * Callback after verification is completed
        * @param result Validation results BOOL:YES/NO
        * @param validate Secondary check data, if the verification result is `false`, `validate` returns empty
        * @param message Result message
        - (void)verifyCodeValidateFinish:(BOOL)result 
                                  validate:(NSString *)validate 
                                  message:(NSString *)message{
          // App add your own processing logic

    (4) The callback of turn off the captcha window

    	* The callback of turn off the captcha window
    	- (void)verifyCodeCloseWindow:(NTESVerifyCodeClose)close {
            //App add your own processing logic

    Swift Project

    1.Introduce the header file in the bridging-header.h corresponding to the project, as follows:

    	#import <VerifyCode/NTESVerifyCodeManager.h>

    Remark: Swift calls Objective-C to require a bridge connector file named -Bridging-Header.h. The role of the file is to provide a bridge for Swift to call Objective-C objects.

    2.Other calls are the same as above

    SDK interface


         * @abstract    Set the captcha language type
         typedef NS_ENUM(NSInteger, NTESVerifyCodeLang) {
             // Chinese
             NTESVerifyCodeLangCN = 1,
             // Englishe
             // Traditional chinese
             // Japanese
             // Korean
             // Thai
             // Vietnamese
             // French
             // Russian
             // Arabic
             // German
             // Italian
             // Hebrew
             // Hindi
             // Indonesian
             // Burmese
             // Laotian
             // Malay
             // Polish
             // Portuguese
             // Spanish
             // Turkish
             // Dutch
        * @abstract    Set captcha type
        typedef NS_ENUM(NSInteger, NTESVerifyCodeMode) {
            // Normal Captcha,include slide,Text click,Icon click,SMS verification code
            NTESVerifyCodeNormal = 1,
            // Senseless captcha
        * @abstract    Type of verification code to be disabled
        typedef NS_ENUM(NSInteger, NTESVerifyCodeClose) {
            // Manual override
            NTESVerifyCodeCloseManual = 1,
            // Automatically shut down after verification


        * @abstract    Captcha image display `frame`
        * @Description   The location where the captcha control is displayed may not be passed.
        *              (1)If not passed or passed as` CGRectNull (CGRectZero)`, the default value is used: centered display of `topView`, width is 4/5 of screen width, height: view width / 2.0 + 65
        *              (2)If passed, the width of the frame is at least 270; the height is at least: width / 2.0 + 65.
        @property(nonatomic) CGRect            frame;
        * @abstract    Captcha image background transparency
        * @Description   Range: 0~1, 0 means full transparency, 1 means opaque. Default: 0.8
        @property(nonatomic) CGFloat           alpha;
         * @abstract    Captcha image background color
         * @Description         Default:black
        @property(nonatomic) UIColor           *color;
          * @abstract    Captcha language type
          * @Description   captcha language type NTESVerifyCodeLang, NTESVerifyCodeLangCN means Chinese, NTESVerifyCodeLangEN means English.
          *              Do not pass the default Chinese.
          @property(nonatomic) NTESVerifyCodeLang    lang;
         * @abstract    Set captcha type
         * @Description   Captcha enumeration type NTESVerifyCodeMode, optional type see enumeration definition
         *   Do not pass the default normal captcha.
        @property(nonatomic) NTESVerifyCodeMode mode;
          * @abstract    In extreme cases, when the captcha service is unavailable, whether to enable the downgrade scheme.
          * The default is on. When the downgrade switch is triggered, it will pass the verification directly and proceed to the next step.
         @property(nonatomic) BOOL openFallBack;
         * @abstract    Degradation is triggered when the first fallBackCount error occurs. Value range >=1
         *              The default setting is 3 times. When an error occurs in the third server, the downgrade is triggered and the verification is passed directly.
        @property(nonatomic) NSUInteger fallBackCount;
    	* @abstract    Whether to hide the close button
    	*              The default value is "YES" and "NO"
    	@property(nonatomic) BOOL closeButtonHidden;	
       * @abstract    Click background to see if you can close the captcha view
       *              The value can be disabled by default. If the value is set to YES, the value can be disabled
       @property(nonatomic) BOOL shouldCloseByTouchBackground;	
    	* @abstract   Verification code ipv6 configuration.
    	*             The default value is no. Sending yes indicates that ipv6 networks are supported.
    	@property(nonatomic) BOOL ipv6;

    3.Single case

    	* @abstract 	Single case
    	* @return 		return NTESVerifyCodeManager Object
    	+ (NTESVerifyCodeManager *)getInstance;


         *  @abstract   Configuration parameter
         *  @param      captcha_id      captcha id
         *  @param      timeoutInterval The timeout period for loading the verification code, up to 12s. Try to set this time longer, such as 7 seconds or more (7-12s)
        - (void)configureVerifyCode:(NSString *)captcha_id

    5.Popup captcha

        *  @abstract Show captcha view
        *  @Description      Placement:[[[UIApplication sharedApplication] delegate] window];Full screen centered display, width is 4/5 of the screen width, height: view width / 2.0 + 65.
        - (void)openVerifyCodeView;
        *  @abstract   Show captcha view on specified view
        *  @param      topView         Load the parent view of the captcha control, which can be nil。
        *                              (1)If the value is passed is nil,then use default value:[[[UIApplication sharedApplication] delegate] window]
        *                              (2)If the value is passed is not  nil,note the width and height of the topView, the width is at least 270; the height is at least: width / 2.0 + 65.
        - (void)openVerifyCodeView:(UIView *)topView;

    6.log print

         *  @abstract    Whether to open sdk log printing
         *  @param         enabled         YES:open ;NO:close
         *  @Description The default is NO, only the `workflow` is printed; when set to YES, only the `workflow `and `BGRLogLevelError` will be printed under Release.           
         - (void)enableLog:(BOOL)enabled;

    7.Obtain the SDK version number

    	* @abstract    Obtain the SDK version number
    	- (NSString *)getSDKVersion;

    8.Customize loading copy

     *  @abstract   Customize loading copy
     *  @param      loadingText  Loading copy
    - (void)configLoadingText:(NSString * _Nullable)loadingText;

    9.You can customize loading images in GIF, PNG, and JPG formats

     *  @abstract  You can customize loading images in GIF, PNG, and JPG formats
     *  @Instructions  To customize parameters for loading pictures.
     *            (1) Image format is GIF only need to send gifData, animationImage null.
     *            (2) If the image format is PNG or JPG, animationImage must be configured and gitData must be null.
     *  @param      animationImage  A single image
     *  @param      gifData The image is binary data in GIF format
    - (void)configLoadingImage:(UIImage *_Nullable)animationImage
                   gifData:(NSData *_Nullable)gifData;

    10.Disable the captcha view. This method actively disables the captcha view so that products can invoke the view as required

        *  @abstract   Disable captcha
        - (void)closeVerifyCodeView;

    Error code definition

    The SDK will throw error codes in the callback methods' verifyCodeInitFailed: 'and' verifyCodeNetError: 'as described below:

    Error code instructions
    501 get request failed
    502 loading of the JS resource timed out
    503 Image load timeout
    1004 Initialization failed
    -1005 no network connection

    Effect demonstration


    2.Slide Captcha

    3.Click on the validation

    4.Message authentication

    Online Chat Tel:95163223 Free trial