Hi, I’ve been messing around a bit with the Messaging API but have run into a bit of a problem, it seems that for me to send messages just to a specific user/set of users I need to use Device Registration. Is there any way to get around this, or is there something I’m missing?
Hello, Benjamin!
Device registration is needed to receive push notifications. Then, using messaging API, you’ll be able to send push notifications to a specific group of devices, but not users.
Also, messaging API can be used to send emails - device registration is not needed in this case.
Can you please describe what exactly do you want to do so we can help?
best regards,
Alex Navara
Essentially what I’m trying to accomplish is trading, one user has a piece of data that they own, and another user wants that item. The person who wants the item creates a request object that has both of them assigned to it, I’m just attempting to have a message sent to the users involved whenever a change is made on either end of the trade. For example if the object representing the trade has a new note from one of the users attached to it, or one of the users denies or cancels the trade.
Ok, I assume that this question is only about notifying the user.
If you’d like to notify them by email - sendEmail() method from Messaging can be used. In this case you’ll be able to put their emails to List of recipients.
If you’d like to notify them using push notifications - then you can make a mapping between user object and its device id. For example, you can create a field “relatedDeviceId” in Users table, and put there device id when user calls “register()” method from device. After that you’ll be able retrieve device ids for specific users and send them a push notification.
Hi Ben,
What you are trying to do is possible with either pub/sub messaging or push notifications. Please bear in mind that push notifications can be delivered to a device/user even when the app is not running. For the pub/sub messages, the app must be active.
For push notifications you could use the approach described by Alex above. For pub/sub messages, you can create a unique subtopic for each pair of users that need to receive (or exchange) trading messages.
Hope this helps.
Regards,
Mark