@bubblsdk/react-native-sdk 4.1.7 → 5.0.0-alpha.1

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 (176) hide show
  1. package/BubblReactNativeSdk.podspec +29 -9
  2. package/CHANGELOG.md +47 -0
  3. package/LICENSE +202 -1
  4. package/README.md +172 -83
  5. package/android/build.gradle +33 -30
  6. package/android/src/main/AndroidManifest.xml +1 -0
  7. package/android/src/main/java/tech/bubbl/reactnative/BubblJson.kt +135 -0
  8. package/android/src/main/java/tech/bubbl/reactnative/BubblSdkModule.kt +277 -0
  9. package/android/src/main/java/tech/bubbl/reactnative/BubblSdkPackage.kt +26 -0
  10. package/app.plugin.js +2 -0
  11. package/ios/BubblPush.swift +44 -0
  12. package/ios/BubblSdk.h +7 -0
  13. package/ios/BubblSdk.mm +252 -0
  14. package/ios/BubblSdkImpl.swift +335 -0
  15. package/ios-extension/BubblReactNativeNotificationService.podspec +44 -0
  16. package/ios-extension/Sources/BubblCore/API/ApiResponse.swift +90 -0
  17. package/ios-extension/Sources/BubblCore/API/CredentialStore.swift +116 -0
  18. package/ios-extension/Sources/BubblCore/API/DeviceApiClient.swift +239 -0
  19. package/ios-extension/Sources/BubblCore/API/ErrorActions.swift +68 -0
  20. package/ios-extension/Sources/BubblCore/API/Http.swift +39 -0
  21. package/ios-extension/Sources/BubblCore/API/ServerClock.swift +69 -0
  22. package/ios-extension/Sources/BubblCore/BubblVersion.swift +5 -0
  23. package/ios-extension/Sources/BubblCore/Device/ConfigSync.swift +216 -0
  24. package/ios-extension/Sources/BubblCore/Device/DeviceSync.swift +160 -0
  25. package/ios-extension/Sources/BubblCore/Device/ProvisioningProfile.swift +24 -0
  26. package/ios-extension/Sources/BubblCore/Engine/EngineCore.swift +523 -0
  27. package/ios-extension/Sources/BubblCore/Engine/Geofencing.swift +170 -0
  28. package/ios-extension/Sources/BubblCore/Engine/Permissions.swift +90 -0
  29. package/ios-extension/Sources/BubblCore/Engine/Privacy.swift +64 -0
  30. package/ios-extension/Sources/BubblCore/Engine/PrivacyControls.swift +184 -0
  31. package/ios-extension/Sources/BubblCore/Engine/Pushes.swift +61 -0
  32. package/ios-extension/Sources/BubblCore/Engine/Sandbox.swift +149 -0
  33. package/ios-extension/Sources/BubblCore/Events/EventQueue.swift +207 -0
  34. package/ios-extension/Sources/BubblCore/Events/EventStore.swift +159 -0
  35. package/ios-extension/Sources/BubblCore/Geofence/Geofence.swift +160 -0
  36. package/ios-extension/Sources/BubblCore/Geofence/GeofenceEngine.swift +488 -0
  37. package/ios-extension/Sources/BubblCore/Geofence/GeofenceState.swift +103 -0
  38. package/ios-extension/Sources/BubblCore/Geofence/RegionBudget.swift +62 -0
  39. package/ios-extension/Sources/BubblCore/Notification/BubblNotification.swift +137 -0
  40. package/ios-extension/Sources/BubblCore/Notification/NotificationEvents.swift +160 -0
  41. package/ios-extension/Sources/BubblCore/Notification/Push.swift +134 -0
  42. package/ios-extension/Sources/BubblCore/Notification/SurveyForm.swift +185 -0
  43. package/ios-extension/Sources/BubblCore/RequestSigner.swift +56 -0
  44. package/ios-extension/Sources/BubblCore/Support/AsyncMutex.swift +39 -0
  45. package/ios-extension/Sources/BubblCore/Support/BubblLog.swift +52 -0
  46. package/ios-extension/Sources/BubblCore/Support/JSON.swift +31 -0
  47. package/ios-extension/Sources/BubblCore/Support/JSONValue.swift +94 -0
  48. package/ios-extension/Sources/BubblCore/Support/Locking.swift +11 -0
  49. package/ios-extension/Sources/BubblCore/Support/ValueStore.swift +109 -0
  50. package/ios-extension/Sources/BubblNotificationService/BubblNotificationService.swift +124 -0
  51. package/ios-sdk/BubblCore/API/ApiResponse.swift +90 -0
  52. package/ios-sdk/BubblCore/API/CredentialStore.swift +116 -0
  53. package/ios-sdk/BubblCore/API/DeviceApiClient.swift +239 -0
  54. package/ios-sdk/BubblCore/API/ErrorActions.swift +68 -0
  55. package/ios-sdk/BubblCore/API/Http.swift +39 -0
  56. package/ios-sdk/BubblCore/API/ServerClock.swift +69 -0
  57. package/ios-sdk/BubblCore/BubblVersion.swift +5 -0
  58. package/ios-sdk/BubblCore/Device/ConfigSync.swift +216 -0
  59. package/ios-sdk/BubblCore/Device/DeviceSync.swift +160 -0
  60. package/ios-sdk/BubblCore/Device/ProvisioningProfile.swift +24 -0
  61. package/ios-sdk/BubblCore/Engine/EngineCore.swift +523 -0
  62. package/ios-sdk/BubblCore/Engine/Geofencing.swift +170 -0
  63. package/ios-sdk/BubblCore/Engine/Permissions.swift +90 -0
  64. package/ios-sdk/BubblCore/Engine/Privacy.swift +64 -0
  65. package/ios-sdk/BubblCore/Engine/PrivacyControls.swift +184 -0
  66. package/ios-sdk/BubblCore/Engine/Pushes.swift +61 -0
  67. package/ios-sdk/BubblCore/Engine/Sandbox.swift +149 -0
  68. package/ios-sdk/BubblCore/Events/EventQueue.swift +207 -0
  69. package/ios-sdk/BubblCore/Events/EventStore.swift +159 -0
  70. package/ios-sdk/BubblCore/Geofence/Geofence.swift +160 -0
  71. package/ios-sdk/BubblCore/Geofence/GeofenceEngine.swift +488 -0
  72. package/ios-sdk/BubblCore/Geofence/GeofenceState.swift +103 -0
  73. package/ios-sdk/BubblCore/Geofence/RegionBudget.swift +62 -0
  74. package/ios-sdk/BubblCore/Notification/BubblNotification.swift +137 -0
  75. package/ios-sdk/BubblCore/Notification/NotificationEvents.swift +160 -0
  76. package/ios-sdk/BubblCore/Notification/Push.swift +134 -0
  77. package/ios-sdk/BubblCore/Notification/SurveyForm.swift +185 -0
  78. package/ios-sdk/BubblCore/RequestSigner.swift +56 -0
  79. package/ios-sdk/BubblCore/Support/AsyncMutex.swift +39 -0
  80. package/ios-sdk/BubblCore/Support/BubblLog.swift +52 -0
  81. package/ios-sdk/BubblCore/Support/JSON.swift +31 -0
  82. package/ios-sdk/BubblCore/Support/JSONValue.swift +94 -0
  83. package/ios-sdk/BubblCore/Support/Locking.swift +11 -0
  84. package/ios-sdk/BubblCore/Support/ValueStore.swift +109 -0
  85. package/ios-sdk/BubblLaunch/BubblLaunch.m +45 -0
  86. package/ios-sdk/BubblLaunch/include/BubblLaunch.h +5 -0
  87. package/ios-sdk/BubblSDK/Bubbl.swift +308 -0
  88. package/ios-sdk/BubblSDK/BubblBackend.swift +118 -0
  89. package/ios-sdk/BubblSDK/BubblCredential.swift +30 -0
  90. package/ios-sdk/BubblSDK/BubblMessage.swift +151 -0
  91. package/ios-sdk/BubblSDK/BubblOptions.swift +39 -0
  92. package/ios-sdk/BubblSDK/BubblPermissions.swift +77 -0
  93. package/ios-sdk/BubblSDK/BubblTestDeviceResult.swift +10 -0
  94. package/ios-sdk/BubblSDK/Engine/BackgroundRefresh.swift +92 -0
  95. package/ios-sdk/BubblSDK/Engine/EngineHost+Geofences.swift +177 -0
  96. package/ios-sdk/BubblSDK/Engine/EngineHost+Privacy.swift +65 -0
  97. package/ios-sdk/BubblSDK/Engine/EngineHost+Push.swift +154 -0
  98. package/ios-sdk/BubblSDK/Engine/EngineHost.swift +356 -0
  99. package/ios-sdk/BubblSDK/Engine/SupportedBubbl.swift +318 -0
  100. package/ios-sdk/BubblSDK/Engine/SystemLog.swift +27 -0
  101. package/ios-sdk/BubblSDK/Engine/WorkRunner.swift +107 -0
  102. package/ios-sdk/BubblSDK/Notification/Look.swift +78 -0
  103. package/ios-sdk/BubblSDK/Notification/NotificationMedia.swift +329 -0
  104. package/ios-sdk/BubblSDK/Notification/NotificationModel.swift +172 -0
  105. package/ios-sdk/BubblSDK/Notification/NotificationScreen.swift +428 -0
  106. package/ios-sdk/BubblSDK/Notification/ScreenPresenter.swift +148 -0
  107. package/ios-sdk/BubblSDK/Permissions/PermissionFlow.swift +167 -0
  108. package/ios-sdk/BubblSDK/Permissions/PrivacyView.swift +110 -0
  109. package/ios-sdk/BubblSDK/Platform/AppleDevicePlatform.swift +95 -0
  110. package/ios-sdk/BubblSDK/Platform/KeychainCredentialStore.swift +114 -0
  111. package/ios-sdk/BubblSDK/Platform/LocationService.swift +418 -0
  112. package/ios-sdk/BubblSDK/Platform/PushIntegration.swift +288 -0
  113. package/ios-sdk/BubblSDK/Platform/URLSessionHttpClient.swift +69 -0
  114. package/ios-sdk/BubblSDK/PrivacyInfo.xcprivacy +76 -0
  115. package/jest/index.js +75 -0
  116. package/lib/commonjs/BubblModule.js +14 -0
  117. package/lib/commonjs/BubblModule.js.map +1 -0
  118. package/lib/commonjs/BubblModule.web.js +13 -0
  119. package/lib/commonjs/BubblModule.web.js.map +1 -0
  120. package/lib/commonjs/NativeBubblSdk.js +20 -0
  121. package/lib/commonjs/NativeBubblSdk.js.map +1 -0
  122. package/lib/commonjs/index.js +336 -0
  123. package/lib/commonjs/index.js.map +1 -0
  124. package/lib/commonjs/package.json +1 -0
  125. package/lib/commonjs/types.js +2 -0
  126. package/lib/commonjs/types.js.map +1 -0
  127. package/lib/module/BubblModule.js +5 -0
  128. package/lib/module/BubblModule.js.map +1 -0
  129. package/lib/module/BubblModule.web.js +9 -0
  130. package/lib/module/BubblModule.web.js.map +1 -0
  131. package/lib/module/NativeBubblSdk.js +18 -0
  132. package/lib/module/NativeBubblSdk.js.map +1 -0
  133. package/lib/module/index.js +331 -0
  134. package/lib/module/index.js.map +1 -0
  135. package/lib/module/package.json +1 -0
  136. package/lib/module/types.js +2 -0
  137. package/lib/module/types.js.map +1 -0
  138. package/lib/typescript/commonjs/package.json +1 -0
  139. package/lib/typescript/commonjs/src/BubblModule.d.ts +3 -0
  140. package/lib/typescript/commonjs/src/BubblModule.d.ts.map +1 -0
  141. package/lib/typescript/commonjs/src/BubblModule.web.d.ts +8 -0
  142. package/lib/typescript/commonjs/src/BubblModule.web.d.ts.map +1 -0
  143. package/lib/typescript/commonjs/src/NativeBubblSdk.d.ts +59 -0
  144. package/lib/typescript/commonjs/src/NativeBubblSdk.d.ts.map +1 -0
  145. package/lib/typescript/commonjs/src/index.d.ts +111 -0
  146. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  147. package/lib/typescript/commonjs/src/types.d.ts +192 -0
  148. package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
  149. package/lib/typescript/module/package.json +1 -0
  150. package/lib/typescript/module/src/BubblModule.d.ts +3 -0
  151. package/lib/typescript/module/src/BubblModule.d.ts.map +1 -0
  152. package/lib/typescript/module/src/BubblModule.web.d.ts +8 -0
  153. package/lib/typescript/module/src/BubblModule.web.d.ts.map +1 -0
  154. package/lib/typescript/module/src/NativeBubblSdk.d.ts +59 -0
  155. package/lib/typescript/module/src/NativeBubblSdk.d.ts.map +1 -0
  156. package/lib/typescript/module/src/index.d.ts +111 -0
  157. package/lib/typescript/module/src/index.d.ts.map +1 -0
  158. package/lib/typescript/module/src/types.d.ts +192 -0
  159. package/lib/typescript/module/src/types.d.ts.map +1 -0
  160. package/package.json +105 -24
  161. package/plugin/build/imageNotifications.d.ts +35 -0
  162. package/plugin/build/imageNotifications.js +198 -0
  163. package/plugin/build/index.d.ts +84 -0
  164. package/plugin/build/index.js +176 -0
  165. package/src/BubblModule.ts +2 -0
  166. package/src/BubblModule.web.ts +9 -0
  167. package/src/NativeBubblSdk.ts +67 -0
  168. package/src/index.ts +338 -282
  169. package/src/types.ts +182 -0
  170. package/android/src/main/kotlin/tech/bubbl/reactnative/BubblSdkModule.kt +0 -680
  171. package/android/src/main/kotlin/tech/bubbl/reactnative/BubblSdkNotificationIntents.kt +0 -32
  172. package/android/src/main/kotlin/tech/bubbl/reactnative/BubblSdkPackage.kt +0 -14
  173. package/ios/BubblSdk.swift +0 -802
  174. package/ios/BubblSdkBridge.m +0 -86
  175. package/react-native.config.js +0 -11
  176. package/src/specs/NativeBubblSdk.ts +0 -54
