Azure / azure-notificationhubs-dotnet

.NET SDK for Azure Notification Hubs
MIT License
71 stars 123 forks source link

hubClient.SendAppleNativeNotificationAsync(json, targets) causes Apple to only try to deliver a notification once. #87

Closed Hatju closed 5 years ago

Hatju commented 5 years ago

hubClient.SendAppleNativeNotificationAsync(json, tags)

is the same as doing this

hubClient.SendNotificationAsync(new AppleNotification(json), tags);

What you need to do to get Apple to NOT drop the notification after the first deliver fails is to set a expiry time like this.

notification = new AppleNotification(json); notification.Expiry = DateTime.UtcNow.AddMonths(1); hubClient.SendNotificationAsync(notification, tags);

So either the default for AppleNotification.Expiry should be changed from NULL to something like DateTime.UtcNow.AddDays(1) or SendAppleNativeNotificationAsync should be deprecated as using it will cause many of you push requests to fail delivery to the devices.

marstr commented 5 years ago

Howdy @Hatju,

You bring good light to a pretty confusing part of our SDK, which is substantiated by Apple's documentation. However, I'm afraid that making this change as suggested would break people who mean to send a one-time best effort notification.

Though, your point is noted. If we ever overhaul the SDK's public interface, trying to surface retry policies in a more intuitive fashion would be of the utmost importance.

Hatju commented 5 years ago

Hi @marstr I get you point about breking compatibility. But a update to the API documatation stating that using SendAppleNativeNotificationAsync and e.g. SendFcmNativeNotificationAsync do not result in the same for Apple and google phones would be a huge help to new users of the API I'm sure.