# iOS – Sign in with Device

## Sign in with Device

In this guide we'll allow users to **Sign In with Device** using Cotter's SDK.&#x20;

### Step 1: Import Cotter as a dependency

**Head to** [**https://dev.cotter.app/rules**](https://dev.cotter.app/rules) **and allow Trusted Devices in the dashboard.**&#x20;

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.

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

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

### Step 4: Logging in

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

```swift
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

{% content-ref url="/pages/-MCiZep6L97mjBj93JTl" %}
[Push Notification](/sdk-reference/ios/ios-sdk-passwordless-login/ios-push-notification.md)
{% endcontent-ref %}

#### Verify User's Email or Phone Number

{% content-ref url="/pages/-M35aUobglanfiWqjf7S" %}
[Sign In with Email/Phone Number](/sdk-reference/ios/ios-sdk-verify-email-phone.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cotter.app/quickstart-guides/ios-quickstart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
