how to find failed notifications in IOS APNS calls when device in airplane mode

736 Views Asked by At

If sender is sending apns notifications to user successfully and suddenly user sets device to air plane mode or do not disturb mode then how does the sender know if the device has got the notification or not.

Will Apns notify of success or failure to the sender.

----Update to above question below, is there a way for IOS app to tell the sending java client about the notifications received, without the user's action of launching the app or clicking one the notification.

For e.g. user might be busy and the device may be idle. In such case if a notification arrives, is there a way or API/Method in IOS to send acknowledgement to the sender, that notification with 'someID' is reviced in notification tray.

Reason being, if someOne wants to charge for notifications sent to a device. if user does not recieve it than it may cause problems.

1

There are 1 best solutions below

7
Sandeep Bhandari On

You need to understand the concept of APNS properly. Have a look at the docs to understand it better :) Though, lemme add some key info here to help you :)

There are few wrong assumptions you have about APNS :)

Mistake 1 "If sender is sending apns notifications to user successfully"

I believe by that statement, you mean user using an app sends a APNS to other user using APNS :)

Sorry :) iOS client applications dont directly talk with APNS to send push notifications :) Request to send a push notification might generate at iOS client app (like user types a text and clicks on send) App wont directly make a call to APNS and handover the payload to it :) There is another important entity playing a very important role in background that is your App Server

What happens when I send a text to other user using APNS?? Your application should gather user text and send it to your Application server :) Your Application server then establishes a two way hand shake with APNS :) Once successful it creates the payload in perticular format :) gets the device ID's to which it has to send the data and sends it to APNS finally APNS delivers it to client apps :)

Mistake 2 Will Apns notify of success or failure to the sender.

Apple documentations clearly says APNS is a best effort service :) Which means APNS will not take any guarantee of delivering every single request sent to it :) and does not provide any feedback regarding the successful delivery of packages at client end :)

All the requests that your Application server sends to APNS gets queued and gets delivered when APNS is free to process them :) If request-1 is yet to be processed and request-2 comes from your application server to APNS request-1 will be discarded and request-2 will be processed :)

How to deal with this kind of situations then ? Once receiving the message your receiver iOS app should talk with your application server and inform that it has received the message/package :)

Assume user 1 sends 2 message :) lets say message1 and message 2 :) now your application server sends message1 to APNS hoping that it will deliver the message :) If APNS sends it to user 2, user 2's app should talk with your app server and say hey I got message 1 :) Now when user 1 sends message 2 your application server knows that no messages are pending to send to user 2 :)

If user 1 sends message 3 and user 2 does not receive anything from APNS when user 1 again sends message 4 and user 2 informs that he has recieved message 4 your application server should be able to identify that it has not recieved the feed back for messge 3 so it should re-send it again :)

There are 100 other ways to keep your Client and server in sync :)

TIP If you are developing chat app depending on APNS is not feasible solution :) Hope I guided you atleast with the concept :) Happy coding all the best