Search code examples
c#apple-push-notificationsazure-notificationhub

How to send a notification to a specific APNS notification token using Azure Notification Hub


I am currently using the below code, which sends to all the devices with the tags specified in the enumerable tag argument. However, I want to send to a device with a specific notification token. The below works but I cannot find an overload that simply takes the APNS token?

NotificationService.Instance.Hub.SendAppleNativeNotificationAsync(jsonPayload, userTag);

Solution

  • To send to a specific handle (APNS token in this case) you use 'SendDirectNotificationAsync' and it is not specific to Apple, Windows, or FCM because under the covers the framework knows since during the registration of the handle you would have specified the platform. The signature is as below:

     SendDirectNotificationAsync (Notification notification, 
        string deviceHandle, CancellationToken cancellationToken);