Reputation: 1
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.
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.
Upvotes: 0
Views: 720
Reputation: 1
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\"}}"
Upvotes: 0