0
votes

I recently migrated an old push notification app to a new Azure Mobile Service. The MPNS API, apparently, has changed. It also automatically created a notification hub. Now instead of being able to define a clear channel URI for the message to be sent to, I need to specify a tag. I find it very hard to find information on this and how to send messages to individual users from Azure Mobile Services.

How is this done now?

2

2 Answers

1
votes

Its actually pretty simple. Use your unique user identifier as a tag when you register.

Here is an example.

Registration reg = new AppleRegistration(token)
reg.getTags().add(userId)
hub.createRegistration(reg)

Now when you want to send to that user, send via the tag.

hub.sendNotification(Notification.createAppleNotification(payload), userId)
0
votes

With Notification Hubs you have a few different options. Tags are the way of identifying who you want to push to (i.e. when you push to tag X, any device that has registered with tag X will be pushed to). So if you want to push based off of channel URI, when you register from the device, you should use the Channel URI as one of the tags. If you want to be able to push to all of a single user's devices, you'd need a different mechanism of knowing who the user is (i.e. registering with the username as a tag and then pushing to the username).