Skip to main content
All CollectionsBest practices & use casesUse Cases
How can I send a silent push notification?
How can I send a silent push notification?

You will find here all you need to know to send your first silent push notification to your user.

Baptiste avatar
Written by Baptiste
Updated over a week ago

Batch supports background notifications, which allow you to run actions for a limited amount of time without notifying the user.

Silent push notifications are useful to:

  • Pass data to the app. Data included in the custom payload of the notification will be passed to the app to perform a specific action in the background (e.g. preload content in the app, increase the unread badge count on your app icon, refresh data coming from your servers, etc).

  • Track uninstalls. You can set up a recurring call to the Push Campaigns API or a recurring campaign to target your userbase with a silent push notification every day or every week. Batch will use the feedback coming from Apple and Google to delete all the invalid tokens from your userbase.

Prerequisites

Before sending your first silent push, make sure your app is ready to handle that kind of notification.

On iOS, your app should support background refresh, as described in the documentation.

On Android, silent push notifications will work out of the box with Batch’s default receiver. In case you are using a custom receiver, ensure you don’t display any notification when a null value is received for the “msg” parameter.

Sending Silent Push From Batch APIs

Here is how you should set up your calls to the Push Campaigns API or the Transactional API to send a silent push notification to your users:

iOS

Starting from iOS 13, you need to define explicitly whether a notification should show an alert or be silent to trigger a background action.

This can be done by including the "push_type" parameter in the payload of your call to the API:

{"push_type":"background"}

{\"aps\":{\"content-available\":1}} will automatically be appended to the final payload to wake up the app in the background (see more here).

Note: Users can disable background refresh for your application, or the system might not deliver it in some cases (like battery saving mode). You shouldn't rely on this to work at all times: always fetch data that you can fetch in a more reliable way when your app starts.

Android

On Android, add the following value to the "custom_payload" parameter of your call to the API:

{"msg": null}

Sending Silent Push From The Dashboard

🚧 Android only. On iOS, you will need to create a recurring campaign using the Push Campaigns API.

You can also set up a recurring push campaign from Batch dashboard that will automatically send a silent push notification to your userbase.

Start editing a push campaign from the dashboard. Leave the targeting untouched and set a recurrence for your push campaign (e.g. every day).

Then, you will need to type some text in the body of your push. That part of the message will not be displayed in the notification.

Jump to the "Advanced" part of the campaign edition and paste the following code:

Tracking uninstalls

Once your campaign is running, you will be able to track the number of daily uninstalls  of your app in a more reliable way from the Analytics > Audience tab:

Intercepting a silent push

The management of a silent push is done with the native APIs: iOS / Android


This article belongs to Batch's FAQ. Need more help? Find insightful articles, documentation, case & market studies, guides, and even more in our website's Resources section on batch.com and our blog.

Did this answer your question?