@doorstepai/dropoff-sdk 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +267 -112
  2. package/android/build.gradle +5 -1
  3. package/android/src/main/java/com/doorstepai/dropoffsdk/DoorstepAIModule.kt +368 -136
  4. package/ios/DoorstepAI.mm +8 -1
  5. package/ios/DoorstepAI.swift +120 -139
  6. package/ios/DoorstepDropoffSDK.xcframework/Info.plist +5 -5
  7. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
  8. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.abi.json +10066 -6190
  9. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +82 -0
  10. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  11. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftinterface +82 -0
  12. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +10 -10
  13. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
  14. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +3833 -3248
  15. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
  16. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +10066 -6190
  17. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +82 -0
  18. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  19. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +82 -0
  20. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +10066 -6190
  21. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +82 -0
  22. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  23. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +82 -0
  24. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +20 -20
  25. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
  26. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +3833 -3248
  27. package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/DoorstepDropoffSDK.yml +3802 -3233
  28. package/lib/module/DoorstepAI.js +306 -71
  29. package/lib/module/DoorstepAI.js.map +1 -1
  30. package/lib/module/RootDoorstepAI.js +50 -32
  31. package/lib/module/RootDoorstepAI.js.map +1 -1
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/typescript/src/DoorstepAI.d.ts +271 -73
  34. package/lib/typescript/src/DoorstepAI.d.ts.map +1 -1
  35. package/lib/typescript/src/RootDoorstepAI.d.ts +24 -7
  36. package/lib/typescript/src/RootDoorstepAI.d.ts.map +1 -1
  37. package/lib/typescript/src/index.d.ts +1 -1
  38. package/lib/typescript/src/index.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/src/DoorstepAI.tsx +425 -91
  41. package/src/RootDoorstepAI.tsx +75 -45
  42. package/src/index.tsx +6 -0
@@ -27,37 +27,161 @@ const doorstepEventEmitter = DoorstepAI ? new NativeEventEmitter(DoorstepAI) : u
27
27
  */
28
28
 
29
29
  /**
30
- * The grant state of one permission, as the published wrapper API has always
31
- * spelled it. `'prompt'` means "not determined yet — asking will show a dialog".
30
+ * A runtime-permission **bucket** — one bucket is one user-visible OS decision,
31
+ * spelled exactly as the native SDK spells it.
32
+ *
33
+ * The buckets are deliberately OS-specific, because the platforms are: iOS has a
34
+ * single Motion & Fitness authorization and no WiFi-scan permission at all,
35
+ * Android splits BLE scanning, nearby-WiFi and notifications into their own
36
+ * dialogs. Only the two location buckets exist on both.
37
+ *
38
+ * | bucket | iOS | Android |
39
+ * |---|---|---|
40
+ * | `locationWhenInUse` | `requestWhenInUseAuthorization` | `ACCESS_FINE_LOCATION` + `ACCESS_COARSE_LOCATION` |
41
+ * | `locationAlways` | `requestAlwaysAuthorization` | `ACCESS_BACKGROUND_LOCATION` |
42
+ * | `motionFitness` | Motion & Fitness | — (use `activityRecognition`) |
43
+ * | `activityRecognition` | — (use `motionFitness`) | `ACTIVITY_RECOGNITION` |
44
+ * | `bluetooth` | `CBCentralManager` | — (use `bluetoothScan`) |
45
+ * | `bluetoothScan` | — (use `bluetooth`) | `BLUETOOTH_SCAN` (API 31+) |
46
+ * | `nearbyWifiDevices` | — | `NEARBY_WIFI_DEVICES` (API 33+) |
47
+ * | `notifications` | — | `POST_NOTIFICATIONS` (API 33+) |
48
+ *
49
+ * You may pass **either platform's** name on either platform: the wrapper
50
+ * translates the counterpart bucket (`motionFitness` ⇄ `activityRecognition`,
51
+ * `bluetooth` ⇄ `bluetoothScan`) so one whitelist works on both without a
52
+ * `Platform.OS` branch. A bucket with no counterpart at all (`nearbyWifiDevices`
53
+ * / `notifications` on iOS) is reported back in `unsupported` rather than
54
+ * silently dropped.
32
55
  */
33
56
 
