@bubblsdk/react-native-sdk 4.1.7 → 5.0.0-alpha.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/BubblReactNativeSdk.podspec +29 -9
- package/CHANGELOG.md +52 -1
- package/LICENSE +202 -1
- package/README.md +172 -83
- package/android/build.gradle +33 -30
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/tech/bubbl/reactnative/BubblJson.kt +135 -0
- package/android/src/main/java/tech/bubbl/reactnative/BubblSdkModule.kt +277 -0
- package/android/src/main/java/tech/bubbl/reactnative/BubblSdkPackage.kt +26 -0
- package/app.plugin.js +2 -0
- package/ios/BubblPush.swift +44 -0
- package/ios/BubblSdk.h +7 -0
- package/ios/BubblSdk.mm +252 -0
- package/ios/BubblSdkImpl.swift +335 -0
- package/ios-extension/BubblReactNativeNotificationService.podspec +44 -0
- package/ios-extension/Sources/BubblCore/API/ApiResponse.swift +90 -0
- package/ios-extension/Sources/BubblCore/API/CredentialStore.swift +116 -0
- package/ios-extension/Sources/BubblCore/API/DeviceApiClient.swift +239 -0
- package/ios-extension/Sources/BubblCore/API/ErrorActions.swift +68 -0
- package/ios-extension/Sources/BubblCore/API/Http.swift +39 -0
- package/ios-extension/Sources/BubblCore/API/ServerClock.swift +69 -0
- package/ios-extension/Sources/BubblCore/BubblVersion.swift +5 -0
- package/ios-extension/Sources/BubblCore/Device/ConfigSync.swift +216 -0
- package/ios-extension/Sources/BubblCore/Device/DeviceSync.swift +160 -0
- package/ios-extension/Sources/BubblCore/Device/ProvisioningProfile.swift +24 -0
- package/ios-extension/Sources/BubblCore/Engine/EngineCore.swift +523 -0
- package/ios-extension/Sources/BubblCore/Engine/Geofencing.swift +170 -0
- package/ios-extension/Sources/BubblCore/Engine/Permissions.swift +90 -0
- package/ios-extension/Sources/BubblCore/Engine/Privacy.swift +64 -0
- package/ios-extension/Sources/BubblCore/Engine/PrivacyControls.swift +184 -0
- package/ios-extension/Sources/BubblCore/Engine/Pushes.swift +61 -0
- package/ios-extension/Sources/BubblCore/Engine/Sandbox.swift +149 -0
- package/ios-extension/Sources/BubblCore/Events/EventQueue.swift +207 -0
- package/ios-extension/Sources/BubblCore/Events/EventStore.swift +159 -0
- package/ios-extension/Sources/BubblCore/Geofence/Geofence.swift +160 -0
- package/ios-extension/Sources/BubblCore/Geofence/GeofenceEngine.swift +488 -0
- package/ios-extension/Sources/BubblCore/Geofence/GeofenceState.swift +103 -0
- package/ios-extension/Sources/BubblCore/Geofence/RegionBudget.swift +62 -0
- package/ios-extension/Sources/BubblCore/Notification/BubblNotification.swift +137 -0
- package/ios-extension/Sources/BubblCore/Notification/NotificationEvents.swift +160 -0
- package/ios-extension/Sources/BubblCore/Notification/Push.swift +134 -0
- package/ios-extension/Sources/BubblCore/Notification/SurveyForm.swift +185 -0
- package/ios-extension/Sources/BubblCore/RequestSigner.swift +56 -0
- package/ios-extension/Sources/BubblCore/Support/AsyncMutex.swift +39 -0
- package/ios-extension/Sources/BubblCore/Support/BubblLog.swift +52 -0
- package/ios-extension/Sources/BubblCore/Support/JSON.swift +31 -0
- package/ios-extension/Sources/BubblCore/Support/JSONValue.swift +94 -0
- package/ios-extension/Sources/BubblCore/Support/Locking.swift +11 -0
- package/ios-extension/Sources/BubblCore/Support/ValueStore.swift +109 -0
- package/ios-extension/Sources/BubblNotificationService/BubblNotificationService.swift +124 -0
- package/ios-sdk/BubblCore/API/ApiResponse.swift +90 -0
- package/ios-sdk/BubblCore/API/CredentialStore.swift +116 -0
- package/ios-sdk/BubblCore/API/DeviceApiClient.swift +239 -0
- package/ios-sdk/BubblCore/API/ErrorActions.swift +68 -0
- package/ios-sdk/BubblCore/API/Http.swift +39 -0
- package/ios-sdk/BubblCore/API/ServerClock.swift +69 -0
- package/ios-sdk/BubblCore/BubblVersion.swift +5 -0
- package/ios-sdk/BubblCore/Device/ConfigSync.swift +216 -0
- package/ios-sdk/BubblCore/Device/DeviceSync.swift +160 -0
- package/ios-sdk/BubblCore/Device/ProvisioningProfile.swift +24 -0
- package/ios-sdk/BubblCore/Engine/EngineCore.swift +523 -0
- package/ios-sdk/BubblCore/Engine/Geofencing.swift +170 -0
- package/ios-sdk/BubblCore/Engine/Permissions.swift +90 -0
- package/ios-sdk/BubblCore/Engine/Privacy.swift +64 -0
- package/ios-sdk/BubblCore/Engine/PrivacyControls.swift +184 -0
- package/ios-sdk/BubblCore/Engine/Pushes.swift +61 -0
- package/ios-sdk/BubblCore/Engine/Sandbox.swift +149 -0
- package/ios-sdk/BubblCore/Events/EventQueue.swift +207 -0
- package/ios-sdk/BubblCore/Events/EventStore.swift +159 -0
- package/ios-sdk/BubblCore/Geofence/Geofence.swift +160 -0
- package/ios-sdk/BubblCore/Geofence/GeofenceEngine.swift +488 -0
- package/ios-sdk/BubblCore/Geofence/GeofenceState.swift +103 -0
- package/ios-sdk/BubblCore/Geofence/RegionBudget.swift +62 -0
- package/ios-sdk/BubblCore/Notification/BubblNotification.swift +137 -0
- package/ios-sdk/BubblCore/Notification/NotificationEvents.swift +160 -0
- package/ios-sdk/BubblCore/Notification/Push.swift +134 -0
- package/ios-sdk/BubblCore/Notification/SurveyForm.swift +185 -0
- package/ios-sdk/BubblCore/RequestSigner.swift +56 -0
- package/ios-sdk/BubblCore/Support/AsyncMutex.swift +39 -0
- package/ios-sdk/BubblCore/Support/BubblLog.swift +52 -0
- package/ios-sdk/BubblCore/Support/JSON.swift +31 -0
- package/ios-sdk/BubblCore/Support/JSONValue.swift +94 -0
- package/ios-sdk/BubblCore/Support/Locking.swift +11 -0
- package/ios-sdk/BubblCore/Support/ValueStore.swift +109 -0
- package/ios-sdk/BubblLaunch/BubblLaunch.m +45 -0
- package/ios-sdk/BubblLaunch/include/BubblLaunch.h +5 -0
- package/ios-sdk/BubblSDK/Bubbl.swift +308 -0
- package/ios-sdk/BubblSDK/BubblBackend.swift +118 -0
- package/ios-sdk/BubblSDK/BubblCredential.swift +30 -0
- package/ios-sdk/BubblSDK/BubblMessage.swift +151 -0
- package/ios-sdk/BubblSDK/BubblOptions.swift +39 -0
- package/ios-sdk/BubblSDK/BubblPermissions.swift +79 -0
- package/ios-sdk/BubblSDK/BubblTestDeviceResult.swift +10 -0
- package/ios-sdk/BubblSDK/Engine/BackgroundRefresh.swift +92 -0
- package/ios-sdk/BubblSDK/Engine/EngineHost+Geofences.swift +177 -0
- package/ios-sdk/BubblSDK/Engine/EngineHost+Privacy.swift +65 -0
- package/ios-sdk/BubblSDK/Engine/EngineHost+Push.swift +154 -0
- package/ios-sdk/BubblSDK/Engine/EngineHost.swift +356 -0
- package/ios-sdk/BubblSDK/Engine/SupportedBubbl.swift +320 -0
- package/ios-sdk/BubblSDK/Engine/SystemLog.swift +27 -0
- package/ios-sdk/BubblSDK/Engine/WorkRunner.swift +107 -0
- package/ios-sdk/BubblSDK/Notification/Look.swift +78 -0
- package/ios-sdk/BubblSDK/Notification/NotificationMedia.swift +329 -0
- package/ios-sdk/BubblSDK/Notification/NotificationModel.swift +172 -0
- package/ios-sdk/BubblSDK/Notification/NotificationScreen.swift +428 -0
- package/ios-sdk/BubblSDK/Notification/ScreenPresenter.swift +148 -0
- package/ios-sdk/BubblSDK/Permissions/PermissionFlow.swift +169 -0
- package/ios-sdk/BubblSDK/Permissions/PrivacyView.swift +110 -0
- package/ios-sdk/BubblSDK/Platform/AppleDevicePlatform.swift +95 -0
- package/ios-sdk/BubblSDK/Platform/KeychainCredentialStore.swift +114 -0
- package/ios-sdk/BubblSDK/Platform/LocationService.swift +418 -0
- package/ios-sdk/BubblSDK/Platform/PushIntegration.swift +288 -0
- package/ios-sdk/BubblSDK/Platform/URLSessionHttpClient.swift +69 -0
- package/ios-sdk/BubblSDK/PrivacyInfo.xcprivacy +76 -0
- package/jest/index.js +75 -0
- package/lib/commonjs/BubblModule.js +14 -0
- package/lib/commonjs/BubblModule.js.map +1 -0
- package/lib/commonjs/BubblModule.web.js +13 -0
- package/lib/commonjs/BubblModule.web.js.map +1 -0
- package/lib/commonjs/NativeBubblSdk.js +20 -0
- package/lib/commonjs/NativeBubblSdk.js.map +1 -0
- package/lib/commonjs/index.js +336 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/BubblModule.js +5 -0
- package/lib/module/BubblModule.js.map +1 -0
- package/lib/module/BubblModule.web.js +9 -0
- package/lib/module/BubblModule.web.js.map +1 -0
- package/lib/module/NativeBubblSdk.js +18 -0
- package/lib/module/NativeBubblSdk.js.map +1 -0
- package/lib/module/index.js +331 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/BubblModule.d.ts +3 -0
- package/lib/typescript/commonjs/src/BubblModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/BubblModule.web.d.ts +8 -0
- package/lib/typescript/commonjs/src/BubblModule.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NativeBubblSdk.d.ts +59 -0
- package/lib/typescript/commonjs/src/NativeBubblSdk.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +111 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +192 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/BubblModule.d.ts +3 -0
- package/lib/typescript/module/src/BubblModule.d.ts.map +1 -0
- package/lib/typescript/module/src/BubblModule.web.d.ts +8 -0
- package/lib/typescript/module/src/BubblModule.web.d.ts.map +1 -0
- package/lib/typescript/module/src/NativeBubblSdk.d.ts +59 -0
- package/lib/typescript/module/src/NativeBubblSdk.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +111 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +192 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/package.json +105 -24
- package/plugin/build/imageNotifications.d.ts +35 -0
- package/plugin/build/imageNotifications.js +198 -0
- package/plugin/build/index.d.ts +84 -0
- package/plugin/build/index.js +176 -0
- package/src/BubblModule.ts +2 -0
- package/src/BubblModule.web.ts +9 -0
- package/src/NativeBubblSdk.ts +67 -0
- package/src/index.ts +338 -282
- package/src/types.ts +182 -0
- package/android/src/main/kotlin/tech/bubbl/reactnative/BubblSdkModule.kt +0 -680
- package/android/src/main/kotlin/tech/bubbl/reactnative/BubblSdkNotificationIntents.kt +0 -32
- package/android/src/main/kotlin/tech/bubbl/reactnative/BubblSdkPackage.kt +0 -14
- package/ios/BubblSdk.swift +0 -802
- package/ios/BubblSdkBridge.m +0 -86
- package/react-native.config.js +0 -11
- package/src/specs/NativeBubblSdk.ts +0 -54
package/src/types.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public types, as in docs/PUBLIC_API.md: the same fields as the native SDKs' (iOS's names,
|
|
3
|
+
* lower camel), filled in natively and copied over as they are.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type LogLevel = 'none' | 'error' | 'warning' | 'info' | 'debug';
|
|
7
|
+
|
|
8
|
+
export type BubblOptions = {
|
|
9
|
+
/** The Bubbl API to talk to (https; http only for localhost, the emulator host or *.test). */
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
/** Nothing runs (no network, location or notifications) until setConsent(true). */
|
|
12
|
+
requireConsent?: boolean;
|
|
13
|
+
/** How much Bubbl logs natively (Logcat tag "BubblSDK", or the unified log). Default 'warning'. */
|
|
14
|
+
logLevel?: LogLevel;
|
|
15
|
+
/** The device's segments, as setSegments would set them. */
|
|
16
|
+
segments?: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A device credential issued outside the app, for startWithCredential: the same as the native
|
|
21
|
+
* SDKs' BubblCredential. Keep the secret out of logs and analytics; Bubbl only hands it to the
|
|
22
|
+
* native SDK, which keeps it in the Keychain / Android Keystore.
|
|
23
|
+
*/
|
|
24
|
+
export type BubblCredential = {
|
|
25
|
+
keyId: string;
|
|
26
|
+
secret: string;
|
|
27
|
+
/** The install the credential was issued for (a pairing flow passes the install id it paired with). */
|
|
28
|
+
installId: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type QuestionType =
|
|
32
|
+
| 'openEnded'
|
|
33
|
+
| 'singleChoice'
|
|
34
|
+
| 'multipleChoice'
|
|
35
|
+
| 'rating'
|
|
36
|
+
| 'boolean'
|
|
37
|
+
| 'number'
|
|
38
|
+
| 'slider';
|
|
39
|
+
|
|
40
|
+
export type BubblQuestion = {
|
|
41
|
+
id: string;
|
|
42
|
+
text: string;
|
|
43
|
+
type: QuestionType;
|
|
44
|
+
required: boolean;
|
|
45
|
+
choices: { id: string; text: string }[];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A notification from Bubbl, as the app's listener and events see it. Keep `json` (the whole
|
|
50
|
+
* notification as the device API sent it) to show it again later with present().
|
|
51
|
+
*/
|
|
52
|
+
export type BubblMessage = {
|
|
53
|
+
/** Echo this on anything reported about it. */
|
|
54
|
+
id: string;
|
|
55
|
+
headline: string;
|
|
56
|
+
body: string;
|
|
57
|
+
isSurvey: boolean;
|
|
58
|
+
/** Sent from a Sandbox workspace (a test, not a real campaign). */
|
|
59
|
+
isSandbox: boolean;
|
|
60
|
+
/** image, video, audio, youtube, application, text or file; null without media. */
|
|
61
|
+
mediaType: string | null;
|
|
62
|
+
mediaUrl: string | null;
|
|
63
|
+
mediaThumbnailUrl: string | null;
|
|
64
|
+
ctaLabel: string | null;
|
|
65
|
+
ctaUrl: string | null;
|
|
66
|
+
/** A survey's questions in order (empty for a message). */
|
|
67
|
+
questions: BubblQuestion[];
|
|
68
|
+
json: string;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Answers to a survey by question id: singleChoice a choice id; multipleChoice a list of choice
|
|
73
|
+
* ids; rating a whole number 1–5; boolean true/false; number a number; slider 0–10; openEnded
|
|
74
|
+
* text (at most 2000 characters).
|
|
75
|
+
*/
|
|
76
|
+
export type SurveyAnswers = Record<string, string | string[] | number | boolean | null>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A Sandbox test device: 'pending' until someone approves it (in the dashboard with `code`, or with
|
|
80
|
+
* Bubbl.registerTestDevice), then 'approved'.
|
|
81
|
+
*/
|
|
82
|
+
export type BubblTestDevice = {
|
|
83
|
+
status: 'pending' | 'approved';
|
|
84
|
+
/** While pending: the short code the dashboard lists this device under (e.g. K7Q-2MX). */
|
|
85
|
+
code?: string;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/** What Bubbl.registerTestDevice came to. */
|
|
89
|
+
export type BubblTestDeviceResult = {
|
|
90
|
+
approved: boolean;
|
|
91
|
+
/** Why not, when not approved (a wrong or expired code, no network, before start). */
|
|
92
|
+
message?: string;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type BubblPermissionStatus = {
|
|
96
|
+
notifications: 'granted' | 'denied' | 'notDetermined';
|
|
97
|
+
location: 'always' | 'whenInUse' | 'denied' | 'notDetermined';
|
|
98
|
+
/** Fine rather than approximate location. */
|
|
99
|
+
preciseLocation: boolean;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* What Bubbl tells the app, by `type`. Events grow in minor versions (a new `type`, never a changed
|
|
104
|
+
* one), so a `switch (event.type)` needs a `default` branch for types it doesn't know yet.
|
|
105
|
+
*/
|
|
106
|
+
export type BubblEvent =
|
|
107
|
+
| { type: 'notification.received'; message: BubblMessage }
|
|
108
|
+
| { type: 'notification.displayed'; message: BubblMessage }
|
|
109
|
+
| { type: 'notification.opened'; message: BubblMessage }
|
|
110
|
+
| { type: 'notification.cta_clicked'; message: BubblMessage }
|
|
111
|
+
| { type: 'notification.dismissed'; message: BubblMessage }
|
|
112
|
+
| { type: 'media.viewed'; message: BubblMessage }
|
|
113
|
+
| { type: 'media.completed'; message: BubblMessage }
|
|
114
|
+
| { type: 'survey.started'; message: BubblMessage }
|
|
115
|
+
| { type: 'survey.submitted'; message: BubblMessage }
|
|
116
|
+
| { type: 'geofence.entered'; locationId: string }
|
|
117
|
+
| { type: 'geofence.exited'; locationId: string }
|
|
118
|
+
| { type: 'error'; message: string }
|
|
119
|
+
/**
|
|
120
|
+
* Bubbl was started with a credential issued outside the app, and the server refused it: Bubbl
|
|
121
|
+
* has stopped until it's started with a new one. (Android now; iOS when its SDK has it.)
|
|
122
|
+
*/
|
|
123
|
+
| { type: 'credential.rejected' };
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Where Bubbl stands on this device, for support and debug screens: the fields both platforms
|
|
127
|
+
* have, then each platform's own (null on the other platform).
|
|
128
|
+
*/
|
|
129
|
+
export type BubblDiagnostics = {
|
|
130
|
+
started: boolean;
|
|
131
|
+
sdkVersion: string;
|
|
132
|
+
/** Bubbl works on this device (iOS 17 and later, Android 8.1 and later): Bubbl.isSupported. */
|
|
133
|
+
supported: boolean;
|
|
134
|
+
/** False when the workspace requires a newer SDK. */
|
|
135
|
+
sdkSupported: boolean;
|
|
136
|
+
registered: boolean;
|
|
137
|
+
/** The install id Bubbl keeps (how Dashboard › Active users finds this device); null before there is one. */
|
|
138
|
+
installId: string | null;
|
|
139
|
+
/** Running: started, consent allows it, not paused by the server, supported. */
|
|
140
|
+
active: boolean;
|
|
141
|
+
/** Unix seconds until which the server paused Bubbl, if it has. */
|
|
142
|
+
pausedUntil: number | null;
|
|
143
|
+
consentRequired: boolean;
|
|
144
|
+
consent: boolean | null;
|
|
145
|
+
locationEnabled: boolean;
|
|
146
|
+
permissions: BubblPermissionStatus | null;
|
|
147
|
+
hasPushToken: boolean;
|
|
148
|
+
geofences: number;
|
|
149
|
+
queuedEvents: number;
|
|
150
|
+
lastError: string | null;
|
|
151
|
+
/** Started with a credential issued outside the app, which the server refused. */
|
|
152
|
+
credentialRejected: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* The workspace the key belongs to: 'sandbox' (pk_test_) or 'production' (pk_live_); null before
|
|
155
|
+
* the device has registered.
|
|
156
|
+
*/
|
|
157
|
+
environment: 'sandbox' | 'production' | null;
|
|
158
|
+
/** In Sandbox, where this device stands as a test device; null in Production. */
|
|
159
|
+
testDevice: BubblTestDevice | null;
|
|
160
|
+
/** Geofences work with the app closed ("Always" location). */
|
|
161
|
+
backgroundLocation: boolean;
|
|
162
|
+
/** Geofence events lost before the first unlock after a reboot (always 0 on Android). */
|
|
163
|
+
transitionsDroppedWhileLocked: number;
|
|
164
|
+
/** Android: the user restricted the app's background activity. */
|
|
165
|
+
backgroundRestricted: boolean | null;
|
|
166
|
+
/** Android: battery optimisation applies (background work may wait in Doze). */
|
|
167
|
+
batteryOptimized: boolean | null;
|
|
168
|
+
/** iOS: Background App Refresh is on for the app. */
|
|
169
|
+
backgroundRefreshAvailable: boolean | null;
|
|
170
|
+
/** iOS: Low Power Mode is on. */
|
|
171
|
+
lowPowerMode: boolean | null;
|
|
172
|
+
/** iOS: the OS watches the geofences (else they're checked from location changes). */
|
|
173
|
+
osWatchesGeofences: boolean | null;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/** Return true (or a promise of true) to show the message yourself; false lets Bubbl show it. */
|
|
177
|
+
export type NotificationListener = (message: BubblMessage) => boolean | Promise<boolean>;
|
|
178
|
+
|
|
179
|
+
export type EventListener = (event: BubblEvent) => void;
|
|
180
|
+
|
|
181
|
+
/** What addEventListener returns: call remove() to stop listening. */
|
|
182
|
+
export type Subscription = { remove(): void };
|