@attentive-mobile/attentive-react-native-sdk 2.0.1 → 2.0.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 CHANGED
@@ -9,6 +9,18 @@ This project uses **npm** as the preferred package manager for consistency and a
9
9
 
10
10
  **Note on package managers:** Modern npm (v7+) has significantly improved performance and features, making it the recommended choice for React Native projects. Both npm and yarn work well with React Native, but this project standardizes on npm for development workflows.
11
11
 
12
+ ## Requirements
13
+
14
+ | Tool | Version |
15
+ |------|---------|
16
+ | Node.js | >= 18.0.0 |
17
+ | React Native | >= 0.74 |
18
+ | Ruby | >= 3.3 |
19
+ | CocoaPods | ~> 1.16 |
20
+ | Xcode | >= 15 |
21
+ | Android SDK | API 24+ |
22
+ | JDK | 17 |
23
+
12
24
  ## Installation
13
25
 
14
26
  Run `npm install @attentive-mobile/attentive-react-native-sdk` from your app's root directory.
@@ -22,23 +34,23 @@ __*** NOTE: Please refrain from using any private or undocumented classes or met
22
34
  ### Import the SDK
23
35
 
24
36
  ```typescript
25
- import { Attentive, <other types you need here> } from 'attentive-react-native-sdk';
37
+ import { initialize, identify, triggerCreative, recordPurchaseEvent, /* ... */ } from '@attentive-mobile/attentive-react-native-sdk';
26
38
  ```
27
39
 
28
40
  ### Create the AttentiveConfig
29
41
 
30
42
  ```typescript
31
- // Create an AttentiveConfiguration with your attentive domain, in production mode
32
- const config : AttentiveConfiguration = {
43
+ // Create an AttentiveSdkConfiguration with your attentive domain, in production mode
44
+ const config: AttentiveSdkConfiguration = {
33
45
  attentiveDomain: 'YOUR_ATTENTIVE_DOMAIN',
34
- mode: Mode.Production,
46
+ mode: 'production',
35
47
  }
36
48
  ```
37
49
  ```typescript
38
50
  // Alternatively, use "debug" mode. When in debug mode, the Creative will not be shown, but instead a popup will show with debug information about your creative and any reason the Creative wouldn't show.
39
- const config : AttentiveConfiguration = {
51
+ const config: AttentiveSdkConfiguration = {
40
52
  attentiveDomain: 'YOUR_ATTENTIVE_DOMAIN',
41
- mode: Mode.Debug,
53
+ mode: 'debug',
42
54
  }
43
55
  ```
44
56
 
