Expiry message response in push notification for IOS - ios

When the device is off, I am sending push notification with expiry time to the device(IPhone).
If I have switched on the device before expiry time, I am able to receive the msg and no response from apple.
But If I have switched on the device after expiry time, Still no response from apple.
Is it possible to get the response saying "msg got expired" from apple?

No, the feedback service only indicates where you have attempted to deliver a notification to an invalid device ID. There is no indication available as to whether a notification was successfully delivered (or not) to a valid device ID.

Related

iOS APNS - Missing Push Notifications

I am sending notifications to apns one after the other just to test it. For example I send 20 notifications. Each time I send, a counter is incremented and its value is added to the beginning of the title in order to track delivery. The phone receives the first 5 and the 16th but none else.
I am not getting an error for any of them from the apns. They all receive success response.
Why could this be?
EDIT (some extra info):
I am communicating directly with https://api.push.apple.com. I am using http2 and jwtToken. And as suggested, I am keeping the connection alive.
EDIT2:
Device is not offline during this period.
Well, if you send the notifications in a short time period, some may be discarded, especially if the device was temporarily offline when some of the notifications were sent.
Apple Push Notification service includes a Quality of Service (QoS) component that performs a store-and-forward function. If APNs attempts to deliver a notification and the destination device is offline, APNs stores the notification for a limited period of time and delivers it when the device becomes available again. This component stores only the most recent notification per device and per app. If a device is offline, sending a notification request targeting that device causes the previous request to be discarded. If a device remains offline for a long time, all its stored notifications in APNs are discarded.
(Source)
Your app should never depend on all the notifications being delivered.

APNS Bad Channel Error on Notification Hub Test Push Send

I am developing a cross-platform application with xamarin forms and I'm trying to run notifications on the various devices through the notification hub.
I encounter a problem when I try to send a test notification for the iphone.
The device can register the token, received by apns, on the notification hub even if only after the '<' and '>' and spaces are deleted, otherwise, the notification hub returns the error "one or more characters in device token is not a hexadecimal digit".
However, when I try to send a first test notification, Notification Hub returns:
"The test message has been sent. Outcome: {1 success, 0 unsuccessful}"
but notification never reaches the device. All the test notifications sent subsequently result:
"The test message has been sent. Outcome: {0 success, 0 unsuccessful}"
In fact, going to see the metrics in the notification hub the next day there are some
"APNS bad Channel Error"
So what could be the problem? Did anyone have the same problem? And what does "APNS bad channel error" mean?
The APNS Bad channel error indicates the device token you are using is no longer valid. Your app on the device needs to update the token on app. You can include that as part of application restart.
Also, regarding the notication not reaching the device. Can you make sure the device is switched on and notification are turned on. You can try to set the apns-expiration header to a longer value so that apns stores the notification for redelivery for a longer time.
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW13
Thanks,
Amol

App Deletion - APNS Response to Development Server on Push Notification Failure

I have an iOS app that receives notification from APNS. If my user deletes the app there is no way for the backend to know the app is not installed on a certain device(device token). In this case what error code will be generated when trying to push via APNS, so that i can remove the entry from the database?
There is a Provider (Your backend server) API introduced by Apple in WWDC-2015 & enhanced in 2016 to give more valuable feedback to the server about the push notification. Here is a transcript to that WWDC session.
From the transcript: "If a device token has been removed, you will get an HTTP/2 response with status 410, or "removed."
It will have a time stamp in payload indicating when APNS last learned that the device token has been removed."
APNS Server Response Codes
200 Success
400 Bad request
403 There was an error with the certificate or with the provider
authentication token.
405 The request used a bad :method value. Only POST requests are
supported.
410 The device token is no longer active for the topic.
413 The notification payload was too large.
429 The server received too many requests for the same device token.
500 Internal server error
503 The server is shutting down and unavailable.
Now what I cannot confirm to you is that if iOS removes the device token if app is removed or if notification setting is turned off from App settings without deleting app.
"410 does mean the app was uninstalled. The token will remain active if the user disables notification alerts in the app settings. The device will still receive the notification, even if no alert is shown to the user. The server will not know if the user has turned off notification alerts. Only the app knows this."
Thanks to Marcus Adams for clartfying this doubt.
Here goes the Apple Developer Guide!!!
If required, Here is a Paid SDK that can help you with uninstallation tracking.

Apple APNS stream with unregistered devices

I couldn't find any decisive answer in Apple's developers area regarding to an issue with unregistered device from APNS.
Assuming a device has unregistered itself from the APSN service, will I get any response in the stream about it unregistered, or the only way I can know about it is the use of Feedback service?
If in fact the feedback service is the only solution, what way is suggested to handle this success -> failure status?
To be more clear, if I don't get any response in the stream, it means it 'might' (use of Apple) reached its destination but then, the feedback indicates it was a failure.
If a device unregistered itself from APNS via your code (i.e. your app's code initiated the un-registration), your app can notify your server to delete the device token (the same way it notifies the server to store the token after registration).
Otherwise, the only way for the server to know that a device token is no longer relevant (due to app being uninstalled from the device or the user disabling push notifications for the app) is by getting the device token in the Feedback Service.
As for responses in the stream, you only get error responses if the message is invalid. It can be invalid due to an invalid token, but an invalid token is a token that was never valid in the current push env (unlike tokens returned in the Feedback Service, which used to be valid, and may be valid again if the app is re-installed).
To be more clear, if I dont get any response in the stream, it means it 'might' (use of Apple) reached its destination but then, the feedback indicates it was a failure.
If Apple didn't send any response in the stream, it means the message is valid, and Apple will try to deliver it to the device. If, when Apple tries to deliver the message, they discover the app was uninstalled from the device, the next call to the Feedback Service would return the device token of that device.

Push notification is not being delivered when iPhone comes back online

I'm testing Apple push notifications for our iPhone app. The app deployment target is 6.1 and the iPhone is running 7.1.1. We use Apigee as our push notification provider. The phone receives notifications when it's online via cellular and wi-fi, confirming that registration is correct on the app side and Apigee side. I turn on Airplane mode, push a notification from Apigee, wait 3 minutes, take the phone out of Airplane mode, and the phone never receives the push notification. I wait a few minutes (up to 30), then push another notification from Apigee and the phone receives the notification.
I've read Apple's Local and Push Notification Programming Guide and I've read Technical Note TN2265 Troubleshooting Push Notifications.
According to the troubleshooting guide, "Any push notification that isn't delivered immediately was queued for future redelivery because your device was not connected to the service. "Immediately" of course needs to take latency for your connection into account. Outlying cases would be beyond 60 seconds as APNs will time out at that point." This is why I wait 3 minutes. I also know that APNS queues a single message and I think I know that I'm not overwriting that message - unless latency/throughput with the APNS QoS queue is much worse than a few minutes.
In Apigee, in Message History, I see the notification that was sent when the phone was offline. It has a status of Finished with total sent: 1, total errors: 0. I also see a receipt under Data/receipts. This seems to indicate Apigee successfully sent the notification to APNS (but I'm not 100% sure). I verified that the notifierId from Apigee is the same for all notifications sent when online and offline.
Is there any technique I can use to see why the notification is not being delivered from APNS? Is there anything else I can check?
You are correct, if the Notification is showing no errors and a Receipt has been created, the message was properly delivered to APNS.
The only thing I can think of outside of any vagaries of APNS itself that can affect your delivery is if you set the "expire" property on your Notification. Have you tried to see if that makes any difference to your result?

Resources