Azure Notification Hub: Why is NotificationOutcome NotificationId Property Empty? - azure

Using a Standard Notification Hub, I want to view telemetry for a specific message using the returned NotificationId and either this rest API:
https://msdn.microsoft.com/en-us/library/azure/mt608135.aspx
or the NotificationHubClient GetNotificationOutcomeDetailsAsync method:
https://msdn.microsoft.com/en-us/library/microsoft.azure.notificationhubs.notificationhubclient.getnotificationoutcomedetailsasync.aspx
Either way, I need the Notification Message Id that is supposed to be returned from the hub when sending the message.
I am sending the message from the app backend using the SendTemplateNotificationAsync method:
NotificationOutcome result = await hub.SendTemplateNotificationAsync(params, tags);
After sending the template notification, the result.NotificationId property is empty. How can I get the NotificationId so I can then get the telemetry?
Update:
I tried setting the enableTestSend property to true when creating the NotificationHubClient. The result still does not contain a NotificationId.
Currently there is only one device (installation) registered in the hub. Could this be due to a low number of devices receiving the push?

Posting this for the benefit of others who may encounter this issue.
I was contacted by an Azure support engineer who helped me resolve the problem. I had recently switched from the Free to the Standard tier, and there is a bug in Notification Hubs related to changing subscription tiers. This required the support engineer to "force sync the cache" - which resolved the issue.
The bug has been fixed and will be rolling out soon. If you encounter this issue I would suggest contacting Azure support.

Related

Azure Notification Hub not sending notifications randomly

For a few weeks there is an issue with Azure Notification Hub - we have a backend service that registers devices & schedules notifications. When one of the notifications is triggered, then we send it to Azure based on the device type (create the payload and all of that).
The response we get from azure is positive, the notification has been enqueued and is ready to be sent. However, it seems that Azure does not send them all. No error is thrown but only a small percentage is sent. It also does not seem to depend on the device type.
There are no logs to read - or none tha I can find and I cannot pin point the issue.
We have an endpoint that triggers the sending of a notification - we did a test run with 30 notifications (similar and different payloads for the same device) and it all went well.
Not sure how to troubleshoot this or what might cause this. I understood from the documentation that the device might be inactive and then the notification is deleted from the queue after a while. But it seems that the said device receives 1 out of 3 notifications (sent at the same time).
Any feedback would be appreciated.
Edit update:
After upgrading to the Standard plan, we managed to get some more information and it looks like Azure gives back a "Success" with a count of "1" but the device does not receive the notification - the problem is, this happens randomly. It's not always the same device that does or does not receive the notification.
Sorry this isn't a super helpful answer, but could you please open a support ticket in the Azure Portal for us to investigate your particular case? This does not seem like expected behavior so the team will have to look into the logs for your namespace and hub.
One immediate thought - there is de-duplication logic when sending notifications. So within a period of time (something like 15 minutes) if the same notification payload is being sent to the same device, Notification Hubs will automatically drop that duplicate notification.

Azure Push Notification Service for Apple iOS 13 fails

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.

Notification messages delivered to the Azure Notification Hub are not reaching the device(Android)

I need the Notification Message Id that is supposed to be returned from the azure notification hub when sending the message.
I am sending the message from the app backend using the SendGcmNativeNotificationAsync method.
NotificationOutcome outcome = await hub.SendGcmNativeNotificationAsync(notif, tags);
After sending the notification, the outcome.NotificationId property is empty or null. How can I get the Notification Id?
Although the outcome.Result[0].Outcome received has value
"The Notification was successfully sent to the Push Notification System"
but the notifications are not delivered to the registered device.
Also I get a tracking id in outcome.trackingid how can I use it to track the message.
I am using free version of azure portal.
Please suggest
Thanks in advance!
It took me quite some time to figure this out, because it is not clear documented, but the answer is simple: NotificationOutcome.NotificationId is always null when Azure pricing tier is not S1 (Standard).
To figure out the cause of your problem, temporary switch to the S1 pricing tier. Then you will get the NotificationId and Azure will register Per Message Telemetry.
In theory, you should be able to get the results by calling GetNotificationOutcomeDetailsAsync with the NotificationId to get more error info. It can take up to 30 minutes (!) before this call succeeds (if you call it too soon you get a MessagingEntityNotFoundException).
Unfortunately, the result State is mostly Completed, even though the message had a wrong or expired device ID.
The results in the Metrics shown in Azure for your Notification Hub are correct, but I did not find a reliable way yet to retrieve the results on a Per Message base.
Don't forget to switch back to the F1 (Free) pricing tier!

Updating apns credentials in azure notification hubs causing error in portal

I'm trying to update the existing APNS Credential for my Azure notification hub.
Regardless if I try to upload a new certificate or click "Delete Credential" I get the same error:
Error updating notification hub
{"error":{"message":"Object reference
not set to an instance of an object.","code":"InternalServerError"}}
If I check the developer console in the browser, there's a PATCH request made, where the only parameter is pnsCredential: null.
I've tried multiple browsers and computers with same results.
Thank you for your edit, it is correct: this was a transient issue in the Notification Hubs creation. This is now resolved and we are not expecting that specific issue to happen again.
Thanks, Karl
Updating for anyone else who may find this.
This seems to have been an issue on Azure Portal. It has since been resolved and now works as expected, without any further action on my end.
I did report it to #AzureSupport but have not heard of any action taken by them, so not sure if that is why it was resolved.

Azure Notification Hub: How to view per message telemetry?

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. "

Resources