API - Phone (mobile app)
API - Phone (mobile app)
This page explains how to find, from your own code, a phone running the Phyling mobile app. A phone is then consumed like a Maxi (see API - Real time), with one difference: its serial number is not fixed. It is found from its Device UID, which never changes.
1. Prepare the phone
- Open the Phyling app and sign in to your account.
- On the Real time page, tap the cloud icon to connect to the server. The phone then appears online in the web app.
- Open Settings > Device: you will find the Device UID, in the form
51XX-XXXX-XXXX-XXXX, with a Copy button. - Keep the app open: outside a record, the phone is only online while the app is in the foreground. During a record, the phone can be locked.
Always use the uid in upper case, with hyphens (
51XX-XXXX-XXXX-XXXX), everywhere (REST and Socket.IO).
The uid belongs to the app installation: copy it once and use it in your code. The phone serial number can change: do not hard-code it.
2. Find the device from the uid
GET /devices/uid/{uid}
Authorization: Bearer <access_token> || ApiKey <key>200 response:
{
"uid": "51AB-CDEF-GHJK-MNPQ",
"number": 51100001,
"client_id": 2
}number (serial number) and client_id are the values to use in all the /devices/rt/{client_id}/{device_number}/... routes. The route answers even if the phone is not connected.
| Code | Meaning |
|---|---|
400 | Malformed uid. |
401 | Missing or invalid authentication. |
403 | You have no real-time rights on the client of the phone. |
404 | Unknown uid. |
410 | No active device for this uid: the app must be open on the phone. The body holds a message { "fr": "...", "en": "..." }. |
3. Follow the device in real time
Once you have the serial number, follow the usual Maxi tutorial: API - Real time.
When the serial number changes
The serial number is tied to the account signed in on the phone. It changes:
- when another account signs in on the phone: each account has its own number, and the phone gets the former one back if the first account signs in again;
- after 60 days without a connection: the phone gets a new number at its next connection.
The uid never changes. So call GET /devices/uid/{uid} again each time your code starts, and when the phone comes back online after a disconnection, then resume the real-time tutorial with the number you got.