@doorstepai/dropoff-sdk 2.2.0 → 2.2.3
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.
- package/README.md +265 -112
- package/android/build.gradle +5 -1
- package/android/src/main/java/com/doorstepai/dropoffsdk/DoorstepAIModule.kt +368 -136
- package/ios/DoorstepAI.mm +8 -1
- package/ios/DoorstepAI.swift +120 -139
- package/ios/DoorstepDropoffSDK.xcframework/Info.plist +5 -5
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.abi.json +10176 -6209
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +82 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios.swiftinterface +82 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +10 -10
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +3867 -3248
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +10176 -6209
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +82 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +82 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +10176 -6209
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +82 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/Modules/DoorstepDropoffSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +82 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/DoorstepDropoffSDK.framework/_CodeSignature/CodeResources +20 -20
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/DWARF/DoorstepDropoffSDK +0 -0
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/aarch64/DoorstepDropoffSDK.yml +3868 -3248
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/DoorstepDropoffSDK.yml +3836 -3233
- package/lib/module/DoorstepAI.js +306 -71
- package/lib/module/DoorstepAI.js.map +1 -1
- package/lib/module/RootDoorstepAI.js +50 -32
- package/lib/module/RootDoorstepAI.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/DoorstepAI.d.ts +271 -73
- package/lib/typescript/src/DoorstepAI.d.ts.map +1 -1
- package/lib/typescript/src/RootDoorstepAI.d.ts +24 -7
- package/lib/typescript/src/RootDoorstepAI.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/DoorstepAI.tsx +425 -91
- package/src/RootDoorstepAI.tsx +75 -45
- package/src/index.tsx +6 -0
package/lib/module/DoorstepAI.js
CHANGED
|
@@ -27,37 +27,161 @@ const doorstepEventEmitter = DoorstepAI ? new NativeEventEmitter(DoorstepAI) : u
|
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* spelled
|
|
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
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
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
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
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
|
|
89
|
+
/** The evaluated state of one bucket. */
|
|
49
90
|
|
|
50
|
-
/**
|
|
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
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
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
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
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
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
182
|
-
*
|
|
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
|
-
*
|
|
189
|
-
*
|
|
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
|
-
*
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* `
|
|
202
|
-
*
|
|
203
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
388
|
+
* Accepts the array directly or the legacy `{ permissions: [...] }` object; the
|
|
389
|
+
* object form additionally carries `onlyIfNotDetermined` (iOS) and
|
|
390
|
+
* `timeoutSeconds`.
|
|
210
391
|
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
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
|
|
219
|
-
|
|
220
|
-
|
|
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
|
|
238
|
-
* `
|
|
239
|
-
*
|
|
240
|
-
*
|
|
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,CAAC;EACRC,QAAQ,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I,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,KAAK,EAAE;IAC3B,MAAM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O4D,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;AACA;AACA;;AA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,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
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//
|
|
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 ||
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
46
|
+
if (cancelled || backgroundPhaseSettled || !backgroundInScope) return;
|
|
30
47
|
try {
|
|
31
|
-
|
|
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
|
-
//
|
|
36
|
-
// (
|
|
37
|
-
|
|
38
|
-
|
|
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.
|
|
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;
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
//
|
|
71
|
-
//
|
|
72
|
-
|
|
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.
|