@@ -1,17 +1,37 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ # The iOS side of @bubblsdk/react-native-sdk: the TurboModule (ios/) and the Bubbl iOS SDK it
6
+ # drives, built together as one module. The SDK's sources (BubblCore, BubblSDK and BubblLaunch)
7
+ # are carried in the package, in ios-sdk/, copied from renewed-sdk/ios by
8
+ # scripts/sync-ios-sources.mjs: there's no BubblSDK pod for 5.0 (CocoaPods trunk goes read-only).
1
9
  Pod::Spec.new do |s|
2
10
  s.name = 'BubblReactNativeSdk'
3
- s.version = '4.1.7'
4
- s.summary = 'React Native wrapper for Bubbl SDK v3 native Android and iOS cores.'
11
+ s.version = package['version']
12
+ s.summary = 'Bubbl for React Native: geofenced and scheduled notifications, surveys and analytics.'
5
13
  s.homepage = 'https://bubbl.tech'
6
- s.license = { :type => 'Commercial', :text => 'Copyright Bubbl. All rights reserved.' }
14
+ s.license = { :type => 'Apache-2.0', :file => 'LICENSE' }
7
15
  s.author = { 'Bubbl' => 'engineering@bubbl.tech' }
8
- s.source = { :git => 'https://github.com/bubbl-platform/renewed-sdk.git', :tag => s.version.to_s }
16
+ s.source = { :git => 'https://github.com/bubbl-platform/renewed-sdk.git', :tag => "v#{s.version}" }
9
17
 
