Skip to content

Soft push prompts for Web

Learn how to set up soft push prompts for the Braze SDK.

Prerequisites

Before you can use this feature, you’ll need to integrate the Web Braze SDK. You’ll also need to set up push notifications.

About soft push prompts

It’s often a good idea for sites to implement a “soft” push prompt where you “prime” the user and make your case for sending them push notifications before requesting push permission. This is useful because the browser throttles how often you may prompt the user directly, and if the user denies permission you can never ask them again.

Alternatively, if you would like to include special custom handling, instead of calling requestPushPermission() directly as described in the standard Web push integration, use our triggered in-app messages.

Setting up soft push prompts

Step 1: Create a push primer campaign

First, you must create a “Prime for Push” in-app messaging campaign in the Braze dashboard:

  1. Create a Modal in-app message with the text and styling you want.
  2. Next, set the on-click behavior to Close Message. This behavior will be customized later.
  3. Add a key-value pair to the message where the key is msg-id, and the value is push-primer.
  4. Assign a custom event trigger action (such as “prime-for-push”) to the message. You can create the custom event manually from the dashboard if needed.

Step 2: Remove calls

In your Braze SDK integration, find and remove any calls to automaticallyShowInAppMessages() from within your loading snippet.

Step 3: Update integration

Finally, replace the removed call with the following snippet:

When you wish to display the soft push prompt to the user, call braze.logCustomEvent - with whatever event name triggers this in-app message.

HOW HELPFUL WAS THIS PAGE?
New Stuff!