This topic explains how to integrate the iOS client for local phone number verification and provides SDK API examples.
Download the SDK
Log on to the Phone Number Verification Service console. On the Overview page, find the API & SDK section on the right and click Download Now. Follow the on-screen instructions to download the required SDK.
Create an authentication solution
For more information, see Create an authentication solution and obtain the solution code.
Integration methods
You can integrate the SDK using either a dynamic library or a static library. You cannot integrate both ATAuthSDK_D.framework (the dynamic library) and ATAuthSDK.framework (the static library) into the same project.
If you integrate the static library, you must integrate the following components:
ATAuthSDK.framework, YTXMonitor.framework, and YTXOperators.framework.
If you integrate the dynamic library, you must integrate the following component:
ATAuthSDK_D.framework.
Integrate the static library
Create a project.
Download and install Xcode. Click Create a new Xcode project and follow the on-screen instructions to create a new project.
Add the primary and system libraries.
Method 1: In the menu bar, choose Targets > Build Phases > Link Binary With Libraries. Add the primary libraries ATAuthSDK.framework, YTXMonitor.framework, and YTXOperators.framework. Then, add the system library Network.framework.

Method 2: In Xcode, go to Targets > General > Frameworks, Libraries, and Embedded Content. Add the primary libraries ATAuthSDK.framework, YTXMonitor.framework, and YTXOperators.framework. Then, add the system library Network.framework.
NoteWhen you add the primary libraries, set Embed to Do Not Embed.

Network.framework is supported on iOS 12.0 and later. In the menu bar, choose Targets > Build Phases > Linked Frameworks and Libraries > Status. Set Status to a weak dependency.
Configure Build Settings.
In the menu bar, choose Targets > Build Settings > Other Linker Flags.
Add
-ObjC,-framework, and"YTXOperators"to Other Linker Flags.
Add the ATAuthSDK.bundle resource file.
Right-click the main project and add the ATAuthSDK.framework > ATAuthSDK.bundle resource files. Otherwise, the default images or icons on the one-click logon authorization page will not be displayed.
Alternatively, go to Targets > Build Phases > Copy Bundle Resources and add ATAuthSDK.bundle.

Integrate the dynamic library
The dynamic library may not include the emulator architecture. You can use the
lipo -infocommand to check for supported architectures. If the build fails because an unsupported architecture is included, use thelipo -thincommand to remove the unsupported architecture from the executable file.Do not drag the decompressed dynamic library files directly into the project. The decompressed files contain the ATAuthSDK_D.framework.dSYM symbol file, which is used for symbolicating crash logs. Including this file in your project causes issues during the App Store review. Drag only the ATAuthSDK_D.framework into the project.
Add the primary library.
Method 1: In Xcode, go to Targets > General > Frameworks, Libraries, and Embedded Content and add the primary library ATAuthSDK_D.framework.
NoteWhen you add the primary library, set Embed to Embed & Sign.

Method 2:
Go to Targets > Build Phases > Link Binary With Libraries and Embed Frameworks. Add the primary library ATAuthSDK_D.framework.

Add the ATAuthSDK.bundle resource file.
Right-click the main project and add the ATAuthSDK.framework > ATAuthSDK.bundle resource file. Otherwise, the default images or icons on the one-click logon authorization page will not be displayed.
Alternatively, go to Targets > Build Phases > Copy Bundle Resources and add ATAuthSDK.bundle.

