Batch allows you to customize your notifications adding specific keys to the payload. The customization of the payload is available for Pro (and higher) users.
Since we allow the overriding of Apple's keys, you can use and override anything Apple accepts in the
Apple's full documentation about the payload is located here
All of the following JSON examples go into the
custom_payload field of both Transactional and Campaigns APIs.
You can add a badge to your iOS notifications by adding a
badge key to the payload of your push. Here is how it looks:
You should reset the badge count when the app is opened.
You can add action buttons to your notification by adding a category key to the payload of your push. Here is how it looks:
We recommend you follow that guide to register categories.
You can set a custom sound for your notification by adding the
sound key to your payload. All you need to do is to add your custom sound to your app bundle before choosing it. Here is how it looks:
You can't remotely push new sounds to your app. The filename (or "default") must be a sound file already present in your app bundle. If it is missing, iOS will play the default sound.
iOS (7+) supports sending pushes that will wake up your app in the background. It works like background fetching, except that you control when your app will wake up.
This allows you to fetch new content (news feed, conversation list, etc) so your users won't have to wait for your app to sync when then open it.
"content-available":1 in your
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.
Batch supports background notifications, which allow you to run actions for a limited amount of time without notifying the user.
Please keep in mind that the same restrictions apply as the ones described higher up for Background Refresh.
When calling our Campaign/Transactional APIs, add
'push_type': 'background' to the request's JSON body, and remove the
Silent notifications are not supported from the dashboard yet. Using the legacy way to do silent notifications using only the custom payload will NOT work on iOS 13 and later.
As said earlier for background refresh, we advise against triggering local notifications in response to a silent notification. While they are handy, the delivery rate will suffer heavily due to the unreliableness of background refresh.
In order to show foreground notifications on iOS 10 and higher, you'll need to implement a
UNUserNotificationCenterDelegate and tell iOS to display the system alert.
If you registered
BatchUNUserNotificationCenterDelegate as your delegate, use the
// If you did not use BatchUNUserNotificationCenterDelegateregisterAsDelegate() but instanciated your own instance, use it instead of `sharedInstance`. BatchUNUserNotificationCenterDelegate.sharedInstance.showForegroundNotifications = true
You can also do so with your own UNUserNotificationCenterDelegate:
- Create a class that implements
- Override userNotificationCenter(center:willPresentNotification:withCompletionHandler) and return at least the alert type to its completion handler
- Call Batch's appropriate methods so you don't break any features
- Set it as the default
UNUserNotificationDelegate along with how to show a foreground push is detailed in Intercepting Notifications.