Cotter
  • 🚀Getting Started
  • Features & Concepts
    • 💬Sign In with Email/Phone Number
    • 🔐Sign In with Device
      • How it works
    • 🧬Sign In with WebAuthn
  • 📌Quickstart Guides
    • All Guides & Tutorials
    • HTML – Sign in with Email/Phone
    • React – Sign in with Email/Phone
    • React – WebAuthn
    • ▲ Next.js
    • Angular
    • Webflow
    • Bubble.io
    • Python SDK for a CLI
    • React Native – Sign in with Device
    • iOS – Sign in with Device
    • Flutter – Sign in with Device
  • 📘SDK Reference
    • Web
      • Sign In with Email/Phone Number
        • Customize the Form
        • Checking the email or phone before sending a verification code
        • Sending Code or Link via WhatsApp
        • Styling
        • Older SDK
          • Customize the Form
      • Sign in with Social Login
        • Getting Access Tokens from Social Login Providers
        • Github Instructions
        • Google Instructions
      • Sign In with WebAuthn
        • Register WebAuthn for a logged-in user
      • Sign In with Device
        • Steps for Pop Up Authentication Prompt
        • Advanced Customization for Login Form
        • Advanced Customization for Pop Up Authentication Prompt
      • Getting Access Token and Logged-In User Info
      • Sending Successful Form Submission
      • FAQ & Troubleshooting
    • React Native
      • Installation
      • Sign In with Device
        • Add Email/Phone Verification
        • Authenticate from a Non-Trusted Device
        • Add a new Trusted Device
        • Remove Trusted Device
      • Sign In with Email/Phone Number
      • Getting Stored OAuth Tokens and User Information
      • FAQ
      • Older SDK Versions
        • Sign in with Email/Phone
        • Sending Code via WhatsApp
        • Sign In with Device
          • Authenticate from a Non-Trusted Device
          • Add a new Trusted Device
          • Customization
    • Flutter
      • Sign In with Device
        • Add Email/Phone Verification
        • Authenticate from a Non-Trusted Device
      • Sign in with Email/Phone Number
      • Getting the Logged-in User
      • Getting OAuth Tokens
      • Signing a User Out
    • iOS
      • Sign In with Email/Phone Number
      • Sign In with Device
        • Authenticate from a Non-Trusted Device
        • Push Notification
        • Check if Trusted Device is Enrolled
        • Add a New Trusted Device
        • Remove Trusted Device
      • Older Versions
        • Biometric/Pin
    • Android
      • Sign In with Device
        • Authenticate from a Non-Trusted Device
        • Check if Trusted Device is Enrolled
        • Add a new Trusted Device
        • Remove Trusted Device
        • Customization
      • Sign In with Email/Phone Number
      • Biometric/Pin
        • Advanced Methods
        • Customization
        • Setting Strings
        • Styling
      • Older SDK Version
        • Sign In with Device
          • Authenticate from a Non-Trusted Device
    • Python (for CLI)
    • API for Other Mobile Apps or CLI
      • Verify Email/Phone Number
        • Handling URL Scheme
    • Backend: Handling Response
  • 🛡️ Protecting Your Account
    • Only Allow Your Website/App to Use Your API Key
    • Rate Limit
    • Enable reCAPTCHA to Protect Against Automated Abuse
  • 🗝️ Getting Access Token
    • Cotter's OAuth 2.0 Tokens Specification
    • Getting the Tokens
      • Get Tokens during Authentication
      • Using the Refresh Token
    • Storing and Removing Tokens
    • Renewing Expired Tokens
    • Verifying JWT Tokens
    • Requesting Custom Fields on your JWT Token
    • Older API
      • Using HTTP Requests
      • Getting the Tokens
        • During Authentication
          • During Email/Phone Verification
        • During enrolling Trusted Devices
  • 🔌API Reference
    • User API
      • User Object
    • OAuth Tokens API
      • Verify JWT Token using API (serverless)
      • Requesting Custom Claims on your Access Token
      • Older API
    • OAuth Tokens from Social Login
    • Event Object
    • Reset PIN API
  • Older API
    • Validating Cotter's Identity Token
    • Validating Cotter's Event Response
Powered by GitBook
On this page
  • Sign in with Device
  • Step 1: Import Cotter as a dependency
  • Step 2: Initialize Cotter
  • Step 3: Register your user
  • Step 4: Logging in
  • 👉 Next steps
  1. Quickstart Guides

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:

PreviousReact Native – Sign in with DeviceNextFlutter – Sign in with Device

Last updated 4 years ago

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 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.

import Cotter // IMPORTANT: IMPORT COTTER AS DEPENDENCY
...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  Cotter.configureWithLaunchOptions(
    launchOptions: launchOptions,
    apiSecretKey: <your-secret-key>,
    apiKeyID: <your-api-id>
  )
}

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.

Passwordless.shared.register( 
  identifier: <user-email>
)

Step 4: Logging in

When a user logs in, call the following function in your view controller

Passwordless.shared.parentVC = self
Passwordless.shared.login(
  identifier: <user-email>, 
  cb: { (token: CotterOAuthToken?, err:Error?) in
    if err != nil {
        // case 1: handle error as necessary
    }
    if token == nil {
        // case 2: user is unauthorized
    }
    // case 3: user is authorized
})

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

📌
https://dev.cotter.app/rules
Push Notification
Sign In with Email/Phone Number