How do I get multiple users connect to one device? (with iOS mobile app)

I would like to have multiple iOS apps (one user per app) connect to one Photon device. The Photon (or maybe another database) will keep a record of all users that have connected to it. Is it possible to have multiple users / customers connect to one device? I understand that a device can only be claimed by one user, but how does it work with multiple customers? The docs were a little unclear on how to handle multiple users.

(I’m new to the forums and this post is kind of related to mine but hasn’t been updated in a while and kinda went off topic, so I thought it might be best to start a new topic)

You’d need to clarify a bit more.
How do you want to be connected (SoftAP, TCPServer, cloud functions, …)?

For cloud functions anybody who has the access token can use them concurrently.
The other options are limited by the available free sockets, but a few are possible in parallel.

Yes, cloud functions! To get an access token, you need to authenticate right? I’m confused with the instructions for Simple Authentication. So I get my client ID and secret from the console, add that to my app, the customer logs in to create an account and then (step 4) claims the device. If I have multiple users wanting to connect to the same device, would the device be claimed more than once? Is it ideal/possible to have a device claimed more than once?

Thank you for your help!

No, you can’t have one device claimed to multiple accounts.
You’d either need a shared account or just hand one access token of that account out to the other guys.
You could also have some “colaborators” in your Console account for a particular product.

But it might be best to ping @jeiden to help you select the most suitable option.

1 Like

I’m leaning more towards the use of one access token then, if there is no standard way to have multiple customers connect to one device.

What would be the steps to share this access token? I’m thinking all users log in using the same account, and they would have that access token automatically? Would the step to claim the device using the mobile SDK only be done by the first person to log in, and not by the rest? Is it possible to skip the claiming step if the device has already been claimed?

I’m not familiar with iOS SDK, but I’d guess that logging in and claiming would be two independent modules.
So no need to skip the claiming, just don’t execute that part.
If you were the same person who previously claimed the device you’d also not need to claim the device again.

I just want to describe what I’m currently doing in case anyone else is facing a similar situation.

So first I claim the device using normal methods (Particle app / through USB and particle CLI). This works for my use case because the customers shouldn’t have to worry about claiming a Photon, they just need to all connect to the same one. Eventually, I will have more than one Photon, and different groups of customers will need connection to different Photons (one customer will have at most one Photon connection). Each Photon will be given a random device ID.

The users would have to type that device ID to the app depending on which Photon they will connect to. This ID maps to a specific Photon device’s access token. Behind the scenes, the app would query a database using that ID to get the appropriate access token to be able to connect to the Photon. This way, users don’t have to worry about signing in with a Particle account or claiming the device.

I used the injectSessionAccessToken as detailed here. I got the access token through the Particle console (under Settings). I’m not sure if this is the best way to get the access token though.