Skip to content

Commit ab4bd92

Browse files
committed
docs: clarify deviceId is created in admin dashboard, not by SDK
1 parent 0e8d90c commit ab4bd92

3 files changed

Lines changed: 41 additions & 9 deletions

File tree

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ Minimum SDK: **API 29 (Android 10)**
3838

3939
## Device pairing
4040

41-
Before calling `SquareScreen.init()`, a device must be paired with a SquareScreen workspace. Pairing is a two-step admin-confirm flow:
41+
Before calling `SquareScreen.init()`, a device must be paired with a SquareScreen workspace. There are two pairing paths — choose whichever fits your setup.
42+
43+
### Path 1 — Register (admin confirms by OS identifier)
4244

4345
1. An admin pre-registers the device in the SquareScreen dashboard using its Android ID.
4446
2. The SDK calls the register endpoint with that ID and polls for admin approval.
4547
3. On approval, the SDK receives a `deviceId` and `deviceToken` — store them securely and pass them to `SquareScreen.init()`.
4648

47-
### Usage
48-
4949
```kotlin
5050
val androidId = Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
5151
val pairing = SquareScreenPairing.create(
@@ -71,6 +71,38 @@ pairing.pairingStatus.collect { status ->
7171
}
7272
```
7373

74+
### Path 2 — Activate (developer-supplied credentials)
75+
76+
Use this when an admin has already created a device in the SquareScreen dashboard and given you its device ID. You supply that ID alongside your own device token — the token can be anything stable (IMEI, installation UUID, etc.), it is your choice.
77+
78+
1. Admin creates the device in the SquareScreen dashboard — this generates the `deviceId`.
79+
2. The SDK calls the activate endpoint with that `deviceId` and your chosen `deviceToken`, then polls for admin approval exactly like Path 1.
80+
3. On approval, call `SquareScreen.init()` with the same `deviceId` and `deviceToken`.
81+
82+
```kotlin
83+
val pairing = SquareScreenPairing.createWithActivation(
84+
context = applicationContext,
85+
deviceId = "AB12CD34", // created in the SquareScreen admin dashboard
86+
deviceToken = telephonyManager.imei ?: myInstallationUuid,
87+
logger = if (BuildConfig.DEBUG) SquareScreenDebugLogger() else null
88+
)
89+
90+
pairing.pairingStatus.collect { status ->
91+
when (status) {
92+
is PairingStatus.Approved -> {
93+
credentialStore.save(status.deviceId, status.deviceToken)
94+
initializeSdk(status.deviceId, status.deviceToken)
95+
}
96+
PairingStatus.Pending -> showAwaitingApprovalUI()
97+
PairingStatus.DeviceNotFound -> showDeviceNotFoundUI()
98+
PairingStatus.AlreadyPaired -> initializeFromStoredCredentials()
99+
PairingStatus.Expired -> showExpiredUI()
100+
PairingStatus.InvalidToken -> showInvalidTokenUI()
101+
is PairingStatus.Error -> showGenericError(status.throwable)
102+
}
103+
}
104+
```
105+
74106
### How it works
75107

76108
- On first launch (no stored token): calls `register`, persists the returned pairing token, then begins polling `pair-status`.

squarescreen-network/src/main/kotlin/io/squarescreen/network/PairingNetworkClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class PairingNetworkClient {
8787
* Calls `POST /screen/activate` with the developer-supplied device ID and token.
8888
*
8989
* An alternative to [register] for integrators who already hold a SquareScreen device ID
90-
* (8-character alphanumeric) and supply their own device token (IMEI, UUID, etc.).
90+
* (created in the admin dashboard) and supply their own device token (IMEI, UUID, etc.).
9191
* Returns the same [PairingRegistration] as [register] on success.
9292
*/
9393
suspend fun activate(deviceId: String, deviceToken: String): SquareScreenResult<PairingRegistration> {

squarescreen-player/src/main/kotlin/io/squarescreen/player/SquareScreenPairing.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private const val TAG = "SquareScreenPairing"
2626
* Two factory methods cover the two registration paths:
2727
* - [create] — register path: SDK sends an OS identifier; admin confirms in the dashboard.
2828
* - [createWithActivation] — activate path: developer supplies a SquareScreen device ID
29-
* (8-character alphanumeric) and their own device token (IMEI, UUID, etc.).
29+
* (created in the admin dashboard) and their own device token (IMEI, UUID, etc.).
3030
*
3131
* Both paths converge at the same `pair-status` polling loop and emit the same
3232
* [PairingStatus] states.
@@ -195,14 +195,14 @@ class SquareScreenPairing private constructor(
195195
}
196196

197197
/**
198-
* Activate path: the developer supplies a SquareScreen [deviceId] (8-character
199-
* alphanumeric string issued by SquareScreen) and their own [deviceToken]
200-
* (IMEI, UUID, or any stable identifier they choose).
198+
* Activate path: the developer supplies a SquareScreen [deviceId] (created in the
199+
* admin dashboard) and their own [deviceToken] (IMEI, UUID, or any stable identifier
200+
* they choose).
201201
*
202202
* The flow then polls `pair-status` identically to the register path.
203203
*
204204
* @param context Application or Activity context (used for token persistence).
205-
* @param deviceId 8-character alphanumeric SquareScreen device ID.
205+
* @param deviceId SquareScreen device ID created in the admin dashboard.
206206
* @param deviceToken Developer-chosen device token (e.g. IMEI, installation UUID).
207207
* @param logger Optional logger for debug output. Null (default) = silent.
208208
*/

0 commit comments

Comments
 (0)