34
57
  /**
35
- * The permission domains the SDK uses, on BOTH platforms.
36
- *
37
- * - `location` — CoreLocation (iOS) / `ACCESS_FINE_LOCATION` + `ACCESS_COARSE_LOCATION` (Android).
38
- * - `motion` — Motion & Fitness (iOS) / activity recognition (Android).
39
- * - `bluetooth`— Bluetooth (iOS) / the "Nearby devices" group (Android 12+).
58
+ * Coarse aliases accepted anywhere a {@link DoorstepPermission} is, kept because
59
+ * they are what the published 2.x wrapper API took. Each expands to this
60
+ * platform's buckets: `location` → both location buckets, `motion` / `activity`
61
+ * → the platform's motion bucket, `bluetooth` → the platform's BLE bucket
62
+ * (`bluetooth` is also a real iOS bucket name, so it is both).
63
+ */
64
+
65
+ /** Anything the whitelist accepts. */
66
+
67
+ /**
68
+ * The state of one bucket. Eight states, **identical names on both platforms**,
69
+ * so host code branches once.
40
70
  *
41
- * The string `'activity'` is still ACCEPTED wherever a `DoorstepPermissionType`
42
- * is passed, as a **deprecated alias for `'motion'`** — it was the published name
43
- * in `@doorstepai/dropoff-sdk-capacitor` 1.0.4 and dropping it would break hosts.
44
- * It is normalised to `'motion'` before it reaches native, and it is never a key
45
- * of {@link PermissionStatus}.
71
+ * - `granted` — held right now.
72
+ * - `notDetermined` — never asked; a request will show a dialog.
73
+ * - `whenInUseOnly` — **load-bearing.** Foreground location held, background not
74
+ * (iOS "While Using the App" / Android foreground-only). Only ever reported for
75
+ * `locationAlways`. Never treat it as `granted`: background collection and
76
+ * route geofencing do not work in it.
77
+ * - `denied` — refused, but another prompt is still possible. Android only; iOS
78
+ * refusals are always final.
79
+ * - `permanentlyDenied` — refused with no further prompt possible. Deep-link the
80
+ * user to Settings. Every iOS refusal lands here.
81
+ * - `restricted` — blocked by device policy / MDM / Screen Time.
82
+ * - `unavailable` — the OS version or the hardware does not have it. Not a
83
+ * failure, nothing to request.
84
+ * - `notDeclared` — **the HOST BUILD is missing the declaration**
85
+ * (`<uses-permission>` on Android, an `NS…UsageDescription` key on iOS), so the
86
+ * OS would never show a dialog. Fixable by you; it is NOT a user refusal.
46
87
  */
47
88
 
48
- /** The state of every permission domain the SDK uses. */
89
+ /** The evaluated state of one bucket. */
49
90
 
50
- /** Options for {@link DoorstepAIModule.requestPermissions}. */
91
+ /**
92
+ * The grant state of one permission in the **legacy** three-value vocabulary the
93
+ * published 2.x wrapper API used. `'prompt'` means "not determined yet".
94
+ *
95
+ * @deprecated Read {@link PermissionStatus.statuses} instead — it distinguishes
96
+ * `whenInUseOnly`, `permanentlyDenied` and `notDeclared`, all of which collapse
97
+ * away here.
98
+ */
51
99
 
52
100
  /**
53
- * `'activity'` → `'motion'`, applied once here so both bridges only ever see the
54
- * canonical names. This is the ONE alias the public surface owes its published
55
- * history; it is not a wrapper-owned permission list, and it never decides WHICH
56
- * OS permissions get requested — native still owns that.
101
+ * The three coarse domains of the legacy view.
102
+ *
103
+ * @deprecated Use {@link DoorstepPermission}.
57
104
  */
