question

MikeV-4658 avatar image
0 Votes"
MikeV-4658 asked SnehaAgrawal-MSFT answered

How can I batch send the notification hub message to specific users using PNS token

Hello,

A bunch of devices are registered on my server. I have saved the mapping between device Id and PNS token, I have used the device Id as the installation ID to register template notification push on notification hub using installation method.



I have read the doc and saw that there is no such a way to target for specific token or installation ID.

This is the doc I read to send via template: https://docs.microsoft.com/en-us/rest/api/notificationhubs/send-template-notification.

I noticed that the article(https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-registration-management) mentioned that I can actually send through instllation ID:

The installation model supports a special tag format ($InstallationId:{INSTALLATION_ID}) that enables sending a notification directly to the specific device. For example, if the app's code sets an installation ID of joe93developer for this particular device, a developer can target this device when sending a notification to the $InstallationId:{joe93developer} tag. This enables you to target a specific device without having to do any additional coding.

  • I would like to ask how can I target specific users and send message using installation method? I have seen people using tags, however I don't want to use this method because I cannot previously categorize the users into different tags.

  • I don't know if this is applicable for template notification by adding the installation ID to ServiceBusNotification-Tags in the header.

  • Will there be any batch Api that I can do so that I don't need to call the same API for many times?

  • I would also like ask will there be any method that I can push via specific token using template?

Thank you.

azure-notification-hubs
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

SnehaAgrawal-MSFT avatar image
0 Votes"
SnehaAgrawal-MSFT answered

Thanks for asking question!

  1. Targeting an installation/user ID is done via a special installation tag as mentioned in the docs below. If you create an installation using device token (or whatever value you like) abc, you target that user by targeting a special tag $InstallationId:abc.
    You do not need to add this tag themselves.

  2. Template notifications support tags, so targeting installation IDs is supported as well.

  3. There is no batch API for registration/installation-based sends. We do have a direct batch send API for native (non-template) direct sends which accepts up to 1000 devices: https://docs.microsoft.com/en-us/rest/api/notificationhubs/direct-batch-send

  4. We don’t have a method for sending template notifications by device ID. See #1 above.

Hope this helps.





5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.