We are able to send push notification to apple 12.x iOS devices. But it doesn't send notification to the iOS 13 devices. We tried the suggestion of adding "apns-push-type" value to "alert" in the notification header. But it doesn't work at all. It seems microsoft doesn't know how to fix it. They just like that told the change. We have tried many ways to solve it for last 1 week. But no success.
Apple recently updated their public Push service in a way that impacts Azure Notification Hubs customers. Learn more about the impact of these changes on Azure Notification Hubs. Specifically, Apple now requires that developers identify notifications as an alert or background notifications through the new 'apns-push-type' header in the APNS API.
Azure Notification Hubs updates for iOS 13 - I understand you mentioned "We have tried many ways to solve it", If you haven't tried these already kindly try and let us know for further investigation.
According to Apple’s documentation: "The value of this header must accurately reflect the contents of your notification’s payload. If there is a mismatch, or if the header is missing on required systems, APNs may return an error, delay the delivery of the notification, or drop it altogether."
Developers must now set this header in their applications that send notifications through Azure Notification Hubs. Due to a technical limitation, customers must use token-based authentication for APNS credentials with requests that includes this attribute. If you’re using certificate-based authentication for your APNS credentials, you must switch to using token-based authentication.
To help you during this transition, when Azure Notification Hubs detects a notification that doesn’t have the apns-push-type set, the service will infer the push type from the notification request and set the value automatically. Remember, you must configure Azure Notification Hubs to use token-based authentication to set the required header; please refer to Token-based (HTTP/2) Authentication for APNS for additional information.
Another minor change, but one that requires a change to the backend application that sends notifications, is the requirement that for background notifications the apns-priority header must be set to 5. Many applications set the apns-priority header to 10 (indicating immediate delivery), or don’t set it and get the default value which is also 10. This is no longer allowed for background notifications, so you must set the value for each request as Apple will not deliver background notifications if this value is missing.
For years, iOS developers used the description attribute of the deviceToken data sent to the push token delegate to extract the push token a backend application uses to send notifications to the device. With Xcode 11, that description attribute changed to a different format. Existing code developers used for this is now broken. We’ve updated the Azure Notification Hubs SDK to accommodate this change, please update the SDK used by your applications to the version 2.0.4 or newer of the Azure Notification Hubs iOS SDK.
Source -Azure Updates Azure Notification Hubs updates for iOS 13 (Posted on 21 October 2019). Copied the content here for more clarity.
Related
In the article describing the registration management it states that:
The following are some key advantages to using installations:
Creating or updating an installation is fully idempotent. So you can
retry it without any concerns about duplicate registrations
What does it exactly mean? I assume it doesn't mean the installations have a 'CreateOrUpdate' unlike registrations, because a similar method also exists there - 'CreateOrUpdateRegistrationAsync'.
Suppose that I've created two installations with different installation ID but the same PNS handle (pushChannel property) and identical tag 'foo' present in both installations. I'm going to send a notification using the SendTemplateNotificationAsync method using the 'foo' tag to select the target of my notification.
It's going to match both my installations, because they both contain the tag 'foo' and both have the same PNS handle. Is the device going to receive two notifications, or is Azure going to prevent delivery of duplicates in this case?
In the the same article I've linked the code samples do check for existing registrations with the PNS handle that's about to get registered:
// make sure there are no existing registrations for this push handle (used for iOS and Android)
string newRegistrationId = null;
var registrations = await hub.GetRegistrationsByChannelAsync(pushChannel.Uri, 100);
but they don't check that in the installations samples, which again suggests that Azure prevents delivery of duplicate notifications.
Creating or updating an installation is fully idempotent. So you can
retry it without any concerns about duplicate registrations
Here, an installation is a term used to describe an enhanced registration (with Azure's Notification Hub) to associate PNS of the device with tag(s) and/or template(s). "Idempotency" here is used with regards to the act of such an installation.
What it means is that you can simply call the same code for this type of registration every time your app starts or is brought to foreground without worrying about handling changes in PNS or previous states of registration with the Notification Hub.
This is good because the classic registration model can lead to duplicate registrations for the same device and user in the notification hub. Installation model doesn't do that.
Q. What would happen when you have one PNS assigned to multiple registrations with same tag in the Notification Hub and you try to push a notification by targeting a tag?
A. Azure Notification Hub has de-duplication logic which will prevent duplicate notifications from going out.
Q. Can you force multiple notifications (for the same tag) in any way if you have multiple applications but one Notification Hub?
A. You can if you can get multiple device tokens. However, in case of iOS, as APNS issues only one valid device token at a time, it will not be possible. Also, iOS apps have their own bundle identifier and therefore their own specific push certificate. And, Notification Hubs don't support multiple certificates. But in case of Android, you can force it if you use registration model and use older GCM registration Ids as they are renewed frequently and don't expire so easily.
Hope that helps! Cheers!
I am currently working on an application built in VS using a Xamarin Unified IOS project. one requirement of the application is the utilisation of push notifications. The issue is that our test device/application registers in the first instance without any issues, we can see the registration events in azure portals, and the azure service bus. I have also confirmed the initial registration using the 'Service Bus Explorer' application and the server explorer feature in VS.
The issue arises when sending the test push notification. According to all the logs I have access too the message is successfully pushed to apples APNS server and I can't see any failures being returned as part of the PNS request. However once this completed the device registration is removed and the notification never arrives on the test device.
My understanding is that the azure application hub handles PNS rejections itself in order to tidy up device registrations. This in and of itself is not a terrible idea, but due to a lack of logging, it's very hard to determine the root cause. I have done a ridiculous amount of googling for this one, and a lot of people suggest an issue with the apple certificates that are used. I have deleted, recreated, resigned, verified, both APNS certs and Provisioning profiles until I ran out of combinations. None of that has resolved the issue.
To make the issue more confusing, if I use a service such as 'http://pushtry.com' or 'http://pushwatch.com' and upload the certificate and device token, it will allow me to successfully push a notification to the device.
Am I missing something glaringly obvious? or is the notification hub absurdly difficult to setup and debug for APNS?
Any help you can provide will be appreciated, I would publish some code, but as I know that the device registers the correct device token, I don't see it necessary at this point, but please feel free to tell me otherwise. Many thanks.
What's also important to note, if you are using Azure Notification Hubs APNS, is that it will unregister devices if the application mode is not set to in production. Once you have deployed to the app store, you need to switch the "application mode" in your Azure Notification Hub from sandbox to production. Otherwise your device registrations will be unregistered.
I'm using the same token/key for both sandbox and production with no issues.
After many man hours and through luck rather than any kind of logical process, we determined that 'Azure Notification Hubs' have an in built validator for the apple device token that's passed up to the APNS. So even though there are multiple examples and answers out there that suggest submitting a device token without spaces or symbols to the notification hub, this is in fact the wrong approach. The device token should always be submitted to the 'Azure Notification Hub' in an 'as is' state, without any validating from within the Xamarin.IOS application. Although this seems like such a simple thing to overlook, there is a lot of contradictory evidence out there on google, and Azure's documentation says very little about the format of submitted device tokens. Anyway hopefully this will help someone else someday.
-- Edit --
Device Token format from Apple: < XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX >
Format that many online resources suggest it is passed to the notification hub as: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
without spaces or the '<' and '>'
However it should be passed through to the notification hub as it is received from Apple.
On the pricing page for Azure Notification Hubs:
https://azure.microsoft.com/en-us/pricing/details/notification-hubs/
It states that "Standard namespaces have access to Per Message Telemetry and Push Notification Services Feedback". I am using a Standard namespace.
The app is sending template based notifications to an iOS app from my back end using the C# Notification Hub client. For example:
NotificationOutcome result = await hub.SendTemplateNotificationAsync(params, tags);
The result.State is coming back as Enqueued, but some notifications are not being delivered and I am trying to figure out why. (There are no bad registrations in the hub - I have already checked that.)
In the Azure portal, I can see aggregate metrics of messages received by the hub, errors, etc. - but I cannot seem to view the specific results of a push message to determine why it failed to reach the device, or even if it was successfully handed off to APNS.
How can I see the results of an attempted push? Is this even possible with Azure Notification Hubs?
Did you try Fiddler+https://msdn.microsoft.com/en-us/library/azure/mt608135.aspx ?
Also, as far as i know, Apple does not guarantee the delivery of all notifications.
1) Is Apple's push notification service reliable?
More of that,
2) https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-faq/
"A PNS does not guarantee any SLA for delivering notifications; however, typically a vast majority of push notifications are delivered to target devices within a few minutes (usually within the limits of 10 minutes) from the time they are sent to our platform. "
Now I'm using PushSharp library to send Apple push notifications (through APNS), but I want to migrate to Notification Hubs for robustness and scalability.
I'm planning to implement sending notification via Azure Notification Hubs using backend registration as described in this article. So:
There is a method of backend API that an iOS client calls when it has push token updated. In this method I do the registration tagging it with user id. (Previously, I stored push token to user link in DB.)
When I have some notification to send for a specific user I send it using the tag (user id). (Previously, I used APNS device token from DB.)
It seems like a working solution, but in Notification Hubs documentation it's said:
It is important to note that registrations are transient. Similar to the PNS handles that they contain, registrations expire. You can set the time to live for a registration on the Notification Hub, up to a maximum of 90 days. This limit means that they must be periodically refreshed, and also that they should not be the only store for important information. This automatic expiration also simplifies cleanup when your mobile application is uninstalled.
And that is the problem. Sometimes I need to send notification to devices that haven't updated the token for 90 days and so forth the registration. So the APNS token will still be active, but Notification Hub's registration will be invalidated. So I just lose the communication channel for the user.
How do you handle this?
Of course, I can still store tokens in DB and make a job that updates registrations periodically. But that's not what you expect from a push notification solution like Notification Hubs.
You can either refresh your registrations from the application or from your server. If you do it from your application, the app must be launched by the user in order for the registration to be refreshed.
Therefore, if you require that device registrations remain active even for apps that weren't launched for over 90 days, you have to refresh the registration via your server, and running a job in your server that would refresh the tokens seems like your only option.
I agree that Notification Hubs' decision to expire the tokens seems strange. Perhaps they had in mind the behavior of MPNS (Microsoft Push Notification Service) notification channels, which expire more often than APNS device tokens or GCM registration IDs.
Just a quick note, since the answer is 2 years old. In this blogpost Azure states:
It is important to note that registrations and installations by default no longer expire.
I assume that this makes the expire field confusing, but not a problem anymore.
UPDATE
Older notification hubs still have this issue. You need to update them to set the expiry to infinity, instructions are found in this forum post. New hubs are automatically set to infinity.
As per latest notification hub documentation, this 90 days limit has increased to lifetime, which means you don't need to re register device after 90 days.
I am evaluating which Push Notification service to use out of Azure Mobile Services, Parse and Urban Airship.
One of the criteria is whether the service provides a way for the app to register a bespoke user Id or alias that can then easily be used when calling the service to send a push notification to an individual. This removes the need for our backend service to have a lookup table giving us the service registration ID for a given user.
Urban Airship has the alias feature: http://docs.urbanairship.com/connect/connect_audience.html#aliases
Parse has a sophisticated Installation object which behaves like a dictionary so that additional values can be added to it (like UserId). When the Parse service is called to send a Push Notification a query can be used to specify the user that will receive the message:
https://www.parse.com/docs/push_guide#sending-queries/REST
Is there an equivalent feature in Azure Mobile Services?
With Mobile Services, you would need to keep track of a user to token / channel URI / registration ID association in a table which is more work than you NEED to do. However, another feature of Windows Azure is Notification Hubs which does what you want (and much more). With Notification Hubs, from the client you say "I want to register for Notification Hubs, here are some tags you can use to push me information". Those tags can be anything you want including a User ID. Later on you can tell your Notification Hub to push to anyone registered with a certain tag. That would allow you to then push notifications out to any devices a specific user has registered.
The flow would look something like this:
Register with Push Provider (APNS, GCM, MPNS, WNS)
Send token to Notification Hubs along with tags (such as the User's ID)
Trigger a push to a specific Tag (i.e. User ID)
Notification Hubs will handle delivering a push to all devices with a Tag (again, their user ID)
Notification Hubs has client SDKs for WinPhone, WinStore, iOS, and Android so it's very easy to use from the client side. As far as triggering pushes goes, Notification Hubs exposes a REST API you can communicate with, there is a .NET SDK, a Node SDK, as well as an unofficial Java SDK. You can even use the Node SDK from Mobile Services which makes it super easy to combine authentication (i.e. getting User IDs) with data storage and push notifications. It also has lots of other features like templated push notifications so instead of specifying a different payload depending on what the device OS you're pushing to is, you can have the client application indicate how it should receive a certain type of push.