0
votes

I want to be able to create a User Login on lets call this device (Master). So the user enters a username and password and a new user is created.

Then login on another device(Slave) with the same user details from before.

This will then link the device(Slave) to the device(Master) so that the Master can reference the Slave device.

Then I want to be able to send separate Push Notifications to each (Slave)device that has been linked in this way from the (Master) device.

As far as I can tell to send push notification the device has to register a installation entry in the _Installation table.

How can I solve this in the most effective way?

I would really appreciate your help with this, I am new to using Parse as a backend.

P.S. This would need to work for both Android and iOS devices, though I doubt that matters.

2

2 Answers

0
votes

You can create an array field in your users class and store the installations there. Check if it is the first installation, if so set it as master, else add it to the slaves array

//after logged in
//if first user (master)
if([[[PFUser currentUser] objectForKey:@"slaveInstallations"] count] == 0){
    [PFUser currentUser] setObject:[PFInstallation currentInstallation] forKey:@"masterInstallation"];
} else{ 
    [[PFUser currentUser] addUniqueObject:[PFInstallation currentInstallation] forKey:@"slaveInstallations"];
}
0
votes

I suggest to edit channels to master and slave. Let's say you have 2 user foo, bar who have channel property "global" like below global

If one of them register to other, edit PFInstallation to the master's name so sending masters slaves push should be very simple by that.