We have (mostly) successfully implemented push notifications for iOS and Android devices through Azure notification hubs.
The problem is that some iOS devices apparently never receive notifications sent by Azure Notification Hubs.
We use templates and tags to direct messages to relevant devices. Tags are topics of interest and never depend on the user, therefore, we expect that one notification for a tag will be transferred to all devices subscribed to this tag.
Android devices seem to receive their notifications flawlessly, but iOS devices are incompatible. Most of them work. The couple does not.
We know well that push notifications are delivered with maximum effort and do not have a guarantee of reliability, but in our limited testing we found more devices that do not receive push notifications in succession than seems unreasonable (more than two failures from about a dozen devices).
Here's the setting:
We have a simple C # procedure on the back that connects to Azure notification hubs and sends out Azure notifications:
var outcome = await hub.SendTemplateNotificationAsync(properties, tag);
We used the GetAllRegistrationsAsync method to ensure that all the devices we tested successfully registered and used the correct template. Each device is registered, all templates are correct.
We are not in "test mode"; the enableTestSend parameter of the NotificationHubClient.CreateClientFromConnectionString parameter is set to False.
Troubleshooting:
When we send a notification, most devices receive a notification, and in the specific case that we are testing, update the icon counter with the correct number.
However, several devices do not seem to receive a notification. One of the devices received a notification after rebooting the device, but after that it stopped.
Using the aforementioned GetAllRegistrationsAsync method, we checked that the device problems are correctly registered on Azure and have the correct tags and templates.
We were able to identify the device tokens of problem devices from Azure registrations. We used a PHP script that communicates directly with APNS to send notifications only to problem devices using their device tokens. Each time the device receives this notification with direct sending. These are only Azure notifications that are unreliable.
When we look at the Azure notification hub monitoring page, we see these metrics from the last 24 hours:
- 967 successful APNS notifications
- 3 bad channel APNS errors
- 2 APNS Channel Expired Errors
- 4 APNS errors
... and no other errors reported for APNS or for Azure in general. The failure rate that we see should have been an error counter of more than 20.
We were unable to determine which device tokens were responsible for the errors; is there any way to get this information from Azure?
We cannot explain why we can send notifications directly to these devices on top of APNS themselves, but not through Azure, and why Azure does not report more errors than it does.
Any suggestions or ideas?