Hello Team, We are working on a requirement where the business wants to track the delivery of push notifications on iOS devices. Specifically, they want to capture the moment when the device receives the notification and it appears as a badge in the Notification Center—regardless of whether the app is in the background or not—and then send that delivery status back to APNs. We have explored multiple approaches, but so far, we are only able to capture events when the user interacts with the notification banner. We would like to understand: Is it technically possible to send an event to APNs or another service upon receipt of the notification on the device without requiring user interaction? Any guidance or recommendations would be greatly appreciated.
track PushNotification delivery
You will want to look at implementing a UNNotificationServiceExtension
Argun Tekant / DTS Engineer / Core Technologies
Thanks for your response. We implemented the UNNotificationServiceExtension, but it's not working as expected. When the app is in the background and the device receives a notification in the Notification Center, we are not seeing any events passed to APNS. We only get events for "open" and "clicked" when the user taps on the notification banner. We want to know if it is technically feasible to send events back to APNS when the app is in the background and there is no user interaction ?
What do you mean by "sending events back to APNs"?
If you have implemented your service extension correctly and including the correct payload key "mutable-content": 1
the extension will run whenever you send a notification with visible content. In this extension you can then do what you need to do to inform your own server, or however it is you want to tally received notifications.
Hi,
Yes, we are using the "mutable-content": 1 in notification payload, please see below -
{ "aps": { "alert": { "title": "title", "subtitle": "subtitle", "body": "body" }, "category": "subway", "badge": 1, "sound": "default", ** "mutable-content": 1** }, "_mld": "47785028", "_did": "1d9ba0", "customData": { "message": "This is a regular notification message." } }
Also in UNNotificationService Extension we are passing the details to Adobe Campaign (as we are using Adobe as our Notification platform), please see the attachment
So, that seems all fine. What is it that is not working? You may need to debug your extension or consult with Adobe to find out why this is not working.
Use Case: • The app is running in the background and the device is locked. • A push notification is received. • Business Requirement: Even without user interaction (i.e., user does not tap the notification), the app should capture and send a specific event when the notification is delivered. • Current Behavior: • When the user taps on the notification, the app correctly captures and sends the event. • If the user does not interact with the notification, no event is sent, which is the problem.
A Notification Service Extension will run whether the app is running or not, or whether the device is locked or not - as long as you have the correct payload as you described above.
If the CampaignClassic.trackNotificationReceive
is not working you need to debug your app and find out:
- is it properly configured so the extension is running
- is the payload correct so the extension is running
- is the extension crashing
- is the Adobe library (and anything else you might be using) you are importing to your extension putting it over the 24 MB total memory limit (which will cause the system to terminate your extension)
- is the
CampaignClassic.trackNotificationReceive
able to run in an extension and is it able to do it's thing properly. You need to consult with Adobe's support channels to find out if it is not working - I see your
defer{}
block. If your expectation is it will be called under all circumstances, that is not correct. If the extension code is taking longer than 30 seconds, the system will first callserviceExtensionTimeWillExpire()
function in your extension. If you don't call the contentHandler() immediately, your extension will be terminated, whether thedefer{}
block has been executed or not. - If you receive
serviceExtensionTimeWillExpire()
and you are still processing the notification, or pending onCampaignClassic.trackNotificationReceive
the notification will be terminated regardless
These are some of the possible things that could be going wrong with the extension that is failing to send the event. You need to debug this issue and find out why.
ok, thanks for the detailed suggestion