How To Set Up Branch Links in Your Push Notifications

Branch Solutions Architects Sharath Sriram and Zain Sattar Both contributed to this article.


In today’s mobile-first world, push notifications are one of the most effective tools brands have to reach and engage their audience. With users increasingly selective about the mobile apps they interact with, push notifications and in-app messages provide a direct line to grab user attention. Perhaps most importantly, push notifications significantly impact reengagement and retention. After 90 days, app users who have opted in are 88% more likely to interact with the app.

One of the best ways to amplify the impact of your push notifications is by adding deep links that lead directly to specific content within your app. This targeted approach helps users skip multiple steps, taking them straight to the content they care about — a product page, special offer, or personalized update. By setting up Branch Links in your push notifications, you can create a seamless user experience that enhances engagement, reduces friction, provides valuable metrics, and ultimately helps build a stronger relationship with your customers. Read on to learn how to integrate Branch Links into your push notifications and take your mobile marketing to the next level.

Step 1: Create a Branch Link

The first step is creating a Branch Link to use in your push notification payload. We recommend creating unique links specifically for your push notifications. This way, you can easily track where the traffic is coming from by matching these links with the correct analytics data.

You can create a Branch Link from:

Step 2: Add the Branch Link to your push notification payload

Once you have created the Branch Link, you will need to add it as part of your notification payload. Some push notification providers allow you to add new values directly in the UI, while some might require editing a JSON file. Ensure that you place the Branch Link at the top level of your payload content with the key as branch. Here’s an example:

{

“aps”: {

“alert”: “Push notification with a Branch deep link”,

“badge”: “1”

},

“branch”: “https://example.app.link/u3fzDwyyjF”

}

Step 3: Add a push notification handling function to your iOS and Android apps

After setting up your push notifications, configure your apps to handle these Branch Links.

iOS

On iOS, Branch provides a convenient function that looks for the branch parameter in the payload and automatically handles the link.

If you are using the application(_:didReceiveRemoteNotification:fetchCompletionHandler:) function in your App Delegate to handle push notifications, add the following line as part of this function:

Branch.getInstance().handlePushNotification(userInfo)

If you are using the userNotificationCenter(_:didReceive:withCompletionHandler:), you can use this line:

Branch.getInstance().handlePushNotification(response.notification.request.content.userInfo)

Android

Similarly, Branch provides a function on Android that looks for Branch parameters and handles the underlying Branch Link within the payload. Specifically within the Main Activity, the onNewIntent() method is called on the existing activity instance to handle the incoming new intent, which allows the activity to update its state or perform any necessary actions based on this new intent data. Only if the intent extra data matches, branch_force_new_session = true, will it then re-initialize the SDK with the corresponding push notification payload.

override fun onNewIntent(intent: Intent?) {

super.onNewIntent(intent)

this.setIntent(intent);

if (intent != null && intent.hasExtra(“branch_force_new_session”) &&

intent.getBooleanExtra(“branch_force_new_session”,false)) {

Branch.sessionBuilder(this).withCallback { referringParams, error ->

if (error != null) {

Log.e(“BranchSDK_Tester”, error.message)

} else if (referringParams != null) {

Log.i(“BranchSDK_Tester”, referringParams.toString())

}

}.reInit()

}

Need help troubleshooting or have more questions? Reach out to our team.