Interaction flow
For the complete interaction flow, see Local phone number verification interaction flow.
SDK API reference
Get the singleton instance (sharedInstance)
/**
* Gets the singleton instance of this class.
* @return The singleton instance.
*/
+ (instancetype _Nonnull )sharedInstance;Example
TXCommonHandler *handller = [TXCommonHandler sharedInstance];Set the SDK secret key (setAuthSDKInfo)
/**
* Initializes the SDK. Call this method once during the app's lifecycle.
* @param info The secret key for your app.
* @param complete An asynchronous callback that runs on the main thread. On success, the result dictionary is @{resultCode:600000, msg:...}. For other status codes, see PNSReturnCode.
*/
- (void)setAuthSDKInfo:(NSString * _Nonnull)info complete:(void(^_Nullable)(NSDictionary * _Nonnull resultDic))complete;Example
[[TXCommonHandler sharedInstance] setAuthSDKInfo:@"xxxx"
complete:^(NSDictionary * _Nonnull resultDic) {
NSLog(@"Result of setting secret key: %@", resultDic);
}];Accelerate token retrieval (accelerateVerifyWithTimeout)
/**
* Pre-fetches carrier network settings to accelerate the getVerifyTokenWithTimeout:complete: call and help prevent timeouts.
* @param timeout The timeout interval in seconds. The default is 3.0s.
* @param complete An asynchronous callback that runs on the main thread. On success, the result dictionary is @{resultCode:600000, token:..., msg:...}. For other status codes, see PNSReturnCode.
*/
- (void)accelerateVerifyWithTimeout:(NSTimeInterval)timeout complete:(void (^_Nullable)(NSDictionary * _Nonnull resultDic))complete;Example
[[TXCommonHandler sharedInstance] accelerateVerifyWithTimeout:3.0
complete:^(NSDictionary * _Nonnull resultDic) {
NSLog(@"Acceleration result for getting the verification token: %@", resultDic);
}];Get the verification token (getVerifyTokenWithTimeout)
/**
* Gets the token for local phone number verification.
* @param timeout The timeout interval in seconds. The default is 3.0s.
* @param complete An asynchronous callback that runs on the main thread. On success, the result dictionary is @{resultCode:600000, token:..., msg:...}. For other status codes, see PNSReturnCode.
*/
- (void)getVerifyTokenWithTimeout:(NSTimeInterval)timeout complete:(void (^_Nullable)(NSDictionary * _Nonnull resultDic))complete;Example
[[TXCommonHandler sharedInstance] getVerifyTokenWithTimeout:3.0
complete:^(NSDictionary * _Nonnull resultDic) {
NSLog(@"Result of getting verification token: %@", resultDic);
}];Other API descriptions
Optional method: Get the version number
/**
* Gets the current SDK version number.
* @return A string that indicates the SDK version number.
*/
- (NSString *_Nonnull)getVersion;Example
NSString *version = [[TXCommonHandler sharedInstance] getVersion];Optional method: Check the environment
/**
* Checks whether the current environment supports one-click logon or phone number verification. If PNSCodeSuccess is returned in resultDic, the environment is supported.
* @param authType The service type. PNSAuthTypeVerifyToken specifies the phone number verification flow. PNSAuthTypeLoginToken specifies the one-click logon flow.
* @param complete The result is returned asynchronously to the main thread. On success, resultDic=@{resultCode:600000, msg:...}. For other cases, see PNSReturnCode for the "resultCode" value. Subsequent API calls are guaranteed only after a success callback.
*/
- (void)checkEnvAvailableWithAuthType:(PNSAuthType)authType complete:(void (^_Nullable)(NSDictionary * _Nullable resultDic))complete;Example
[[TXCommonHandler sharedInstance] checkEnvAvailableWithAuthType:PNSAuthTypeVerifyToken complete:^(NSDictionary * _Nullable resultDic) {
NSLog(@"Environment check result: %@",resultDic);
}];Optional method: Set the checkbox selection state
/**
* After the authorization page is displayed, modifies the selection state of the checkbox. This setting does not take effect if the checkbox is hidden.
*/
- (void)setCheckboxIsChecked:(BOOL)isChecked;Examples
[[TXCommonHandler sharedInstance] setCheckboxIsChecked:YES];Optional method: Hide the loading animation after getting the logon token
/**
* Manually hides the loading animation that appears after getting the logon token. By default, the animation is hidden automatically. If you set the autoHideLoginLoading property of the TXCustomModel instance to NO, you can call this method to hide the animation manually.
*/
- (void)hideLoginLoading;Examples
[[TXCommonHandler sharedInstance] hideLoginLoading];Optional method: Close the secondary authorization pop-up page
/**
* Closes the secondary authorization pop-up page.
*/
- (void)closePrivactAlertView;Example
[[TXCommonHandler sharedInstance] closePrivactAlertView];Follow the system's dark mode on the authorization page
The one-click logon SDK for iOS does not provide built-in UI support that automatically follows the system's dark mode. You can use the UITraitCollection.userInterfaceStyle method from the official Apple developer documentation to determine the user's current appearance mode. Based on the appearance mode, you can manually update UI elements to ensure that the visual experience of the app is consistent with the system settings.
The following code example shows how to make the button text color automatically adjust to the system's appearance mode. You can use this example to adapt the authorization page for dark mode.
// Step 1: Use the initWithDynamicProvider: method of UIColor to create a color that automatically adjusts based on the system's user interface style.
UIColor *buttonColor = [[UIColor alloc] initWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection *
_Nonnull traitCollection) {
if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
return [UIColor redColor]; // Color for dark mode
} else {
return [UIColor blueColor]; // Color for light mode
}
}];
// Step 2: Create a dictionary to define the button text attributes, including color and font size. Then, use these attributes to create an attributed string.
NSDictionary *buttonAttributes = @{
NSForegroundColorAttributeName : buttonColor, // Use the dynamic color
NSFontAttributeName : [UIFont systemFontOfSize:20.0] // Set the font size
};
model.loginBtnText = [[NSAttributedString alloc] initWithString:@"One-click Logon Button Test"
attributes:buttonAttributes];Instrumentation control object
After you obtain this object, you can configure log settings.
/**
* Gets the instrumentation control object.
*/
- (PNSReporter * _Nonnull)getReporter;Example
PNSReporter *reporter = [[TXCommonHandler sharedInstance] getReporter];Switch for console log output
/**
* The switch for console log output. If enabled, logs are output with the PNS_LOGGER prefix. Remember to disable this in Release mode.
* @param enable The switch parameter. Default value: NO.
*/
- (void)setConsolePrintLoggerEnable:(BOOL)enable;Example
PNSReporter *reporter = [[TXCommonHandler sharedInstance] getReporter];
[reporter setConsolePrintLoggerEnable:YES];Switch for log and instrumentation data upload
/**
* Sets the switch for uploading logs and instrumentation data. This does not affect custom upload methods implemented through the setupUploader: API.
* @param enable A BOOL value for the switch. Default value: YES.
*/
- (void)setUploadEnable:(BOOL)enable;Example
PNSReporter *reporter = [[TXCommonHandler sharedInstance] getReporter];
[reporter setUploadEnable:YES];Utility class TXCommonUtils
Check if the device's cellular network is enabled (checkDeviceCellularDataEnable)
/**
Checks if the device's cellular data network (3G or 4G) is enabled.
@return The result.
*/
+ (BOOL)checkDeviceCellularDataEnable;Check if the current internet SIM card is from China Unicom (isChinaUnicom)
/**
Checks if the carrier of the current internet SIM card is China Unicom.
@return The result.
*/
+ (BOOL)isChinaUnicom;Check if the current internet SIM card is from China Mobile (isChinaMobile)
/**
Checks if the carrier of the current internet SIM card is China Mobile.
@return The result.
*/
+ (BOOL)isChinaMobile;Check if the current internet SIM card is from China Telecom (isChinaTelecom)
/**
Checks if the carrier of the current internet SIM card is China Telecom.
@return The result.
*/
+ (BOOL)isChinaTelecom;
Get the name of the current internet carrier (getCurrentCarrierName)
/**
Gets the name of the current internet carrier, such as China Mobile, China Telecom, or China Unicom.
@return The result.
*/
+ (NSString *)getCurrentCarrierName;Get the current internet network type (getNetworktype)
/**
Gets the current internet network type, such as Wi-Fi or 4G.
@return The result.
*/
+ (NSString *)getNetworktype;Check if the device has a SIM card (simSupportedIsOK)
/**
Checks if the current device has a SIM card.
@return The result.
*/
+ (BOOL)simSupportedIsOK;Check if the wireless network is enabled (isWWANOpen)
/**
Checks if the wireless network is enabled (detected via the p0 NIC, with or without Wi-Fi).
@return The result.
*/
+ (BOOL)isWWANOpen;Check if the wireless network is enabled when not connected to Wi-Fi (reachableViaWWAN)
/**
Checks if the wireless network is enabled (only when not connected to Wi-Fi).
@return The result.
*/
+ (BOOL)reachableViaWWAN;Get the device's current private IP address (getMobilePrivateIPAddress)
/**
Gets the private IP address of the device's current network.
@return The result.
*/
+ (NSString *)getMobilePrivateIPAddress:(BOOL)preferIPv4;Get the unique ID of the current device (getUniqueID)
/**
Gets the unique ID of the current device, used for precise instrumentation lookups.
*/
+ (NSString *)getUniqueID;Generate an image from a color setting (imageWithColor)
/**
Generates an image from a color setting. Supports border radius settings, such as for the background image of a one-click logon button.
*/
+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size isRoundedCorner:(BOOL )isRounded radius:(CGFloat)radius;