58
- function normalizePermissionTypes(permissions) {
59
- if (permissions == null) return undefined;
60
- return permissions.map(p => p === 'activity' ? 'motion' : p);
105
+
106
+ /** What {@link DoorstepAIModule.checkPermissions} answers. */
107
+
108
+ /** What {@link DoorstepAIModule.requestPermissions} answers. */
109
+
110
+ /** Options for {@link DoorstepAIModule.requestPermissions}. */
111
+
112
+ // ---- Whitelist normalisation ----------------------------------------------
113
+ //
114
+ // A NAMING translation, not a permission list: it maps the names the two native
115
+ // SDKs use onto each other so one host whitelist compiles on both. It never adds
116
+ // or removes a bucket of its own accord, and it never decides what gets
117
+ // requested — the native planner owns that.
118
+
119
+ const IOS_ALIASES = {
120
+ location: ['locationWhenInUse', 'locationAlways'],
121
+ locationwheninuse: ['locationWhenInUse'],
122
+ locationalways: ['locationAlways'],
123
+ motion: ['motionFitness'],
124
+ activity: ['motionFitness'],
125
+ motionfitness: ['motionFitness'],
126
+ activityrecognition: ['motionFitness'],
127
+ bluetooth: ['bluetooth'],
128
+ bluetoothscan: ['bluetooth'],
129
+ nearbywifidevices: [],
130
+ notifications: []
131
+ };
132
+ const ANDROID_ALIASES = {
133
+ location: ['locationWhenInUse', 'locationAlways'],
134
+ locationwheninuse: ['locationWhenInUse'],
135
+ locationalways: ['locationAlways'],
136
+ motion: ['activityRecognition'],
137
+ activity: ['activityRecognition'],
138
+ motionfitness: ['activityRecognition'],
139
+ activityrecognition: ['activityRecognition'],
140
+ bluetooth: ['bluetoothScan'],
141
+ bluetoothscan: ['bluetoothScan'],
142
+ nearbywifidevices: ['nearbyWifiDevices'],
143
+ notifications: ['notifications']
144
+ };
145
+
146
+ /** Every bucket this platform has, derived from the one alias table above. */
147
+ function platformBuckets() {
148
+ const table = Platform.OS === 'ios' ? IOS_ALIASES : ANDROID_ALIASES;
149
+ const out = [];
150
+ for (const mapped of Object.values(table)) {
151
+ for (const bucket of mapped) if (!out.includes(bucket)) out.push(bucket);
152
+ }
153
+ return out;
154
+ }
155
+ function normalizeWhitelist(permissions) {
156
+ if (permissions == null) return {
157
+ buckets: undefined,
158
+ unsupported: []
159
+ };
160
+ const table = Platform.OS === 'ios' ? IOS_ALIASES : ANDROID_ALIASES;
161
+ const buckets = [];
162
+ const unsupported = [];
163
+ for (const raw of permissions) {
164
+ const mapped = table[String(raw).trim().toLowerCase()];
165
+ if (mapped == null || mapped.length === 0) {
166
+ unsupported.push(String(raw));
167
+ continue;
168
+ }
169
+ for (const bucket of mapped) {
170
+ if (!buckets.includes(bucket)) buckets.push(bucket);
171
+ }
172
+ }
173
+ return {
174
+ buckets,
175
+ unsupported
176
+ };
177
+ }
178
+
179
+ /** Merges the wrapper-side `unsupported` list into whatever native answered. */
180
+ function withUnsupported(payload, unsupported) {
181
+ return {
182
+ ...payload,
183
+ unsupported: [...(payload.unsupported ?? []), ...unsupported]
184
+ };
61
185
  }
62
186
 
63
187
  /**
@@ -101,6 +225,40 @@ class DoorstepAIModule {
101
225
  DoorstepAI.setApiKey(apiKey);
102
226
  }
103
227
 
228
+ /**
229
+ * Sets the API key for the Doorstep Go service, which is a separate credential
230
+ * from {@link setApiKey}. Present on both native SDKs; a no-op if you do not use
231
+ * Doorstep Go.
232
+ */
233
+ static setDoorstepGoApiKey(apiKey) {
234
+ DoorstepAI.setDoorstepGoApiKey(apiKey);
235
+ }
236
+
237
+ /**
238
+ * The native SDK's internal-state dump as compact JSON, for bug reports and
239
+ * support logs. Free-form and unstable — never branch on it. **iOS only**
240
+ * (`DoorstepAI.debugStateJson()`); the Android SDK has no counterpart, so it
241
+ * rejects there.
242
+ */
243
+ static debugStateJson() {
244
+ if (Platform.OS !== 'ios') {
245
+ return unsupportedOnThisPlatform('debugStateJson', 'iOS');
246
+ }
247
+ return DoorstepAI.debugStateJson();
248
+ }
249
+
250
+ /**
251
+ * Re-registers the raw-GNSS callbacks after the OS has dropped them (some
252
+ * devices stop delivering measurements without reporting an error). **Android
253
+ * only** — iOS has no raw-GNSS access at all, so it rejects there.
254
+ */
255
+ static retryGnssCallbacks() {
256
+ if (Platform.OS !== 'android') {
257
+ return unsupportedOnThisPlatform('retryGnssCallbacks', 'Android');
258
+ }
259
+ return DoorstepAI.retryGnssCallbacks();
260
+ }
261
+
104
262
  // ---- Runtime permissions -------------------------------------------------
105
263
  // Every method below is a pass-through to the native SDK's own permission API.
106
264
  // The SDK owns the permission list and the prompt ordering; this wrapper used to
@@ -159,66 +317,142 @@ class DoorstepAIModule {
159
317
  }
160
318
 
161
319
  /**
162
- * The current grant state of every permission domain the SDK uses, on both
163
- * platforms. Pure observation — it reads the platform's own status APIs
164
- * (`CLLocationManager.authorizationStatus` / `CMMotionActivityManager.
165
- * authorizationStatus()` / `CBManager.authorization` on iOS,
166
- * `ContextCompat.checkSelfPermission` on Android) and shows no dialog.
320
+ * The current state of the whitelisted permission buckets, on both platforms.
321
+ * **Pure observation — never prompts**, so it is safe at launch, on every
322
+ * screen, as often as you like.
323
+ *
324
+ * @param permissions whitelist; omit for every bucket this platform has.
167
325
  *
168
- * The set of permissions read comes from the native SDK
169
- * (`DoorstepAI.getRequiredPermissions()` on Android); the wrapper keeps no
170
- * permission list of its own, it only reports the state of what native names.
326
+ * ```ts
327
+ * const { statuses } = await DoorstepAI.checkPermissions();
328
+ * if (statuses.locationAlways?.state === 'whenInUseOnly') {
329
+ * // foreground location only: background collection and route geofencing
330
+ * // will NOT work. Never read this as 'granted'.
331
+ * }
332
+ * ```
171
333
  *
172
- * A domain the native SDK requires no runtime grant for on this OS version
173
- * reports `'granted'` — e.g. `motion` on Android, where sensor collection needs
174
- * no runtime permission, and `bluetooth` below Android 12.
334
+ * The buckets and their states come straight from the native SDKs
335
+ * (`DoorstepAI.checkPermissions(...)` on both platforms) — the wrapper keeps no
336
+ * permission list and no state machine of its own.
175
337
  */
176
- static checkPermissions() {
177
- return DoorstepAI.checkPermissions();
338
+ static async checkPermissions(permissions) {
339
+ const {
340
+ buckets,
341
+ unsupported
342
+ } = normalizeWhitelist(permissions);
343
+ const payload = await DoorstepAI.checkPermissions(buckets ?? null);
344
+ return withUnsupported(payload, unsupported);
178
345
  }
179
346
 
180
347
  /**
181
- * The one permission requester. Asks for every runtime permission the SDK needs
182
- * on whichever platform the app is running: Android's foreground runtime
183
- * permissions (`DoorstepAI.requestPermissions(activity, requestCode,
184
- * includeBluetooth)`, only the not-yet-granted ones) and iOS's Location +
185
- * Motion/Fitness + Bluetooth prompts
186
- * (`DoorstepAI.requestAllPermissions(requestAlwaysLocation:requestBluetooth:onlyIfNotDetermined:)`).
348
+ * Every permission bucket this platform has — the whitelist
349
+ * {@link requestPermissions} uses when you pass none.
187
350
  *
188
- * Hosts must not branch on `Platform.OS` to ask for permissions — that branch
189
- * lives here, once, so the two platforms cannot drift apart in host code.
351
+ * Useful for building a permission screen that lists what the SDK can ask for
352
+ * without hardcoding a per-platform list. Synchronous: it is the wrapper's name
353
+ * table, not a device read. Use {@link checkPermissions} for state.
354
+ */
355
+ static allPermissionBuckets() {
356
+ return platformBuckets();
357
+ }
358
+
359
+ /**
360
+ * {@link checkPermissions} rendered as the native SDK's own compact JSON — for
361
+ * bug reports, support logs and scripted on-device assertions.
190
362
  *
191
- * **Resolves only AFTER the user has answered the dialog**, with the resulting
192
- * state — a status captured while the prompt is still up would be stale, and
193
- * reporting it as the outcome would be a lie. A second call made while one is
194
- * still in flight REJECTS rather than interleaving two prompt sequences.
195
- * If the user never answers, the wait gives up after 120 s and resolves with the
196
- * state as it is at that moment (still `'prompt'` for anything unanswered).
363
+ * Shape: `{"<bucket>":{"state":"…","canRequest":true|false,"os":"…"}}`.
364
+ */
365
+ static checkPermissionsJson(permissions) {
366
+ const {
367
+ buckets
368
+ } = normalizeWhitelist(permissions);
369
+ return DoorstepAI.checkPermissionsJson(buckets ?? null);
370
+ }
371
+
372
+ /**
373
+ * The one permission requester, and the only one hosts should need.
197
374
  *
198
- * **`options.permissions` can only narrow Bluetooth.** Neither native offers
199
- * per-permission selection: each requests its whole required set behind one
200
- * `includeBluetooth` / `requestBluetooth` flag. So the array is read as
201
- * `includeBluetooth = permissions.includes('bluetooth')` (Bluetooth is included
202
- * when `permissions` is omitted), and `location` and `motion` always ride the
203
- * base set — **passing `['bluetooth']` alone still requests the base set.**
375
+ * **No argument requests every bucket the platform has. An argument is a
376
+ * whitelist: exactly those buckets are requested and nothing else.** That is
377
+ * the native contract on both platforms
378
+ * (`DoorstepAI.requestPermissions(_ permissions:…)` on iOS,
379
+ * `DoorstepAI.requestPermissions(activity, permissions)` on Android) and this
380
+ * method is a pass-through to it — the wrapper does not decide what gets asked.
204
381
  *
205
- * `'activity'` is accepted in the array as a deprecated alias for `'motion'`.
382
+ * ```ts
383
+ * await DoorstepAI.requestPermissions(); // everything
384
+ * await DoorstepAI.requestPermissions(['locationWhenInUse']); // just that
385
+ * await DoorstepAI.requestPermissions({ permissions: ['location', 'motion'] });
386
+ * ```
206
387
  *
207
- * Native guidance on iOS is to call this once from a user-initiated flow rather
208
- * than from app launch; native's `onlyIfNotDetermined` default (`true`) is what
209
- * makes a launch-time call safe — it is left at the native default here.
388
+ * Accepts the array directly or the legacy `{ permissions: [...] }` object; the
389
+ * object form additionally carries `onlyIfNotDetermined` (iOS) and
390
+ * `timeoutSeconds`.
210
391
  *
211
- * Android's `ACCESS_BACKGROUND_LOCATION` is deliberately NOT part of this call:
212
- * Android 11+ requires it as a second prompt issued after the foreground grant,
213
- * so it keeps its own entry point (`requestBackgroundLocationPermission`). The
214
- * iOS expression of the same intent is native's `requestAlwaysLocation`, left at
215
- * its default (`true`) here.
392
+ * **Resolves only AFTER the user has answered**, with the settled state — a
393
+ * status read while a dialog is still up would be a lie. Anything the native
394
+ * planner declines to ask comes back explained rather than silent:
395
+ * `alreadyDetermined`, `unavailable`, `deferred`.
396
+ *
397
+ * The deferral to expect: **`locationAlways` is only ever requested alone, and
398
+ * only once foreground location is granted** (Android auto-denies a bundled
399
+ * background ask; iOS shows the When-In-Use prompt first and offers the Always
400
+ * upgrade later on its own schedule). So a full-whitelist call typically returns
401
+ * `locationAlways` in `deferred` — call again, with just that bucket, after the
402
+ * first batch is answered.
403
+ *
404
+ * A second call made while one is still in flight does not interleave prompt
405
+ * sequences: iOS reports every bucket as `deferred`, Android rejects with
406
+ * `E_PERMISSION_REQUEST_IN_FLIGHT`.
407
+ *
408
+ * iOS guidance from the SDK: call this **once, from a user-initiated flow**, not
409
+ * from app launch.
216
410
  */
217
- static requestPermissions(options) {
218
- const permissions = normalizePermissionTypes(options?.permissions);
219
- return DoorstepAI.requestPermissions(permissions == null ? null : {
220
- permissions
411
+ static async requestPermissions(options) {
412
+ const opts = Array.isArray(options) ? {
413
+ permissions: options
414
+ } : options ?? {};
415
+ const {
416
+ buckets,
417
+ unsupported
418
+ } = normalizeWhitelist(opts.permissions);
419
+ const payload = await DoorstepAI.requestPermissions({
420
+ permissions: buckets ?? null,
421
+ onlyIfNotDetermined: opts.onlyIfNotDetermined ?? null,
422
+ timeoutSeconds: opts.timeoutSeconds ?? null
221
423
  });
424
+ return withUnsupported(payload, unsupported);
425
+ }
426
+
427
+ /**
428
+ * Forward your Activity's `onRequestPermissionsResult` to the SDK. **Android
429
+ * only; a no-op elsewhere.**
430
+ *
431
+ * Optional but worth wiring: it is the only way the SDK can tell a refusal it
432
+ * may re-ask (`denied`) from one only Settings can fix (`permanentlyDenied`).
433
+ * Android reports the same signals for "permanently denied" and "never asked",
434
+ * and a *cancelled* dialog leaves the same trace as a denial — so the SDK
435
+ * refuses to guess and reports the re-askable `denied` until a real,
436
+ * host-forwarded answer says otherwise.
437
+ *
438
+ * It also settles a `requestPermissions` promise the moment the real answer
439
+ * arrives, instead of waiting on the activity-lifecycle backstop.
440
+ *
441
+ * ```kotlin
442
+ * // MainActivity.kt
443
+ * override fun onRequestPermissionsResult(
444
+ * requestCode: Int, permissions: Array<out String>, grantResults: IntArray
445
+ * ) {
446
+ * super.onRequestPermissionsResult(requestCode, permissions, grantResults)
447
+ * DoorstepAI.notePermissionRequestResult(this, permissions, grantResults)
448
+ * }
449
+ * ```
450
+ *
451
+ * If you would rather not touch Kotlin, call this from JS with the same values.
452
+ */
453
+ static async notePermissionRequestResult(permissions, grantResults) {
454
+ if (Platform.OS !== 'android') return;
455
+ await DoorstepAI.notePermissionRequestResult(permissions, grantResults);
222
456
  }
223
457
 
224
458
  /**
@@ -234,10 +468,11 @@ class DoorstepAIModule {
234
468
  * the two calls for you — deciding when the user has been told why the app wants
235
469
  * "Allow all the time" is the host's, not the wrapper's.
236
470
  *
237
- * On iOS the same intent is already inside `requestPermissions`, via native's
238
- * `requestAlwaysLocation` (left at its default, `true`); there is no iOS
239
- * counterpart to this method, so it rejects there rather than resolving a
240
- * made-up answer.
471
+ * On iOS the same intent is the `locationAlways` bucket of
472
+ * `requestPermissions`; there is no iOS counterpart to this method, so it
473
+ * rejects there rather than resolving a made-up answer. On Android you can also
474
+ * express it as `requestPermissions(['locationAlways'])` — same prompt, and it
475
+ * reports back why if the OS would have refused to show it.
241
476
  *
242
477
  * Resolves `true` when a request was actually issued (false below API 29 or when
243
478
  * already granted).
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","NativeEventEmitter","Platform","DoorstepAI","GEOFENCE_SESSION_EVENT","doorstepEventEmitter","undefined","normalizePermissionTypes","permissions","map","p","unsupportedOnThisPlatform","method","supportedOn","Promise","reject","Error","OS","SDK_LOG_LEVEL_RAW","debug","info","warning","error","critical","DoorstepAIModule","isInitialized","init","notificationTitle","notificationText","console","log","setApiKey","apiKey","getRequiredPermissions","includeBluetooth","hasRequiredPermissions","hasBackgroundLocationPermission","checkPermissions","requestPermissions","options","requestBackgroundLocationPermission","configureRemoteLogging","minLevelRaw","minLevel","enabled","flushIntervalSeconds","batchSize","maxQueueSize","startDeliveryByPlaceID","placeID","deliveryId","timeoutSeconds","timeout","autoStop","autoStopAfterDropoffSeconds","customerId","driverId","result","manualForeground","startDeliveryByPlusCode","plusCode","startDeliveryByAddress","address","coordinates","startDeliveryByAddressString","startDeliveryByLatLng","latitude","longitude","subUnit","markDropoff","dropoffType","stopDelivery","newEvent","eventName","timestamp","startRouteGeofencing","stops","length","updateRouteStops","stopRouteGeofencing","resumeRouteGeofencingIfNeeded","getMonitoredStops","addGeofenceSessionListener","listener","addListener","enableDevMode","Boolean","validateDevModeAccess","disableDevMode"],"sourceRoot":"../../src","sources":["DoorstepAI.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAE1E,MAAM;EAAEC;AAAW,CAAC,GAAGH,aAAa;;AAEpC;AACA;AACA,MAAMI,sBAAsB,GAAG,8BAA8B;AAC7D,MAAMC,oBAAoB,GAAGF,UAAU,GACnC,IAAIF,kBAAkB,CAACE,UAAU,CAAC,GAClCG,SAAS;;AAgBb;AACA;AACA;AACA;AACA;AACA;;AAYA;;AAcA;;AAQA;AACA;AACA;AACA;;AAqCA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAKA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,wBAAwBA,CAC/BC,WAAmE,EAC7B;EACtC,IAAIA,WAAW,IAAI,IAAI,EAAE,OAAOF,SAAS;EACzC,OAAOE,WAAW,CAACC,GAAG,CAAEC,CAAC,IACvBA,CAAC,KAAK,UAAU,GAAG,QAAQ,GAAGA,CAChC,CAAC;AACH;;AAEA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,SAASC,yBAAyBA,CAChCC,MAAc,EACdC,WAA8B,EACd;EAChB,OAAOC,OAAO,CAACC,MAAM,CACnB,IAAIC,KAAK,CACP,cAAcJ,MAAM,OAAOC,WAAW,4CAA4CX,QAAQ,CAACe,EAAE,GAC/F,CACF,CAAC;AACH;AAEA,MAAMC,iBAA8C,GAAG;EACrDC,KAAK,EAAE,CAAC;EACRC,IAAI,EAAE,CAAC;EACPC,OAAO,EAAE,CAAC;EACVC,KAAK,EAAE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D,gBAAgB,IAAI,IAAI,CAAC;EACpE;;EAEA;AACF;AACA;AACA;EACE,OAAOE,+BAA+BA,CAAA,EAAqB;IACzD,IAAIlC,QAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAON,yBAAyB,CAC9B,iCAAiC,EACjC,SACF,CAAC;IACH;IACA,OAAOR,UAAU,CAACiC,+BAA+B,CAAC,CAAC;EACrD;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,gBAAgBA,CAAA,EAA8B;IACnD,OAAOlC,UAAU,CAACkC,gBAAgB,CAAC,CAAC;EACtC;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOC,kBAAkBA,CACvBC,OAAkC,EACP;IAC3B,MAAM/B,WAAW,GAAGD,wBAAwB,CAACgC,OAAO,EAAE/B,WAAW,CAAC;IAClE,OAAOL,UAAU,CAACmC,kBAAkB,CAClC9B,WAAW,IAAI,IAAI,GAAG,IAAI,GAAG;MAAEA;IAAY,CAC7C,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAOgC,mCAAmCA,CAAA,EAAqB;IAC7D,IAAItC,QAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAON,yBAAyB,CAC9B,qCAAqC,EACrC,SACF,CAAC;IACH;IACA,OAAOR,UAAU,CAACqC,mCAAmC,CAAC,CAAC;EACzD;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,sBAAsBA,CAACF,OAM7B,EAAE;IACD,IAAIrC,QAAQ,CAACe,EAAE,KAAK,KAA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A;AACA;AACA;EACE,OAAO4D,0BAA0BA,CAC/BC,QAA+C,EACd;IACjC,OAAO9E,oBAAoB,EAAE+E,WAAW,CAAChF,sBAAsB,EAAE+E,QAAQ,CAAC;EAC5E;;EAEA;;EAEA,aAAaE,aAAaA,CAACrD,MAAc,EAAoB;IAC3D,IAAI9B,QAAQ,CAACe,EAAE,KAAK,KAAK,EAAE;MACzB,MAAMd,UAAU,CAACkF,aAAa,CAACrD,MAAM,CAAC;MACtC,OAAO,IAAI;IACb;IACA,OAAOsD,OAAO,CAAC,MAAMnF,UAAU,CAACkF,aAAa,CAAC,CAAC,CAAC;EAClD;;EAEA;EACA,aAAaE,qBAAqBA,CAAA,EAAqB;IACrD,IAAIrF,QAAQ,CAACe,EAAE,KAAK,SAAS,EAAE,OAAO,KAAK;IAC3C,OAAOqE,OAAO,CAAC,MAAMnF,UAAU,CAACoF,qBAAqB,CAAC,CAAC,CAAC;EAC1D;;EAEA;EACA,aAAaC,cAAcA,CAAA,EAAqB;IAC9C,IAAItF,QAAQ,CAACe,EAAE,KAAK,SAAS,EAAE,OAAO,KAAK;IAC3C,OAAOqE,OAAO,CAAC,MAAMnF,UAAU,CAACqF,cAAc,CAAC,CAAC,CAAC;EACnD;AACF;AAEA,SAAShE,gBAAgB,IAAIrB,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["NativeModules","NativeEventEmitter","Platform","DoorstepAI","GEOFENCE_SESSION_EVENT","doorstepEventEmitter","undefined","IOS_ALIASES","location","locationwheninuse","locationalways","motion","activity","motionfitness","activityrecognition","bluetooth","bluetoothscan","nearbywifidevices","notifications","ANDROID_ALIASES","platformBuckets","table","OS","out","mapped","Object","values","bucket","includes","push","normalizeWhitelist","permissions","buckets","unsupported","raw","String","trim","toLowerCase","length","withUnsupported","payload","unsupportedOnThisPlatform","method","supportedOn","Promise","reject","Error","SDK_LOG_LEVEL_RAW","debug","info","warning","error","critical","DoorstepAIModule","isInitialized","init","notificationTitle","notificationText","console","log","setApiKey","apiKey","setDoorstepGoApiKey","debugStateJson","retryGnssCallbacks","getRequiredPermissions","includeBluetooth","hasRequiredPermissions","hasBackgroundLocationPermission","checkPermissions","allPermissionBuckets","checkPermissionsJson","requestPermissions","options","opts","Array","isArray","onlyIfNotDetermined","timeoutSeconds","notePermissionRequestResult","grantResults","requestBackgroundLocationPermission","configureRemoteLogging","minLevelRaw","minLevel","enabled","flushIntervalSeconds","batchSize","maxQueueSize","startDeliveryByPlaceID","placeID","deliveryId","timeout","autoStop","autoStopAfterDropoffSeconds","customerId","driverId","result","manualForeground","startDeliveryByPlusCode","plusCode","startDeliveryByAddress","address","coordinates","startDeliveryByAddressString","startDeliveryByLatLng","latitude","longitude","subUnit","markDropoff","dropoffType","stopDelivery","newEvent","eventName","timestamp","startRouteGeofencing","stops","updateRouteStops","stopRouteGeofencing","resumeRouteGeofencingIfNeeded","getMonitoredStops","addGeofenceSessionListener","listener","addListener","enableDevMode","Boolean","validateDevModeAccess","disableDevMode"],"sourceRoot":"../../src","sources":["DoorstepAI.tsx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAE1E,MAAM;EAAEC;AAAW,CAAC,GAAGH,aAAa;;AAEpC;AACA;AACA,MAAMI,sBAAsB,GAAG,8BAA8B;AAC7D,MAAMC,oBAAoB,GAAGF,UAAU,GACnC,IAAIF,kBAAkB,CAACE,UAAU,CAAC,GAClCG,SAAS;;AAgBb;AACA;AACA;AACA;AACA;AACA;;AAYA;;AAcA;;AAQA;AACA;AACA;AACA;;AAqCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,UAAU,CAACyH,aAAa,CAAC/D,MAAM,CAAC;MACtC,OAAO,IAAI;IACb;IACA,OAAOgE,OAAO,CAAC,MAAM1H,UAAU,CAACyH,aAAa,CAAC,CAAC,CAAC;EAClD;;EAEA;EACA,aAAaE,qBAAqBA,CAAA,EAAqB;IACrD,IAAI5H,QAAQ,CAACoB,EAAE,KAAK,SAAS,EAAE,OAAO,KAAK;IAC3C,OAAOuG,OAAO,CAAC,MAAM1H,UAAU,CAAC2H,qBAAqB,CAAC,CAAC,CAAC;EAC1D;;EAEA;EACA,aAAaC,cAAcA,CAAA,EAAqB;IAC9C,IAAI7H,QAAQ,CAACoB,EAAE,KAAK,SAAS,EAAE,OAAO,KAAK;IAC3C,OAAOuG,OAAO,CAAC,MAAM1H,UAAU,CAAC4H,cAAc,CAAC,CAAC,CAAC;EACnD;AACF;AAEA,SAAS1E,gBAAgB,IAAIlD,UAAU","ignoreList":[]}
@@ -5,11 +5,19 @@ import { useEffect } from 'react';
5
5
  import { DoorstepAI } from "./DoorstepAI.js";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  const DoorstepAIView = requireNativeComponent('RootDoorstepAIView');
8
+
9
+ /**
10
+ * Drop-in bootstrap: mount it once, near the root, and it runs the SDK's
11
+ * `init` + `setApiKey` and the permission sequence for you. Everything it does is
12
+ * available a la carte on {@link DoorstepAI} — this component exists so a host
13
+ * that just wants the default flow does not have to write it.
14
+ */
8
15
  export function RootDoorstepAI(props) {
9
16
  const {
10
17
  apiKey,
11
18
  notificationTitle,
12
19
  notificationText,
20
+ permissions,
13
21
  requestBluetooth,
14
22
  requestBackgroundLocation
15
23
  } = props;
@@ -17,27 +25,43 @@ export function RootDoorstepAI(props) {
17
25
  let cancelled = false;
18
26
  let backgroundPhaseSettled = false;
19
27
 
20
- // Android requires ACCESS_BACKGROUND_LOCATION to be requested SEPARATELY, and
21
- // only once foreground location is granted — asking earlier burns the request
22
- // on an automatic denial. The foreground grant result is delivered to the
23
- // Activity rather than to JS, so re-run this against native's own predicates
24
- // whenever the host returns to the foreground instead of guessing at the
25
- // dialog outcome.
28
+ // The effective whitelist. `permissions` wins; `requestBluetooth: false` is
29
+ // expressed as "every bucket except this platform's BLE one", which is what
30
+ // the old two-boolean requester meant by it.
31
+ const whitelist = permissions ?? (requestBluetooth === false ? DoorstepAI.allPermissionBuckets().filter(bucket => bucket !== 'bluetooth' && bucket !== 'bluetoothScan') : undefined);
32
+
33
+ // Whether background location is ours to ask for at all: the host can turn the
34
+ // phase off, and a whitelist that does not name the bucket must not have it
35
+ // added back behind the host's back.
36
+ const backgroundInScope = requestBackgroundLocation !== false && (whitelist == null || whitelist.some(p => p === 'locationAlways' || p === 'location'));
37
+
38
+ /**
39
+ * Phase 2. `locationAlways` is only ever asked ALONE and only after foreground
40
+ * location is granted — the SDK enforces both rules and reports a refusal to
41
+ * ask rather than asking anyway, so this can be called optimistically. It is
42
+ * re-run on each foreground because on Android the foreground grant result is
43
+ * delivered to the Activity, not to JS.
44
+ */
26
45
  const runBackgroundLocationPhase = async () => {
27
- if (cancelled || backgroundPhaseSettled || Platform.OS !== 'android' || requestBackgroundLocation === false) {
28
- return;
29
- }
46
+ if (cancelled || backgroundPhaseSettled || !backgroundInScope) return;
30
47
  try {
31
- if (await DoorstepAI.hasBackgroundLocationPermission()) {
48
+ const {
49
+ statuses
50
+ } = await DoorstepAI.checkPermissions(['locationWhenInUse', 'locationAlways']);
51
+ const always = statuses.locationAlways?.state;
52
+ if (always === 'granted') {
32
53
  backgroundPhaseSettled = true;
33
54
  return;
34
55
  }
35
- // Gate on native's own predicate. It is stricter than "location granted"
36
- // (it also covers POST_NOTIFICATIONS), which is the safe direction: a
37
- // premature request is spent, a deferred one can still be made later.
38
- if (!(await DoorstepAI.hasRequiredPermissions())) return;
56
+ // Foreground first: asking earlier spends the request on an automatic
57
+ // denial (Android) or shows the wrong prompt (iOS).
58
+ if (statuses.locationWhenInUse?.state !== 'granted') return;
59
+ // On iOS `whenInUseOnly` is a deliberate user choice and the SDK declines
60
+ // to re-prompt for it; the call is still made because native is the right
61
+ // place for that decision, and it comes back `deferred` rather than
62
+ // prompting.
39
63
  backgroundPhaseSettled = true;
40
- await DoorstepAI.requestBackgroundLocationPermission();
64
+ await DoorstepAI.requestPermissions(['locationAlways']);
41
65
  } catch (err) {
42
66
  console.warn('DOORSTEPAI - background location request failed:', err);
43
67
  }
@@ -54,23 +78,17 @@ export function RootDoorstepAI(props) {
54
78
  DoorstepAI.setApiKey(apiKey);
55
79
  if (cancelled) return;
56
80
  try {
57
- // One requester for both platforms; it dispatches natively. Safe at launch
58
- // on iOS only because native defaults `onlyIfNotDetermined` to true: the
59
- // location prompt is skipped unless authorization is .notDetermined, so
60
- // this cannot re-escalate a user's "While Using the App" choice on every
61
- // launch.
62
- //
63
- // `permissions` can only narrow Bluetooth (see `requestPermissions`), so
64
- // `requestBluetooth === false` is expressed by omitting 'bluetooth' from
65
- // the array; location and motion ride the base set either way.
66
- const status = await DoorstepAI.requestPermissions(requestBluetooth === false ? {
67
- permissions: ['location', 'motion']
68
- } : undefined);
81
+ // One requester for both platforms; native dispatches. Safe at launch on
82
+ // iOS only because native defaults `onlyIfNotDetermined` to true: an
83
+ // already-answered permission is left alone, so this cannot re-escalate a
84
+ // user's "While Using the App" choice on every launch.
85
+ const {
86
+ statuses
87
+ } = await DoorstepAI.requestPermissions(whitelist);
69
88
  if (cancelled) return;
70
- // This resolves only once the user has ANSWERED, so the state is final and
71
- // the second-phase background prompt can be issued straight away instead of
72
- // waiting for the next foreground. On iOS the phase is a no-op.
73
- if (status.permissions.location === 'granted') {
89
+ // Resolves only once the user has ANSWERED, so this state is final and
90
+ // phase 2 can run straight away instead of waiting for the next foreground.
91
+ if (statuses.locationWhenInUse?.state === 'granted') {
74
92
  await runBackgroundLocationPhase();
75
93
  }
76
94
  } catch (err) {
@@ -82,7 +100,7 @@ export function RootDoorstepAI(props) {
82
100
  cancelled = true;
83
101
  appStateSubscription.remove();
84
102
  };
85
- }, [apiKey, notificationTitle, notificationText, requestBluetooth, requestBackgroundLocation]);
103
+ }, [apiKey, notificationTitle, notificationText, permissions, requestBluetooth, requestBackgroundLocation]);
86
104
 
87
105
  // On iOS, the native view might handle triggering permission prompts if needed.
88
106
  // The main setup involves Info.plist configuration.