10
- s.platform = :ios, '15.0'
18
+ # iOS 13 and up install it (React Native's own floor, when its Podfile helper is loaded); Bubbl
19
+ # runs on iOS 17 and up and does nothing below (Bubbl.isSupported).
20
+ s.platforms = { :ios => defined?(min_ios_version_supported) ? min_ios_version_supported : '13.0' }
11
21
  s.swift_version = '5.9'
12
- s.source_files = 'ios/**/*.{h,m,mm,swift}'
13
- s.static_framework = true
22
+ s.source_files = 'ios/**/*.{h,m,mm,swift}', 'ios-sdk/**/*.{h,m,swift}'
23
+ # BubblLaunch's C function, called from the SDK's Swift in the same module.
24
+ s.public_header_files = 'ios-sdk/BubblLaunch/include/*.h'
25
+ # The iOS SDK's privacy manifest (what its Swift package ships as a resource), in a bundle of its
26
+ # own so Xcode's privacy report finds it in the app.
27
+ s.resource_bundles = { 'BubblSDKPrivacy' => ['ios-sdk/BubblSDK/PrivacyInfo.xcprivacy'] }
28
+ s.frameworks = 'CoreLocation', 'UserNotifications', 'UIKit', 'Security'
29
+ # The SDK's parts share `package` declarations, built here as one module.
30
+ s.pod_target_xcconfig = {
31
+ 'DEFINES_MODULE' => 'YES',
32
+ 'OTHER_SWIFT_FLAGS' => '$(inherited) -package-name BubblReactNativeSdk',
33
+ }
14
34
 
