iOS – Sign in with Device
Cotter's Passwordless SDK authenticates your user using the FIDO protocol. It allows a seamless, fast, and secure way for your user to login to your iOS App. Authenticate your users in 4 simple steps:

Sign in with Device

In this guide we'll allow users to Sign In with Device using Cotter's SDK.

Step 1: Import Cotter as a dependency

Head to https://dev.cotter.app/rules and allow Trusted Devices in the dashboard.
We use Cocoapods as our SDK host. Add pod 'Cotter' to your podfile then run pod install.

Step 2: Initialize Cotter

In your app's AppDelegate.swift, initialize Cotter with your API keys.
1
import Cotter // IMPORTANT: IMPORT COTTER AS DEPENDENCY
2
...
3
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
4
Cotter.configureWithLaunchOptions(
5
launchOptions: launchOptions,
6
apiSecretKey: <your-secret-key>,
7
apiKeyID: <your-api-id>
8
)
9
}
Copied!

Step 3: Register your user

To register, simply call the following function anywhere in your app. Make sure you do import Cotter at the start of the swift file.
1
Passwordless.shared.register(
2
identifier: <user-email>
3
)
Copied!

Step 4: Logging in

When a user logs in, call the following function in your view controller
1
Passwordless.shared.parentVC = self
2
Passwordless.shared.login(
3
identifier: <user-email>,
4
cb: { (token: CotterOAuthToken?, err:Error?) in
5
if err != nil {
6
// case 1: handle error as necessary
7
}
8
if token == nil {
9
// case 2: user is unauthorized
10
}
11
// case 3: user is authorized
12
})
Copied!
Then you can handle 3 cases mentioned in the comments in any way you like.

πŸ‘‰ Next steps

That's it! You have successfully build a seamless, fast, and secure login mechanism with Cotter.

Integrate Cotter's push notification services

Verify User's Email or Phone Number

​
Last modified 1yr ago