Headless
Utilize our Headless SDK for ultimate flexibility. This guide provides detailed instructions on integrating custom UI elements with OTPLESS’s backend authentication functions.
Step 1: Add SDK Dependency
SDK can be installed via both Cocoapods and Swift Package Manager.
Cocoapods
- Open your app’s project file
.xcodeproj
. - Add the following line into the dependencies section of your project’s
Podfile
:
Make sure to run the following commands in your root folder to fetch the dependency.
Swift Package Manager
- In Xcode, click File > Swift Packages > Add Package Dependency.
- In the dialog that appears, enter the repository URL: https://github.com/otpless-tech/Otpless-iOS-SDK.git.
- Select the dependency rule as
exact version
and use the version2.1.9
.
Step 2: Configure info.plist
Add the following block to your info.plist
file:
Add the following block to your info.plist
file (Only required if
you are using the SNA feature):
Replace YOUR_APP_ID
with your actual App
ID provided in
your OTPLESS dashboard.
Step 3: Handle Redirection
Add the following code to your App Delegate
to handle redirection:
Step 4: Initialize OTPLESS
Import OtplessSDK in your signup/sign in file.
Initialise OTPLESS in viewDidLoad() function before proceeding further.
Step 5: Handle Callback
Conform to onHeadlessResponseDelegate
in your signup/sign in file to receive callbacks from OtplessSDK.
Step 6: Initiate Authentication
Initiate the authentication process based on the user’s selected method by using the initiate
method of the SDK.
(Optional): Verify OTP
To verify the OTP entered by the user, use the verify
method with the necessary parameters.
Replace YOUR_APP_ID
with your actual App
ID provided in
your OTPLESS dashboard.
Object Attributes
Attribute | Mandatory | Description |
---|---|---|
channel | Yes | The authentication method selected by the user. |
phone | Conditional | User’s phone number (required if channel is PHONE). |
countryCode | Conditional | Country code of the phone number (required if channel is PHONE). |
email | Conditional | User’s email (required if channel is EMAIL). |
channelType | Conditional | Type of social login initiated (required if channel is OAUTH). |
🏁 Checkpoint
To ensure a smooth integration process:
- Deploy your app/website with the included OTPLESS SDK.
- Conduct tests to verify the sign-in flow functions correctly.
- Ensure that after a successful sign-in, the user is redirected back to your app/website and their information is correctly logged in the console.
User Information Response Structure
The structure of the user information returned upon successful sign-in is as follows:
You can check out a complete sample response here.
Next Steps
Was this page helpful?