Skip to content

Deep linking in push notifications

Learn how to set up silent push notifications for the Braze SDK.

Prerequisites

Before you can use this feature, you’ll need to integrate the Android Braze SDK.

Creating a universal delegate

The Android SDK provides the ability to set a single delegate object to custom handle all deep links opened by Braze across Content Cards, in-app messages, and push notifications.

Your delegate object should implement the IBrazeDeeplinkHandler interface and be set using BrazeDeeplinkHandler.setBrazeDeeplinkHandler() . In most cases, the delegate should be set in your app’s Application.onCreate().

The following is an example of overriding the default UriAction behavior with custom intent flags and custom behavior for YouTube URLs:

Deep linking to app settings

To allow deep links to directly open your app’s settings, you’ll need a custom BrazeDeeplinkHandler. In the following example, the presence of a custom key-value pair called open_notification_page will make the deep link open the app’s settings page:

Customizing WebView activity

By default, when website deeplinks are opened inside the app by Braze, they are handled by BrazeWebViewActivity . To change this:

  1. Create a new Activity that handles the target URL from Intent.getExtras() with the key com.braze.Constants.BRAZE_WEBVIEW_URL_EXTRA. For an example, see BrazeWebViewActivity.java .
  2. Add that activity to AndroidManifest.xml and set exported to false.
  3. Set your custom Activity in a BrazeConfig builder object . Build the builder and pass it to Braze.configure() in your Application.onCreate() .

Using Jetpack Compose

To handle deeplinks when using Jetpack Compose with NavHost:

  1. Ensure that the activity handling your deeplink is registered in the Android Manifest.
  2. In NavHost, specify which deeplinks you want it to handle.
  3. Depending on your app architecture, you may need to handle the new intent that’s sent to your current activity as well.

Prerequisites

Before you can use this feature, you’ll need to integrate the Swift Braze SDK.

Step 1: Register a scheme

To handle deep linking, a custom scheme must be stated in your Info.plist file. The navigation structure is defined by an array of dictionaries. Each of those dictionaries contains an array of strings.

Use Xcode to edit your Info.plist file:

  1. Add a new key, URL types. Xcode will automatically make this an array containing a dictionary called Item 0.
  2. Within Item 0, add a key URL identifier. Set the value to your custom scheme.
  3. Within Item 0, add a key URL Schemes. This will automatically be an array containing a Item 0 string.
  4. Set URL Schemes » Item 0 to your custom scheme.

Alternatively, if you wish to edit your Info.plist file directly, you can follow this spec:

Step 2: Add a scheme allowlist

You must declare the URL schemes you wish to pass to canOpenURL(_:) by adding the LSApplicationQueriesSchemes key to your app’s Info.plist file. Attempting to call schemes outside this allowlist will cause the system to record an error in the device’s logs, and the deep link will not open. An example of this error will look like this:

For example, if an in-app message should open the Facebook app when tapped, the app has to have the Facebook custom scheme (fb) in your allowlist. Otherwise, the system will reject the deep link. Deep links that direct to a page or view inside your own app still require that your app’s custom scheme be listed in your app’s Info.plist.

Your example allowlist might look something like:

For more information, refer to Apple’s documentation on the LSApplicationQueriesSchemes key.

Step 3: Implement a handler

After activating your app, iOS will call the method application:openURL:options: . The important argument is the NSURL object.

App Transport Security (ATS)

As defined by Apple , “App Transport Security is a feature that improves the security of connections between an app and web services. The feature consists of default connection requirements that conform to best practices for secure connections. Apps can override this default behavior and turn off transport security.”

ATS is applied by default. It requires that all connections use HTTPS and are encrypted using TLS 1.2 with forward secrecy. Refer to Requirements for Connecting Using ATS for more information. All images served by Braze to end devices are handled by a content delivery network (“CDN”) that supports TLS 1.2 and is compatible with ATS.

Unless they are specified as exceptions in your application’s Info.plist, connections that do not follow these requirements will fail with errors that are similar to the following.

Example Error 1:

Example Error 2:

ATS compliance is enforced for links opened within the mobile app (our default handling of clicked links) and does not apply to sites opened externally via a web browser.

Working with ATS

You can handle ATS in either of the following ways, but we recommend complying with ATS requirements.

Your Braze integration can satisfy ATS requirements by ensuring that any existing links you drive users to (for example, though in-app message and push campaigns) satisfy ATS requirements. While there are ways to bypass ATS restrictions, our recommendation is to ensure that all linked URLs are ATS-compliant. Given Apple’s increasing emphasis on application security, the following approaches to allowing ATS exceptions are not guaranteed to be supported by Apple.

You can allow a subset of links with certain domains or schemes to be treated as exceptions to the ATS rules. Your Braze integration will satisfy ATS requirements if every link you use in a Braze messaging channel is either ATS compliant or handled by an exception.

To add a domain as an exception of the ATS, add following to your app’s Info.plist file:

Refer to Apple’s article on app transport security keys for more information.

You can turn off ATS entirely. Note that this is not recommended practice, due to both lost security protections and future iOS compatibility. To disable ATS, insert the following in your app’s Info.plist file:

Decoding URLs

The SDK percent-encodes links to create valid URLs. All link characters that are not allowed in a properly formed URL, such as Unicode characters, will be percent escaped.

To decode an encoded link, use the String property removingPercentEncoding . You must also return true in the BrazeDelegate.braze(_:shouldOpenURL:). A call to action is required to trigger the handling of the URL by your app. For example:

Deep linking to app settings

You can take advantage of UIApplicationOpenSettingsURLString to deep link users to your app’s settings from Braze push notifications and in-app messages.

To take users from your app into the iOS settings:

  1. First, make sure your application is set up for either scheme-based deep links or universal links.
  2. Decide on a URI for deep linking to the Settings page (for example, myapp://settings or https://www.braze.com/settings).
  3. If you are using custom scheme-based deep links, add the following code to your application:openURL:options: method:

Customization options

Default WebView customization

The Braze.WebViewController class displays web URLs opened by the SDK, typically when “Open Web URL Inside App” is selected for a web deep link.

You can customize the Braze.WebViewController via the BrazeDelegate.braze(_:willPresentModalWithContext:) delegate method.

Linking handling customization

The BrazeDelegate protocol can be used to customize the handling of URLs such as deep links, web URLs, and universal links. To set the delegate during Braze initialization, set a delegate object on the Braze instance. Braze will then call your delegate’s implementation of shouldOpenURL before handling any URIs.

Braze supports universal links in push notifications, in-app messages, and Content Cards. To enable universal link support, configuration.forwardUniversalLinks must be set to true.

When enabled, Braze will forward universal links to your app’s AppDelegate via the application:continueUserActivity:restorationHandler: method.

Your application also needs to be set up to handle universal links. Refer to Apple’s documentation to ensure your application is configured correctly for universal links.

Examples

BrazeDelegate

Here’s an example using BrazeDelegate. For more information, see Braze Swift SDK reference .

Prerequisites

Before you can implement deep linking into your Flutter app, you’ll need to set up deep linking in the native Android or iOS layer.

Implementing deep linking

Step 1: Set up Flutter’s built-in handling

  1. In your Xcode project, open your Info.plist file.
  2. Add a new key-value pair.
  3. Set the key to FlutterDeepLinkingEnabled.
  4. Set the type to Boolean.
  5. Set the value to YES. An example project's `Info.plist` file with the added key-value pair.
  1. In your Android Studio project, open your AndroidManifest.xml file.
  2. Locate .MainActivity in your activity tags.
  3. Within the activity tag, add the following meta-data tag:

Step 2: Forward data to the Dart layer (optional)

You can use native, first-party, or third-party link handling for complex use cases, such as sending a user to a specific location in your app, or calling a specific function.

Example: Deep linking to an alert dialog

First, a method channel is used in the native layer to forward the deep link’s URL string data to the Dart layer.

Next, a callback function is used in the Dart layer to display an alert dialogue using the URL string data sent previously.

HOW HELPFUL WAS THIS PAGE?
New Stuff!