@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.
- package/README.md +267 -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 +10066 -6190
- 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 +3833 -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 +10066 -6190
- 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 +10066 -6190
- 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 +3833 -3248
- package/ios/DoorstepDropoffSDK.xcframework/ios-arm64_x86_64-simulator/dSYMs/DoorstepDropoffSDK.framework.dSYM/Contents/Resources/Relocations/x86_64/DoorstepDropoffSDK.yml +3802 -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/src/RootDoorstepAI.tsx
CHANGED
|
@@ -9,24 +9,41 @@ import {
|
|
|
9
9
|
import { useEffect } from 'react';
|
|
10
10
|
|
|
11
11
|
import { DoorstepAI } from './DoorstepAI';
|
|
12
|
+
import type { DoorstepPermissionInput } from './DoorstepAI';
|
|
12
13
|
|
|
13
14
|
const DoorstepAIView = requireNativeComponent('RootDoorstepAIView');
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Drop-in bootstrap: mount it once, near the root, and it runs the SDK's
|
|
18
|
+
* `init` + `setApiKey` and the permission sequence for you. Everything it does is
|
|
19
|
+
* available a la carte on {@link DoorstepAI} — this component exists so a host
|
|
20
|
+
* that just wants the default flow does not have to write it.
|
|
21
|
+
*/
|
|
15
22
|
export function RootDoorstepAI(props: {
|
|
16
23
|
apiKey: string;
|
|
17
24
|
notificationTitle?: string;
|
|
18
25
|
notificationText?: string;
|
|
19
26
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
27
|
+
* The whitelist handed to `requestPermissions`: **exactly these buckets are
|
|
28
|
+
* requested and nothing else.** Omit it to request every bucket the platform
|
|
29
|
+
* has, which is the SDK's own default.
|
|
30
|
+
*/
|
|
31
|
+
permissions?: DoorstepPermissionInput[];
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Pass a {@link permissions} whitelist instead — it can narrow any
|
|
34
|
+
* bucket, not just this one. Kept because it was the published prop: `false`
|
|
35
|
+
* drops the platform's Bluetooth bucket from the default whitelist. Ignored when
|
|
36
|
+
* `permissions` is given.
|
|
24
37
|
*/
|
|
25
38
|
requestBluetooth?: boolean;
|
|
26
39
|
/**
|
|
27
|
-
* Run the second-phase
|
|
28
|
-
*
|
|
29
|
-
*
|
|
40
|
+
* Run the second-phase background-location request (`locationAlways`) once
|
|
41
|
+
* foreground location has been granted. Default on.
|
|
42
|
+
*
|
|
43
|
+
* It has to be a second phase because Android forbids bundling background
|
|
44
|
+
* location with the foreground ask — a bundled request is auto-denied from
|
|
45
|
+
* Android 11 on. Turn it off if your app asks for "Allow all the time" from its
|
|
46
|
+
* own onboarding UI; without the grant the SDK cannot collect while
|
|
30
47
|
* backgrounded and route geofences fire foreground-only.
|
|
31
48
|
*/
|
|
32
49
|
requestBackgroundLocation?: boolean;
|
|
@@ -35,6 +52,7 @@ export function RootDoorstepAI(props: {
|
|
|
35
52
|
apiKey,
|
|
36
53
|
notificationTitle,
|
|
37
54
|
notificationText,
|
|
55
|
+
permissions,
|
|
38
56
|
requestBluetooth,
|
|
39
57
|
requestBackgroundLocation,
|
|
40
58
|
} = props;
|
|
@@ -43,32 +61,53 @@ export function RootDoorstepAI(props: {
|
|
|
43
61
|
let cancelled = false;
|
|
44
62
|
let backgroundPhaseSettled = false;
|
|
45
63
|
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
// The effective whitelist. `permissions` wins; `requestBluetooth: false` is
|
|
65
|
+
// expressed as "every bucket except this platform's BLE one", which is what
|
|
66
|
+
// the old two-boolean requester meant by it.
|
|
67
|
+
const whitelist: DoorstepPermissionInput[] | undefined =
|
|
68
|
+
permissions ??
|
|
69
|
+
(requestBluetooth === false
|
|
70
|
+
? DoorstepAI.allPermissionBuckets().filter(
|
|
71
|
+
(bucket) => bucket !== 'bluetooth' && bucket !== 'bluetoothScan'
|
|
72
|
+
)
|
|
73
|
+
: undefined);
|
|
74
|
+
|
|
75
|
+
// Whether background location is ours to ask for at all: the host can turn the
|
|
76
|
+
// phase off, and a whitelist that does not name the bucket must not have it
|
|
77
|
+
// added back behind the host's back.
|
|
78
|
+
const backgroundInScope =
|
|
79
|
+
requestBackgroundLocation !== false &&
|
|
80
|
+
(whitelist == null ||
|
|
81
|
+
whitelist.some((p) => p === 'locationAlways' || p === 'location'));
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Phase 2. `locationAlways` is only ever asked ALONE and only after foreground
|
|
85
|
+
* location is granted — the SDK enforces both rules and reports a refusal to
|
|
86
|
+
* ask rather than asking anyway, so this can be called optimistically. It is
|
|
87
|
+
* re-run on each foreground because on Android the foreground grant result is
|
|
88
|
+
* delivered to the Activity, not to JS.
|
|
89
|
+
*/
|
|
52
90
|
const runBackgroundLocationPhase = async () => {
|
|
53
|
-
if (
|
|
54
|
-
cancelled ||
|
|
55
|
-
backgroundPhaseSettled ||
|
|
56
|
-
Platform.OS !== 'android' ||
|
|
57
|
-
requestBackgroundLocation === false
|
|
58
|
-
) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
91
|
+
if (cancelled || backgroundPhaseSettled || !backgroundInScope) return;
|
|
61
92
|
try {
|
|
62
|
-
|
|
93
|
+
const { statuses } = await DoorstepAI.checkPermissions([
|
|
94
|
+
'locationWhenInUse',
|
|
95
|
+
'locationAlways',
|
|
96
|
+
]);
|
|
97
|
+
const always = statuses.locationAlways?.state;
|
|
98
|
+
if (always === 'granted') {
|
|
63
99
|
backgroundPhaseSettled = true;
|
|
64
100
|
return;
|
|
65
101
|
}
|
|
66
|
-
//
|
|
67
|
-
// (
|
|
68
|
-
|
|
69
|
-
|
|
102
|
+
// Foreground first: asking earlier spends the request on an automatic
|
|
103
|
+
// denial (Android) or shows the wrong prompt (iOS).
|
|
104
|
+
if (statuses.locationWhenInUse?.state !== 'granted') return;
|
|
105
|
+
// On iOS `whenInUseOnly` is a deliberate user choice and the SDK declines
|
|
106
|
+
// to re-prompt for it; the call is still made because native is the right
|
|
107
|
+
// place for that decision, and it comes back `deferred` rather than
|
|
108
|
+
// prompting.
|
|
70
109
|
backgroundPhaseSettled = true;
|
|
71
|
-
await DoorstepAI.
|
|
110
|
+
await DoorstepAI.requestPermissions(['locationAlways']);
|
|
72
111
|
} catch (err) {
|
|
73
112
|
console.warn('DOORSTEPAI - background location request failed:', err);
|
|
74
113
|
}
|
|
@@ -91,25 +130,15 @@ export function RootDoorstepAI(props: {
|
|
|
91
130
|
if (cancelled) return;
|
|
92
131
|
|
|
93
132
|
try {
|
|
94
|
-
// One requester for both platforms;
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
//
|
|
100
|
-
// `permissions` can only narrow Bluetooth (see `requestPermissions`), so
|
|
101
|
-
// `requestBluetooth === false` is expressed by omitting 'bluetooth' from
|
|
102
|
-
// the array; location and motion ride the base set either way.
|
|
103
|
-
const status = await DoorstepAI.requestPermissions(
|
|
104
|
-
requestBluetooth === false
|
|
105
|
-
? { permissions: ['location', 'motion'] }
|
|
106
|
-
: undefined
|
|
107
|
-
);
|
|
133
|
+
// One requester for both platforms; native dispatches. Safe at launch on
|
|
134
|
+
// iOS only because native defaults `onlyIfNotDetermined` to true: an
|
|
135
|
+
// already-answered permission is left alone, so this cannot re-escalate a
|
|
136
|
+
// user's "While Using the App" choice on every launch.
|
|
137
|
+
const { statuses } = await DoorstepAI.requestPermissions(whitelist);
|
|
108
138
|
if (cancelled) return;
|
|
109
|
-
//
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
if (status.permissions.location === 'granted') {
|
|
139
|
+
// Resolves only once the user has ANSWERED, so this state is final and
|
|
140
|
+
// phase 2 can run straight away instead of waiting for the next foreground.
|
|
141
|
+
if (statuses.locationWhenInUse?.state === 'granted') {
|
|
113
142
|
await runBackgroundLocationPhase();
|
|
114
143
|
}
|
|
115
144
|
} catch (err) {
|
|
@@ -127,6 +156,7 @@ export function RootDoorstepAI(props: {
|
|
|
127
156
|
apiKey,
|
|
128
157
|
notificationTitle,
|
|
129
158
|
notificationText,
|
|
159
|
+
permissions,
|
|
130
160
|
requestBluetooth,
|
|
131
161
|
requestBackgroundLocation,
|
|
132
162
|
]);
|
package/src/index.tsx
CHANGED
|
@@ -4,10 +4,16 @@ export type {
|
|
|
4
4
|
AddressType,
|
|
5
5
|
LatLngObject,
|
|
6
6
|
StartDeliveryOptions,
|
|
7
|
+
DoorstepPermission,
|
|
8
|
+
DoorstepPermissionAlias,
|
|
9
|
+
DoorstepPermissionInput,
|
|
10
|
+
DoorstepPermissionState,
|
|
11
|
+
DoorstepPermissionStatus,
|
|
7
12
|
PermissionState,
|
|
8
13
|
DoorstepPermissionType,
|
|
9
14
|
PermissionStatus,
|
|
10
15
|
PermissionRequestOptions,
|
|
16
|
+
PermissionRequestResult,
|
|
11
17
|
SDKLogLevel,
|
|
12
18
|
DeliveryStop,
|
|
13
19
|
RouteGeofenceOptions,
|