Skip to content
Menu

Push notifications

Deep links

Markdown version

Open a specific screen in your app when a user taps a push notification, a content card or an in-app message button.

A deep link is a URL that opens a specific screen in your app, such as lumen://plan/today. Every Herald push, content card and in-app button can carry one; the SDK opens it when the user taps.

Before you start

  • A URL scheme or universal link (iOS) or App Link (Android) your app already handles, or will handle after this guide.
  • Notification taps wired to the SDK: iOS setup or Android setup.
SourceiOSAndroid
Push taphandleNotificationResponse opens the push's deeplink (a tapped action button's own link first)handleNotificationIntent opens the push's deeplink (a tapped action button's own link first)
Content card or in-app message tapThe HeraldUI views call openDeepLink(_:) for the card or button URL; custom views call it themselvesThe herald-ui views open the card or button URL; custom views call Herald.openUrl
How it opensYour deepLinkHandler, or the system when the handler is not set or returns falseYour Herald.deepLinkHandler, or an ACTION_VIEW intent for the URL when the handler is not set or returns false

Push dismissals never open a link.

Set deepLinkHandler once at launch. Return true when your app handled the URL; return false to let the SDK pass it to the system (for example a web URL that should open in Safari).

swift
@MainActor
func installDeepLinkHandler() {
    Herald.shared.deepLinkHandler = { url in
        guard url.scheme == "lumen" else { return false }
        Router.shared.open(url) // your app's navigation
        return true
    }
}

Handle your own universal links (https:// URLs on your domain) in the handler too, and return true. Handing them to the system from inside your app is not a reliable way to open your own screens.

To open a link from your own UI the same way, for example from a custom card list, call Herald.shared.openDeepLink(url).

From SDK 0.6.0 every link that goes through the SDK (both platforms) is recorded as a $deep_link_opened event, without its query unless you turn on trackDeepLinkQuery. See Lifecycle events.

In Herald, set the deep link on the push message, on the content card, or on each in-app message button. Use the full URL, including the scheme.

Verify it works

Open the link in the simulator to test your routing on its own:

bash
xcrun simctl openurl booted "lumen://plan/today"

Then send a test push with the same deep link and tap it. See Testing push.

Troubleshooting

  • iOS opens Safari instead of the app. The handler returned false for a URL your app owns, or no handler is set. Return true for your scheme and your domains.
  • Nothing happens on Android. No deepLinkHandler took the link and no activity declares an intent filter for the scheme. Logcat shows openUrl failed under the tag Herald.
  • Android opens a second copy of your screen. The link went to ACTION_VIEW, which starts a new task. Set Herald.deepLinkHandler and navigate inside your app.
  • The link opens, but on the wrong screen. Your routing reads the URL before the app finishes launching. Store the URL and navigate once your root view is ready.
  • A web link opens in the app instead of the browser. Your universal link or App Link configuration claims that path. Narrow the paths your app claims.

Next

See Herald decide live →