delivered, and opened
counts can exceed delivered counts in the dashboard.
1
Create the extension target
In Xcode: File > New > Target > Notification Service Extension. Name it
anything, for example Link the
NotificationService. Replace the generated class
with a subclass of ours:PushNotifAINSE product to the extension target only.2
Create the app group
In the Apple Developer portal, create an app group named:For the app
com.acme.app that is group.com.acme.app.pushnotifai.Add the App Groups capability with that group to both the app target
and the extension target, then regenerate your distribution provisioning
profiles, since they change when capabilities do.3
Ship it
That’s all. Following the naming convention means neither target needs any
configuration: each works out the group from its own bundle id.
Using a different group name
If your group can’t follow the convention, point both sides at it. In the app:PushNotifAIAppGroup = group.custom-id to its
Info.plist, or override appGroupId in your subclass.
How it behaves
- Never delays your notification for long. The report is attempted with a
5 second timeout (override
beaconTimeoutto change it), then the notification is handed back to iOS either way. - Never loses a report. It is written to disk in the app group before any network attempt. If the upload doesn’t finish, the app sends it on next launch.
- Never double counts. Reports carry stable ids, so the extension and the app both sending one counts once.
- Leaves other pushes alone. A push that didn’t come from PushNotifAI passes through untouched and isn’t reported.
Already have a Notification Service Extension?
Make your existing class subclassPushNotifAIServiceExtension instead of
UNNotificationServiceExtension, and call super from didReceive and
serviceExtensionTimeWillExpire for pushes you don’t handle yourself.