Pass the
content_available: true
parameter in the Send Notifications API request body and omit the notification
object to send a silent notification: {
"to": "a6345d0278adc55d3474f5",
"data": {
"silentPayloadData": "Hello World"
},
"content_available": true
}
Note: Silent notifications require the Background Modes -> Remote Notifications capability to be enabled in the Xcode project settings.
Sending a silent notification will silently invoke your
pushy.setNotificationHandler()
even when your app is in the background:// Handle push notifications pushy.setNotificationHandler({ (data, completionHandler) in // Print notification payload data print("Received notification: \(data)") // Consume your custom payload in the background silently if data["silentPayloadData"] {
print("This is a silent notification") }
// Call this completion handler when you finish processing // the notification (after fetching background data, if applicable) completionHandler(UIBackgroundFetchResult.newData) })
You may execute a network request at this time to fetch additional data, and afterwards, display a local notification if you wish.
Comments
0 comments
Please sign in to leave a comment.