Backendless Support
 
Answered

Push Notifications receiver-device-id

Greetings,

What is the best way to get the reciever-device-id for sending push notifications with the method below targeting a specific device? The documentation does not explain it. I have a chosen the reciever user from a list of users i have pulled in another api call meaning i have the user object and it's properties.

  1. DeliveryOptions deliveryOptions = new DeliveryOptions();
  2. deliveryOptions.addPushSinglecast( receiver-device-id );
  3. PublishOptions publishOptions = new PublishOptions();
  4. MessageStatus status = Backendless.Messaging.publish( "this is a private message!",
  5. publishOptions,
  6. deliveryOptions );

Regards,

George

Leave a Comment

Comments (4)

photo
1

George,

When a device is registered in an app where there is a logged in user, there will be a relationship established between an object in the DeviceRegistration table and the user object from the Users table. To retrieve the device id, you should retrieve the user who will be receiving the notification and for that user retrieve their device registration. That device registration will contain the ID you're looking for.

Regards,

Mark

photo
1

Hi Mark,

The relationship between User and DeviceRegistration is displayed in console like so. Is "user" the relation column name for User(parent) and DeviceRegistration(child)? That got me a bit confused.

a28542b613434dc36a09bd1713231023

photo
1

Correct, the relation is defined in the Users table. See the little "i" icon in the screenshot? Move the mouse in the console to it and see what it says.

photo
1

Thanks, let me immerse myself in it.

photo