# Deep links

> Open the right screen when a push or a card is tapped, with Xulo.onOpen.

URL: https://docs.xulo.io/ios/deep-links
iOS SDK version: 0.1.4

A push can carry a link and a data dictionary. When the person taps it, the SDK calls `Xulo.onOpen` with both, and your app decides which screen to open.

## Handle the link

Set `Xulo.onOpen` early, next to `Xulo.start`. Return `true` when your app opened the link.

```swift
Xulo.onOpen = { url, data in
    guard let url, url.scheme == "exampleapp" else {
        return false
    }
    Router.shared.open(url, data: data)
    return true
}
```

- `url` is the push link, or `nil` when the push has none.
- `data` is the push's data dictionary, with your values as text. It also holds `draft_id`, the numeric id of the send.

## What the SDK does

| Your handler returns | Link | Result |
| --- | --- | --- |
| `true` | any | Nothing more. Your app handled it. |
| `false`, or no handler | `https://…` | The link opens in the system browser. |
| `false`, or no handler | any other scheme | Nothing more. |

The SDK does not open a web view. If you want a page inside the app, open it yourself in your handler and return `true`.

## Where the link comes from

The dashboard, an agent and the REST API all write the same two fields: the link and the data. From the REST API they are `url` (or `app_url`) and `data`. See [Send notification](https://docs.xulo.io/api/send-notification).

In the payload they are `custom.u` and `custom.a`. See [Notifications](https://docs.xulo.io/concepts/notifications#the-payload).

## In-app cards

A card's button link goes through the same `Xulo.onOpen` handler, with the same rules.
