Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am sending remote push notifications using APNS. The requirement is when the notification is delivered to the app user (even if the user did not tapped on the notification or even seen it) , send a delivery receipt to the web server (i.e. call a web service) according to the notification id i received.

APNS did not have a provision of delivery reports. Their is a feedback service of APNS, however that does not offer delivery report either.

So i would like to know what are the possible ways to get a delivery report of remote push notifications. If i am able to execute a custom method in APP deligate or any other when a remote push notification arrives even when the APP is in background or terminated by user then it will solve my problem.

Any help will be highly appreciated.

Below is the code i am using currently and it is not working when the app is in background.

I wrote a custom method in

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

to send confirmation to the server that the notification is received. When the application is in foreground all functions execute perfectly. But the problem arise when the application is in background. The custom method which is written in

 -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

does not execute until the user open the application by tapping the notification bar and never execute if the user open the application by tapping the app icon not by the notification bar.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
530 views
Welcome To Ask or Share your Answers For Others

1 Answer

Since Apple doesn't provides any method to know when a Push Notification has delivered to user's device. Here is what you can do,

1) Add "Notification Service Extension" to your app.

2) Now add your code for calling webservice to report to your server about the Notification being received, in didReceiveNotificationRequest.

3) Now go to Capabilities of your app and enable "Background fetch" in "Background Modes".

4) Now with the notification you are sending, pass "content-available = 1", This will wake up your app for 30 sec and it can execute the code written in didReceiveNotificationRequest.

It worked for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...