Sign In with Email/Phone Number
Our iOS SDK offers the easiest way to verify email/phone numbers in your Swift app. You can simply call a function and it does most of the heavy lifting and authentication for you.
Concepts: Learn about how Sign in with Email/Phone Number works.
Overview
Verifying email and phone number in your mobile app using our iOS SDK consists of the following steps:
Import Cotter
Call Cotter's Login function
Receive user's email or phone number, and whether or not it's verified
What you're building
Steps
Step 1. Import Cotter as dependency
We use Cocoapods as our SDK host. If you're using Cocoapods, add this to your Podfile
Then simply run pod install
Step 2. Initialize Cotter with your API Key
You will have to do import Cotter
on the file that will use Cotter. Then do initialization as follows
example:
Step 3. Call Cotter's login function
example:
To login and enter email or phone number in Cotter's window, simply set the directLogin to false and set the input to empty string
To send code/link via SMS or WhatsApp, you'll need to add some balance to you project in the Dashboard.
Step 4: Receive Token
The token will be received in the callback function. The token will be in the form as the following:
The token contains the user's phone number, your API_KEY_ID in the receiver field, and a signature to ensure this is from Cotter. The token tells you that this identifier is verified.
You should include this JSON Object into your call to your backend for Login or Registration. Your backend should then verify that the signature of the token is valid.
Validating Cotter's Access Token
Checkout how to verify the OAuth Tokens from Cotter here:
pageVerifying JWT Tokens🎉 You're done!
Securing your Project
Since you'll be using your API Key from a front-end website or mobile app, your API_KEY_ID
is exposed to anyone inspecting your code. Here are some ways to prevent abuse:
Last updated