15
- s.dependency 'React-Core'
16
- s.dependency 'BubblSDK', '4.1.7'
35
+ # React Native's dependencies for a TurboModule (the app's react_native_pods.rb).
36
+ install_modules_dependencies(s)
17
37
  end
package/CHANGELOG.md CHANGED
@@ -2,6 +2,53 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - New v5 wrapper, replacing the 4.x one: a TurboModule (React Native 0.76+, New Architecture)
6
+ with the public API of docs/PUBLIC_API.md — `start(apiKey, options)`, consent and privacy,
7
+ `permissions`, `setSegments`, `track`, events, the notification listener, the report functions,
8
+ `submitSurvey`, `openCta`, `isBubblMessage` and `diagnostics`, and the `credential.rejected` event
9
+ on both platforms. JSON crosses the bridge, in the same shapes as the
10
+ Flutter wrapper.
11
+ - Android over `tech.bubbl.sdk:bubbl-sdk` 5.x.
12
+ - iOS over the Bubbl iOS SDK, built into the package's pod from its sources (no BubblSDK pod in
13
+ 5.0).
14
+ - `startWithCredential({ keyId, secret, installId }, options)`: start with a device credential issued
15
+ outside the app instead of an API key. The secret crosses the bridge as its own argument, never
16
+ in JSON, and nothing logs it.
17
+ - Diagnostics include `installId` and `credentialRejected` on both platforms, and `permissions` on
18
+ iOS too.
19
+ - An Expo config plugin (`app.plugin.js`): the push
20
+ entitlement and location usage strings, and optional plain http for development. Expo SDK 52
21
+ or later.
22
+ - Where there's no native module (the web, Expo Go, Jest, a build from before the install), calls
23
+ do nothing and say why once in the console (the old architecture named as such), instead of
24
+ throwing; `diagnostics()` resolves as not started, the reason in `lastError`.
25
+ Importing the package on the web no longer breaks the bundle.
26
+ - The notification listener never loses one: a notification handed to JS that JS doesn't take
27
+ (a reload, a stuck JS thread) is shown by Bubbl, and a React host going away (a headless one, a
28
+ second screen) only clears the listener its own JS set.
29
+ - The Expo plugin also raises the app target's own `IPHONEOS_DEPLOYMENT_TARGET` to 17 (a higher
30
+ one is kept).
31
+ - Expo: `ios.backgroundRefresh` adds the iOS SDK's background refresh task and the `fetch`
32
+ background mode to Info.plist.
33
+ - Installs on older OS versions too (iOS 13 and Android 6 as floors, React Native's own apply):
34
+ `Bubbl.isSupported` and `diagnostics().supported` say whether Bubbl runs here (iOS 17 and Android
35
+ 8.1 and later); below, every call does nothing. The config plugin no longer raises minSdk to 27 or
36
+ the iOS deployment target to 17 (only a value set below 23 / 13).
37
+ - Sandbox: `registerTestDevice(code)` → `{ approved, message? }`; `diagnostics()` `environment`
38
+ ('sandbox' | 'production' | null) and `testDevice` (`{ status, code? }` | null); `isSandbox` on messages.
39
+ - A Jest mock: `jest.mock('@bubblsdk/react-native-sdk', () => require('@bubblsdk/react-native-sdk/jest'))`.
40
+ - iOS: `BubblReactNativeNotificationService` (in `ios-extension/`), the iOS SDK's
41
+ `BubblNotificationService` for an app's Notification Service Extension (pictures on pushes);
42
+ `BubblPush`, the push hand-overs for an Objective-C AppDelegate.
43
+ - Expo: `ios.imageNotifications` in the config plugin adds that extension at prebuild (the
44
+ target, its Podfile target and its EAS Build `appExtensions` entry).
45
+
46
+ ## 5.0.0-alpha.1
47
+
48
+ - Start of SDK v5, built against Bubbl's device API v1. Pre-release: not for
49
+ production apps. The wrapper surface is unchanged in this alpha; the native
50
+ engines move to the new API in later alphas.
51
+
5
52
  ## 4.1.7
6
53
 
7
54
  - Aligns the React Native wrapper with the native SDK 4.1.7 release
package/LICENSE CHANGED
@@ -1 +1,202 @@
1
- Copyright Bubbl. All rights reserved.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,129 +1,218 @@
1
- # Bubbl React Native SDK
1
+ # @bubblsdk/react-native-sdk
2
2
 
3
- React Native wrapper for Bubbl SDK v3.
3
+ Bubbl for React Native: geofenced and scheduled notifications, surveys and analytics. A thin
4
+ TurboModule over the native Bubbl SDKs (Android `tech.bubbl.sdk:bubbl-sdk`, iOS `BubblSDK`),
5
+ with the same functions as [docs/PUBLIC_API.md](../docs/PUBLIC_API.md) and the Flutter wrapper.
4
6
 
5
- The JavaScript facade forwards calls to the native Android and iOS SDK cores. Native runtime behavior, durable ingest queues, geofence transitions, notification triggering, Firebase/APNs payload handling, and diagnostics are owned by the platform SDKs.
7
+ > 5.0 pre-release: the whole API works on Android and iOS. The
8
+ > Android SDK 5.0 isn't on Maven Central yet: until it is, an Android build needs it in `~/.m2`
9
+ > and `mavenLocal()` in the app's repositories (see Develop).
10
+
11
+ Requires React Native 0.76 or later (the New Architecture) or Expo SDK 52 or later. It installs on
12
+ every Android and iOS version those support; Bubbl runs on Android 8.1 (API 27) and iOS 17 and
13
+ later, and on older ones `Bubbl.isSupported` is false and every call does nothing (permissions give
14
+ null, diagnostics say `supported: false`). Expo SDK 57's own modules need Xcode 26.4 or later to build for
15
+ iOS; Android builds want JDK 17.
6
16
 
7
17
  ## Install
8
18
 
9
- ```bash
10
- npm install @bubblsdk/react-native-sdk
19
+ 5.0 is in alpha, on npm's `alpha` tag: install it by that tag (plain `npm install` still gets
20
+ 4.x, the `latest` tag, until 5.0 is released).
21
+
22
+ ```sh
23
+ npm install @bubblsdk/react-native-sdk@alpha
24
+ npx expo install @bubblsdk/react-native-sdk@alpha # Expo
11
25
  ```
12
26
 
13
- ## Boot
27
+ An alpha can change between releases; pin the exact version (`5.0.0-alpha.1`) in `package.json`
28
+ for repeatable builds. The steps below are otherwise the same.
14
29
 
15
- ```ts
16
- import { Bubbl } from '@bubblsdk/react-native-sdk';
30
+ ### Expo (prebuild)
17
31
 
18
- await Bubbl.boot({ apiKey: '...' });
32
+ ```sh
33
+ npx expo install @bubblsdk/react-native-sdk
19
34
  ```
20
35
 
21
- Enable SDK-owned location/background processing when the host app has collected
22
- location permission:
36
+ ```json
37
+ { "expo": { "plugins": ["@bubblsdk/react-native-sdk"] } }
38
+ ```
23
39
 
24
- ```ts
25
- await Bubbl.boot({
26
- apiKey: '...',
27
- enableLocationTracking: true,
28
- });
40
+ Then `npx expo prebuild` (or an EAS build). Expo Go can't load native modules. The plugin adds the push
41
+ entitlement (`aps-environment`) and the location usage strings (yours, when set, or
42
+ Bubbl's defaults). Options:
43
+
44
+ ```json
45
+ ["@bubblsdk/react-native-sdk", {
46
+ "ios": {
47
+ "locationWhenInUse": "…", "locationAlways": "…", "apsEnvironment": "development",
48
+ "imageNotifications": true, "backgroundRefresh": true
49
+ },
50
+ "android": { "cleartextHosts": ["10.0.2.2"] }
51
+ }]
52
+ ```
53
+
54
+ `ios.backgroundRefresh` lets iOS wake the app now and then so Bubbl sends what's queued (it adds
55
+ `tech.bubbl.sdk.refresh` to `BGTaskSchedulerPermittedIdentifiers` and `fetch` to `UIBackgroundModes`;
56
+ React Native CLI apps add the same two to Info.plist). `ios.imageNotifications` is below.
57
+
58
+ For development against a local API over plain http: `android.cleartextHosts` and
59
+ `ios.allowLocalNetworking: true` (leave both out of release builds).
29
60
 
30
- await Bubbl.startLocationTracking();
61
+ ### React Native CLI
62
+
63
+ ```sh
64
+ npm install @bubblsdk/react-native-sdk
31
65
  ```
32
66
 
33
- The SDK owns the native background mechanics once enabled: Android uses the
34
- bundled foreground location service and WorkManager restore/refresh path, and
35
- iOS uses the bundled CoreLocation monitor. The host app still owns platform
36
- declarations and runtime permission UX.
67
+ Android: nothing to add; what Bubbl needs (permissions, receivers, its screens) comes from the
68
+ SDK's manifest.
69
+
70
+ iOS: `pod install`, then add the Push Notifications
71
+ capability, and `NSLocationWhenInUseUsageDescription` and
72
+ `NSLocationAlwaysAndWhenInUseUsageDescription` to Info.plist. The Bubbl iOS SDK is built into
73
+ this package's pod; there's nothing else to add.
37
74
 
38
- For iOS background geofence cold starts, forward launch options from your
39
- `AppDelegate` before the React Native bridge or JavaScript UI is mounted:
75
+ ### iOS: pictures on pushes (optional)
76
+
77
+ Bubbl's pushes show their picture with a Notification Service Extension. React Native CLI: in
78
+ Xcode, File › New › Target › Notification Service Extension (e.g. `NotificationService`, iOS
79
+ 17), then in the Podfile, outside the app's target:
80
+
81
+ ```ruby
82
+ target 'NotificationService' do
83
+ pod 'BubblReactNativeNotificationService', :path => '../node_modules/@bubblsdk/react-native-sdk/ios-extension'
84
+ end
85
+ ```
86
+
87
+ `pod install`, and make the extension's `NotificationService.swift` just:
40
88
 
41
89
  ```swift
42
- import BubblReactNativeSdk
90
+ import BubblNotificationService
43
91
 
44
- func application(
45
- _ application: UIApplication,
46
- didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
47
- ) -> Bool {
48
- BubblSdkLocationLaunchHandler.handleLaunchOptions(launchOptions as NSDictionary?)
49
- return true
50
- }
92
+ class NotificationService: BubblNotificationService {}
51
93
  ```
52
94
 
53
- For apps that render their own in-app notification modal while still letting
54
- the native SDK trigger device notifications:
95
+ Other pushes pass through untouched.
55
96
 
56
- ```ts
57
- await Bubbl.boot({
58
- apiKey: '...',
59
- notificationRenderingMode: 'sdkDefault',
60
- enableDefaultNotificationModal: false,
61
- });
97
+ Expo: `"ios": { "imageNotifications": true }` in the plugin's options does all of that at prebuild
98
+ (needs `ios.bundleIdentifier`): a `BubblNotificationExtension` target (bundle id: the app's plus
99
+ `.BubblNotificationExtension`, the app's version and device family), its Podfile target, and its
100
+ entry in `extra.eas.build.experimental.ios.appExtensions`, so EAS Build provisions and signs it.
101
+
102
+ ### iOS: handing over pushes yourself (optional)
103
+
104
+ Bubbl takes the push token and its own pushes by itself, alongside other push libraries. With
105
+ `BubblAutoIntegrationEnabled` set to `NO` in Info.plist it doesn't, and the AppDelegate hands
106
+ them over. Swift: `import BubblReactNativeSdk` (the iOS SDK is in this module), then
107
+ `Bubbl.setPushToken(deviceToken)`, `Bubbl.willPresent(…)` and `Bubbl.didReceive(…)` as in the
108
+ iOS SDK. Objective-C:
62
109
 
63
- // Or toggle it after boot.
64
- await Bubbl.disableDefaultNotificationModal();
110
+ ```objc
111
+ #import <UserNotifications/UserNotifications.h>
112
+ #import <BubblReactNativeSdk/BubblReactNativeSdk-Swift.h>
113
+
114
+ [BubblPush setPushToken:deviceToken];
115
+ if ([BubblPush willPresent:notification completionHandler:completionHandler]) return;
116
+ if ([BubblPush didReceive:response completionHandler:completionHandler]) return;
65
117
  ```
66
118
 
67
- Apps with their own notification inbox/history can still ask the SDK to show
68
- the bundled detail UI for a stored payload:
119
+ ## Start
120
+
121
+ Once, early: at the top of `index.js`, or with Expo Router (which has no `index.js`) at the top
122
+ of `app/_layout.tsx`, outside the component:
69
123
 
70
124
  ```ts
71
- await Bubbl.openNotificationModal(payload);
125
+ import { Bubbl } from '@bubblsdk/react-native-sdk';
126
+
127
+ Bubbl.start('pk_live_…', { baseUrl: 'https://…' });
72
128
  ```
73
129
 
74
- This opens the default modal/detail UI without posting another device
75
- notification.
130
+ A mistake (an empty key, an http:// URL) is logged natively, never thrown; calls before `start`
131
+ do nothing. Geofences and pushes keep working with the app closed: the native SDK starts itself
132
+ from its saved settings when the OS wakes the app, without JavaScript.
76
133
 
77
- ## Android Notification Taps
134
+ Where there's no native module, Bubbl's calls do nothing and say why once in the console: on the
135
+ web, in Expo Go, and in a build from before the install (rebuild it). In your Jest tests, use the
136
+ mock, whose functions are `jest.fn`s:
78
137
 
79
- Firebase auto-rendered notifications launch the app's `MainActivity` with the
80
- notification payload as intent extras. Forward those launcher intents into the
81
- SDK so notification taps open the app and route to the right modal.
138
+ ```ts
139
+ jest.mock('@bubblsdk/react-native-sdk', () => require('@bubblsdk/react-native-sdk/jest'));
140
+ ```
82
141
 
83
- Use `openDefaultModal(...)` when the SDK should show the bundled modal:
142
+ ## Use
84
143
 
85
- ```kotlin
86
- import android.content.Intent
87
- import android.os.Bundle
88
- import com.facebook.react.ReactActivity
89
- import tech.bubbl.reactnative.BubblSdkNotificationIntents
144
+ ```ts
145
+ await Bubbl.permissions.requestLocation({ always: true }); // "while in use", then "always"
146
+ await Bubbl.permissions.requestNotifications();
147
+
148
+ Bubbl.setSegments(['vip']);
149
+ Bubbl.track('purchase.completed', { total: 12.5 });
90
150
 
91
- class MainActivity : ReactActivity() {
92
- override fun onCreate(savedInstanceState: Bundle?) {
93
- super.onCreate(savedInstanceState)
94
- BubblSdkNotificationIntents.openDefaultModal(this, intent)
95
- }
151
+ const subscription = Bubbl.addEventListener((event) => {
152
+ if (event.type === 'geofence.entered') console.log('entered', event.locationId);
153
+ });
154
+
155
+ // Show notifications yourself while the app is open (in the background Bubbl posts its own; if
156
+ // JS can't answer, say mid-reload, Bubbl shows it, so none is lost):
157
+ Bubbl.setNotificationListener((message) => {
158
+ showMyBanner(message);
159
+ Bubbl.reportDisplayed(message);
160
+ return true;
161
+ });
96
162
 
97
- override fun onNewIntent(intent: Intent) {
98
- super.onNewIntent(intent)
99
- setIntent(intent)
100
- BubblSdkNotificationIntents.openDefaultModal(this, intent)
101
- }
102
- }
163
+ const diagnostics = await Bubbl.diagnostics();
103
164
  ```
104
165
 
105
- Use `openHostModal(...)` when the app renders its own modal. The SDK records
106
- the tap, keeps the payload pending across cold start, and emits
107
- `notificationTapped` once the React Native bridge subscribes:
166
+ Consent (`setConsent`, `optOut`, `deleteMyData`, `setLocationEnabled`), the report functions,
167
+ `submitSurvey`, `openCta`, `present` and `isBubblMessage` are as in the public API.
108
168
 
109
- ```kotlin
110
- BubblSdkNotificationIntents.openHostModal(this, intent)
169
+ Sandbox (a `pk_test_` key): the device shows up in the dashboard as a test device, pending until
170
+ approved there with the code Bubbl logs and shows, or from the app:
171
+
172
+ ```ts
173
+ const { approved, message } = await Bubbl.registerTestDevice('K7Q-2MX');
174
+ const { environment, testDevice } = await Bubbl.diagnostics(); // 'sandbox', { status, code? }
111
175
  ```
112
176
 
113
- ## Events
177
+ Messages from a Sandbox carry `isSandbox: true`.
178
+
179
+ A device credential issued outside the app (installs provisioned ahead of time, your own pairing
180
+ flow) starts Bubbl instead of an API key, the same way at every launch:
114
181
 
115
182
  ```ts
116
- const subscription = Bubbl.events.addListener((event) => {
117
- if (event.type === 'notificationReceived') {
118
- // Host apps can inspect or custom-render notification payloads here.
119
- }
120
- });
183
+ Bubbl.startWithCredential({ keyId, secret, installId }, { baseUrl: 'https://…' });
184
+ ```
185
+
186
+ The device doesn't register itself. The secret goes only to the native SDK (the Keychain, the
187
+ Android Keystore); keep it out of your own logs. If the server refuses the credential, Bubbl stops
188
+ and says so (`credential.rejected`, `diagnostics().credentialRejected`) until it's started with a
189
+ new one.
121
190
 
122
- subscription.remove();
191
+ ## Develop
192
+
193
+ ```sh
194
+ npm install
195
+ npm test # facade and config plugin tests
196
+ npm run typecheck
197
+ npm run build # lib/ and plugin/build
123
198
  ```
124
199
 
125
- ## Notes
200
+ `example/` is a React Native app using the package from this folder. On Android it uses the
201
+ Bubbl Android SDK from `~/.m2` until 5.0 is on Maven Central:
202
+
203
+ ```sh
204
+ (cd ../android && ./gradlew publishToMavenLocal)
205
+ node ../scripts/fake-device-api.mjs & # a stand-in device API on port 8787
206
+ adb reverse tcp:8787 tcp:8787
207
+ cd example && npx react-native run-android
208
+ ```
126
209
 
127
- - Android depends on `tech.bubbl.sdk:bubbl-sdk` and requires `minSdkVersion 27` or higher.
128
- - iOS depends on the `BubblSDK` CocoaPods/Swift package release and requires iOS 15 or higher.
129
- - Host apps must declare push/location permissions. Android needs coarse/fine/background location, foreground-service location, and notification permissions. iOS needs location usage descriptions and `UIBackgroundModes` entries for `location` and `remote-notification`.
210
+ `example-expo/` is an Expo app (SDK 57) with the package from this folder (`file:..`) and the
211
+ config plugin, `ios.imageNotifications` on. It's for checking prebuild output; build the package
212
+ first:
213
+
214
+ ```sh
215
+ npm run sync:ios && npm run build
216
+ cd example-expo && npm install
217
+ npx expo prebuild --platform ios # on macOS; then pod install in ios/
218
+ ```