There are many scenarios when you need to know if a user received a certain message, or they didn't. Whether you are working on a fallback mechanism with pushes and emails, or you want to check how certain users react to your communications, notification delivery tracking would be absolutely necessary, and, chances are, you want to check the delivery status very quickly, seconds after your pushed out a message. In an article below, we'll guide you through the integration of notification handlers that can track the delivery of pushes and allow you to react on those events.
With both iOS and Android, this is done by using Notification Service Extensions.
Android
1) Create a custom NotificationServiceExtension and include fully qualified class name of your NotificationServiceExtension in metadata under com.pushwoosh.notification_service_extension
value.
<meta-data
android:name="com.pushwoosh.notification_service_extension"
android:value="com.your.package.YourNotificationServiceExtension" / >
public class YourNotificationServiceExtension extends NotificationServiceExtension {
@Override
protected void startActivityForPushMessage(PushMessage message) {
super.startActivityForPushMessage() //starts default launcher activity
}
@Override
protected boolean onMessageReceived(PushMessage data){
//handle push delivery here
return false; //return false if a notification should be generated for this push
}
}
iOS
1) Create a Notification Service Extension.2) Add new target to your project (File -> New -> Target) and create Notification Service Extension.
com.pushwoosh.pushon.NotificationService
) as well as its own Apple App ID and Provisioning profile which must be setup in Apple Developer Portal separately.- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler { self.contentHandler = contentHandler; self.bestAttemptContent = [request.content mutableCopy];
[[PWNotificationExtensionManager sharedManager] handleNotificationRequest:request contentHandler:contentHandler];}
Comments
0 comments
Please sign in to leave a comment.