How to Link a Thing
Before getting the user's data from a thing, it is necessary a procedure called link thing which allows the platform to know that the user is the owner of the thing.
In order to link the thing the user must be logged in and the thing must be activated.
thethings.iO provide the next options to associate a thing to an user's app:
- Link Thing with the thingToken
- Link Thing with a shared id from the device
Link Thing from an App with the thingToken
The easiest way to link a thing is when the user provides the thingToken to the app. The thingToken could be printed at the users' manual, or printed on a card inside the packaging or received after registering the thing at your product's web. There are many ways to do this.
Once the App gets the thingToken from the user, the App has to perform the next operation:
At this point the App has access to the user's thing data.
Link Thing with a shared id from the device
There are some use cases where the App can't know about the thingToken. For this scenarios, the thing and the app has to work together to proceed to link the thing to the user's app.
This is solved creating a shared serial string/number. For example, if a thing like an scale creates a Wi-Fi network, you can use the Wi-Fi SSID to provide a serial string to the app (the app can check for the Wi-Fi networks until recognizes a patron on a SSID).
In this scenario, both, the App and the Thing can start the linking process using this shared serial and wait for the other part to complete the link process. There is a limit of 24 hours to complete the process, if not this has to be restarted.
The App endpoint:
The device endpoint:
How to Unlink a Thing (inverse operation)
If you want to remove the ownership of a thing from a user it's necessary a procedure called unlink thing (inverse to the previous link-thing) which allows the platform to know that the user is no longer the owner of the thing.
In order to unlink the thing the user must be logged in and the thing must be activated and previously linked.
Unlink thing from an App with the thingId
The thingId could be retrieved from the GET:/me/things or GET:/me/resources.
At this point the App don't has longer access to the user's thing data.