@@ -47,9 +59,9 @@ const config : AttentiveConfiguration = {
47
59
  The SDK includes debugging helpers to show what data is being sent and received. Enable debugging by setting `enableDebugger: true`:
48
60
 
49
61
  ```typescript
50
- const config : AttentiveConfiguration = {
62
+ const config: AttentiveSdkConfiguration = {
51
63
  attentiveDomain: 'YOUR_ATTENTIVE_DOMAIN',
52
- mode: Mode.Debug,
64
+ mode: 'debug',
53
65
  enableDebugger: true, // Shows debug overlays for events and creatives
54
66
  }
55
67
  ```
@@ -61,7 +73,7 @@ When enabled, debug overlays will automatically appear when:
61
73
  You can also manually invoke the debug helper:
62
74
 
63
75
  ```typescript
64
- Attentive.invokeAttentiveDebugHelper();
76
+ invokeAttentiveDebugHelper();
65
77
  ```
66
78
 
67
79
  See [DEBUGGING.md](./DEBUGGING.md) for detailed information about debugging features.
@@ -76,7 +88,7 @@ On iOS, call `initialize` from TypeScript as early as possible (e.g. the root `A
76
88
 
77
89
  ```typescript
78
90
  // Called once per app session, before any other SDK operations.
79
- Attentive.initialize(config);
91
+ initialize(config);
80
92
  ```
81
93
 
82
94
  #### Android — Initialize from Native Code
@@ -153,22 +165,22 @@ After the native initialization, all other SDK operations (`identify`, `recordAd
153
165
 
154
166
  ```typescript
155
167
  // This will remove the creative along with its web view
156
- Attentive.destroyCreative();
168
+ destroyCreative();
157
169
  ```
158
170
 
159
171
 
160
172
  ### Identify the current user
161
173
  ```typescript
162
174
  // Before loading the creative or sending events, if you have any user identifiers, they will need to be registered. Each identifier is optional. It is okay to skip this step if you have no identifiers about the user yet.
163
- const identifiers : UserIdentifiers = {
164
- 'phone': '+15556667777',
165
- 'email': 'some_email@gmailfake.com',
166
- 'klaviyoId': 'userKlaviyoId',
167
- 'shopifyId': 'userShopifyId',
168
- 'clientUserId': 'userClientUserId',
169
- 'customIdentifiers': { 'customIdKey': 'customIdValue' }
175
+ const identifiers: UserIdentifiers = {
176
+ phone: '+15556667777',
177
+ email: 'some_email@gmailfake.com',
178
+ klaviyoId: 'userKlaviyoId',
179
+ shopifyId: 'userShopifyId',
180
+ clientUserId: 'userClientUserId',
181
+ customIdentifiers: { customIdKey: 'customIdValue' }
170
182
  };
171
- Attentive.identify(identifiers);
183
+ identify(identifiers);
172
184
  ```
173
185
 
174
186
  The more identifiers that are passed to `identify`, the better the SDK will function. Here is the list of possible identifiers:
@@ -185,46 +197,34 @@ The more identifiers that are passed to `identify`, the better the SDK will func
185
197
 
186
198
  ```typescript
187
199
  // Trigger the Creative. This will show the Creative as a pop-up over the rest of the app.
188
- Attentive.triggerCreative();
200
+ triggerCreative();
189
201
  ```
190
202
 
191
203
  ### Record user events
192
204
 
193
- The SDK currently supports `PurchaseEvent`, `AddToCartEvent`, `ProductViewEvent`, and `CustomEvent`.
205
+ The SDK currently supports `Purchase`, `AddToCart`, `ProductView`, and `CustomEvent`.
194
206
 
195
207
  ```typescript
196
208
  // Construct one or more "Item"s, which represents the product(s) purchased
197
- const items : Item[] = [
198
- {
199
- productId: '555',
200
- productVariantId: '777',
201
- price: {
202
- price: '14.99',
203
- currency: 'USD',
204
- },
205
- },
206
- ];
207
-
208
- // Construct an "Order", which represents the order for the purchase
209
- const order : Order = {
210
- orderId: '88888'
211
- }
212
-
213
- // (Optional) Construct a "Cart", which represents the cart this Purchase was made from
214
- const cart : Cart = {
215
- cartId: '555555',
216
- cartCoupon: 'SOME-DISCOUNT'
217
- }
218
-
219
- // Construct a PurchaseEvent, which ties together the preceding objects
220
- const purchaseEvent : PurchaseEvent = {
209
+ const items: Item[] = [
210
+ {
211
+ productId: '555',
212
+ productVariantId: '777',
213
+ price: '14.99',
214
+ currency: 'USD',
215
+ },
216
+ ];
217
+
218
+ // Construct a Purchase event
219
+ const purchase: Purchase = {
221
220
  items: items,
222
- order: order,
223
- cart: cart
221
+ orderId: '88888',
222
+ cartId: '555555', // optional
223
+ cartCoupon: 'SOME-DISCOUNT', // optional
224
224
  }
225
225
 
226
226
  // Record the PurchaseEvent
227
- Attentive.recordPurchaseEvent(purchaseEvent);
227
+ recordPurchaseEvent(purchase);
228
228
  ```
229
229
 
230
230
  The process is similar for the other events. See [eventTypes.tsx](https://github.com/attentive-mobile/attentive-react-native-sdk/blob/main/src/eventTypes.tsx) for all events.
@@ -233,12 +233,12 @@ The process is similar for the other events. See [eventTypes.tsx](https://github
233
233
 
234
234
  ```typescript
235
235
  // If new identifiers are available for the user, register them
236
- Attentive.identify({email: 'theusersemail@gmail.com'});
236
+ identify({email: 'theusersemail@gmail.com'});
237
237
  ```
238
238
 
239
239
  ```typescript
240
- Attentive.identify({email: 'theusersemail@gmail.com'});
241
- Attentive.identify({phone: '+15556667777'};)
240
+ identify({email: 'theusersemail@gmail.com'});
241
+ identify({phone: '+15556667777'});
242
242
  // The SDK will have these two identifiers:
243
243
  // email: 'theusersemail@gmail.com'
244
244
  // phone: '+15556667777'
@@ -1,7 +1,6 @@
1
1
  require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
- folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
4
 
6
5
  Pod::Spec.new do |s|
7
6
  s.name = "attentive-react-native-sdk"
@@ -15,23 +14,10 @@ Pod::Spec.new do |s|
15
14
  s.source = { :git => "https://github.com/attentive-mobile/attentive-react-native-sdk.git", :tag => "#{s.version}" }
16
15
 
17
16
  s.source_files = "ios/**/*.{h,m,mm,swift}"
17
+ s.public_header_files = "ios/AttentiveReactNativeSdk.h"
18
18
 
19
19
  s.dependency 'attentive-ios-sdk', '2.0.13'
20
20
  s.swift_versions = ['5']
21
- s.dependency "React-Core"
22
21
 
23
- # Don't install the dependencies when we run `pod install` in the old architecture.
24
- if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
25
- s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
26
- s.pod_target_xcconfig = {
27
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/Headers/Public/React-NativeModulesApple\" \"$(PODS_ROOT)/Headers/Private/React-NativeModulesApple\" \"$(PODS_ROOT)/Headers/Private/React-Codegen/react/renderer/components\" \"${PODS_CONFIGURATION_BUILD_DIR}/React-Codegen/React_Codegen.framework/Headers\"",
28
- "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
29
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++20"
30
- }
31
- s.dependency "React-Codegen"
32
- s.dependency "RCT-Folly"
33
- s.dependency "RCTRequired"
34
- s.dependency "RCTTypeSafety"
35
- s.dependency "ReactCommon/turbomodule/core"
36
- end
22
+ install_modules_dependencies(s)
37
23
  end
@@ -5,14 +5,7 @@
5
5
  // Created by Wyatt Davis on 2/13/23.
6
6
  //
7
7
 
8
- #ifdef RCT_NEW_ARCH_ENABLED
9
- #import "AttentiveReactNativeSdkSpec.h"
10
-
11
- @interface AttentiveReactNativeSdk : NSObject <NativeAttentiveReactNativeSdkSpec>
12
- #else
13
8
  #import <React/RCTBridgeModule.h>
14
9
 
15
10
  @interface AttentiveReactNativeSdk : NSObject <RCTBridgeModule>
16
- #endif
17
-
18
11
  @end
@@ -4,17 +4,31 @@
4
4
  //
5
5
  // Created by Wyatt Davis on 2/13/23.
6
6
  //
7
+ // NOTE: This file contains both new arch and old arch implementations. Only the new arch path
8
+ // (RCT_NEW_ARCH_ENABLED) is functional. The old arch #else branch does not compile and is
9
+ // retained as scaffolding for future old arch support work (MSDK-350).
10
+ //
7
11
 
8
12
  #import "AttentiveReactNativeSdk.h"
9
13
  #import <UserNotifications/UserNotifications.h>
10
14
 
11
- #if __has_include(<AttentiveReactNativeSdk-Swift.h>)
15
+ #ifdef RCT_NEW_ARCH_ENABLED
16
+ #import "AttentiveReactNativeSdkSpec.h"
17
+ #endif
18
+
19
+ #if __has_include(<attentive_react_native_sdk/attentive_react_native_sdk-Swift.h>)
20
+ #import <attentive_react_native_sdk/attentive_react_native_sdk-Swift.h>
21
+ #elif __has_include(<AttentiveReactNativeSdk-Swift.h>)
12
22
  #import "AttentiveReactNativeSdk-Swift.h"
13
23
  #else
14
- // Load the headers from the attentive-ios-sdk Pod
15
24
  #import "attentive_react_native_sdk-Swift.h"
16
25
  #endif
17
26
 
27
+ #ifdef RCT_NEW_ARCH_ENABLED
28
+ @interface AttentiveReactNativeSdk () <NativeAttentiveReactNativeSdkSpec>
29
+ @end
30
+ #endif
31
+
18
32
  @implementation AttentiveReactNativeSdk {
19
33
  ATTNNativeSDK* _sdk;
20
34
  }
@@ -190,8 +204,9 @@ customIdentifiers:(NSDictionary *)customIdentifiers {
190
204
  }
191
205
 
192
206
  #else
193
- // Old Architecture implementation with dictionary parameters.
194
- // Initialize is invoked only from TypeScript (e.g. Bonni App); native must not auto-initialize.
207
+ // Old Architecture implementation currently does not compile (missing RCT_EXPORT_METHOD macros,
208
+ // bridge module registration, etc.). Kept here as a starting point for restoring old arch support
209
+ // in a future ticket (MSDK-350).
195
210
  - (void)initialize:(NSDictionary*)configuration {
196
211
  _sdk = [[ATTNNativeSDK alloc] initWithDomain:configuration[@"attentiveDomain"]
197
212
  mode:configuration[@"mode"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attentive-mobile/attentive-react-native-sdk",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "React Native Module for the Attentive SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",