0
votes

Problem

I want to receive push notification on iOS devices, those were sent from my web api, but push notifications are never received.

All notifications, that are sent from API are presented in Azure push notification metric as sent successfully, but not received by devices.

However, in case of sending push notification from Azure Push notification hub, via test send, notifications are sent and received successfully.

Configuration:

Web API Configuration:
.NET Core 2.2 web api
Nuget to send push notification from web api: Microsoft.Azure.NotificationHubs
All devices are registered as installations from web api endpoint.

await _hubClient.CreateOrUpdateInstallationAsync(new Installation()
{
    Tags = installation.Tags,
    Platform = NotificationPlatform.Apns,
    PushChannel = installation.PushChannel,
    InstallationId = Guid.NewGuid().ToString()
});

Native approach is used to send push notifications.

var headers = new Dictionary<string, string>
{
    { "apns-push-type", "alert" },
    { "apns-priority", "5" }
};
var message = "{\"Aps\":{\"Alert\":\"Notification Hub test notification\"}}";
var tagExpression = newNotification.Tags.Aggregate((first, second) => $"{first} || {second}");
var notification = new AppleNotification(message, headers);
outcome = await _hubClient.SendNotificationAsync(notification, tagExpression, CancellationToken.None);

I've tried also following approach, but it gave the same result:

await _hubClient.SendAppleNativeNotificationAsync(newNotification.Content, tagExpression);

Azure:
Azure Notification Hub Apple (APNS) is configured with Token-based authentication for production environment.

Also, I've tried:

  1. Certificate based Auth for Azure push notification hub;
  2. enableTestSend for better debug experience. The outcome notification result is "Success";
  3. Increased Azure push natification plan to S1 for better debug experience. The outcome notification result were also "Success";
  4. Recreating push notification hub;
  5. Removing all existing installations;
  6. Testing was completed on 5 different devices.

Question:

  1. Is there any way to debug not delivered push notifications outside Azure notification hub?
  2. What can cause push notifications not being delivered for this case?
1

1 Answers

0
votes

OK, my issue resolved really quickly :)

In case, anyone wondering, there was a typo in APNS template. It was not in camel case.
Wrong:

"{\"Aps\":{\"Alert\":\"Notification Hub test notification\"}}"

Good:

"{\"aps\":{\"alert\":\"Notification Hub test notification\"}}"