One device registration for multiple users

Hey Team,
We are using JS SDK and registering device using the function shown below in the screen

I checked in the backend we have 1 to 1 relation of the user with the device.

So what will be the best practice to achieve the following use case.

Suppose User-A, User-B…User-N are trying to register/login from the same device. Now, using JS SDK

  1. If User-A register
  2. User-A can receive notifications.
  3. If it’s User-B then (s)he cannot. Because we don’t know how can we add one more record for the same device or how can we add 1 to many relations for users with a device( btw we cannot edit table schema)?

PS: We are sending notification user-specific not to a device directly.


I can offer you the next solution. You can add a custom column to the Device Registration table. Which will have 1:N to the Users table relations and add all necessary users.
Then when you need to send a notification. You will be able to use the segment option. A segment can be defined with a “where clause” which will be executed against the DeviceRegistration table. Backendless will deliver the notification to the devices associated with the users identified by the “where clause”.


How will we add users into to that table using the JS SDK function?
Or we need custom API to register device?

Willit work?

@Baljeet_Singh, here are docs that can help you add objects to the column you need using JS

Set Relation with objects - Backendless SDK for JavaScript API Documentation

Segment works as an ordinary whereClause which you use in the Rest Console. After the condition is added, the number of devices that match the query will be displayed in the right upper corner. Monosnap


But @Marina.Rudenko just checked now
We were using the same SDK function and the user was assigned automatically to device registration table, but now
1.I deleted all the records from the device registration
2.Register new device
3.And see there is no user added in 1:1 relation.

If multiple users use the same device, you must make sure there is a unique device token for each user. Otherwise, you will not be able to send notifications to specific users

But Mark,
Should it be handled automatically with JS SKD Function?
Or If any method using backend APIs then how can we do that?

JS SDK doesn’t know how many users use the device, but you do. SDK will do what you ask it to do.