@attentive-mobile/attentive-react-native-sdk 1.0.5 → 2.0.0-beta.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 (37) hide show
  1. package/README.md +126 -0
  2. package/android/build.gradle +1 -0
  3. package/android/src/main/kotlin/com/attentivereactnativesdk/AttentiveReactNativeSdkModule.kt +384 -0
  4. package/android/src/main/kotlin/com/attentivereactnativesdk/AttentiveReactNativeSdkPackage.kt +36 -0
  5. package/android/src/main/kotlin/com/attentivereactnativesdk/debug/AttentiveDebugHelper.kt +22 -6
  6. package/attentive-react-native-sdk.podspec +3 -3
  7. package/ios/AttentiveReactNativeSdk.h +1 -1
  8. package/ios/AttentiveReactNativeSdk.mm +317 -37
  9. package/ios/Bridging/ATTNNativeSDK.swift +392 -45
  10. package/ios/Bridging/AttentiveReactNativeSdk-Bridging-Header.h +3 -0
  11. package/ios/Bridging/AttentiveSDKManager.swift +83 -0
  12. package/ios/Podfile +3 -16
  13. package/lib/commonjs/NativeAttentiveReactNativeSdk.js +14 -0
  14. package/lib/commonjs/NativeAttentiveReactNativeSdk.js.map +1 -0
  15. package/lib/commonjs/eventTypes.js.map +1 -1
  16. package/lib/commonjs/index.js +362 -52
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/module/NativeAttentiveReactNativeSdk.js +7 -0
  19. package/lib/module/NativeAttentiveReactNativeSdk.js.map +1 -0
  20. package/lib/module/eventTypes.js.map +1 -1
  21. package/lib/module/index.js +345 -50
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/typescript/NativeAttentiveReactNativeSdk.d.ts +103 -0
  24. package/lib/typescript/NativeAttentiveReactNativeSdk.d.ts.map +1 -0
  25. package/lib/typescript/eventTypes.d.ts +44 -17
  26. package/lib/typescript/eventTypes.d.ts.map +1 -1
  27. package/lib/typescript/index.d.ts +276 -41
  28. package/lib/typescript/index.d.ts.map +1 -1
  29. package/package.json +21 -7
  30. package/src/NativeAttentiveReactNativeSdk.ts +152 -0
  31. package/src/eventTypes.tsx +57 -20
  32. package/src/index.tsx +472 -96
  33. package/android/src/main/java/com/attentivereactnativesdk/AttentiveReactNativeSdkModule.java +0 -310
  34. package/android/src/main/java/com/attentivereactnativesdk/AttentiveReactNativeSdkPackage.java +0 -28
  35. package/ios/AttentiveReactNativeSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  36. package/ios/AttentiveReactNativeSdk.xcodeproj/project.xcworkspace/xcuserdata/zheref.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  37. package/ios/AttentiveReactNativeSdk.xcodeproj/xcuserdata/zheref.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -0,0 +1,83 @@
1
+ //
2
+ // AttentiveSDKManager.swift
3
+ // AttentiveReactNativeSdk
4
+ //
5
+ // Created by Attentive SDK Team
6
+ // Copyright © 2026 Attentive. All rights reserved.
7
+ //
8
+
9
+ import Foundation
10
+ import UserNotifications
11
+
12
+ /**
13
+ * Shared manager for accessing the Attentive SDK instance from native code.
14
+ * This allows AppDelegate and other native code to access the SDK instance
15
+ * that was initialized from React Native.
16
+ *
17
+ * Usage in AppDelegate:
18
+ * ```swift
19
+ * // In userNotificationCenter(_:didReceive:withCompletionHandler:)
20
+ * UNUserNotificationCenter.current().getNotificationSettings { settings in
21
+ * let authStatus = settings.authorizationStatus
22
+ * DispatchQueue.main.async {
23
+ * switch UIApplication.shared.applicationState {
24
+ * case .active:
25
+ * AttentiveSDKManager.shared.handleForegroundPush(response: response, authorizationStatus: authStatus)
26
+ * case .background, .inactive:
27
+ * AttentiveSDKManager.shared.handlePushOpen(response: response, authorizationStatus: authStatus)
28
+ * @unknown default:
29
+ * AttentiveSDKManager.shared.handlePushOpen(response: response, authorizationStatus: authStatus)
30
+ * }
31
+ * }
32
+ * }
33
+ * ```
34
+ */
35
+ @objc public class AttentiveSDKManager: NSObject {
36
+ /// Shared singleton instance
37
+ @objc public static let shared: AttentiveSDKManager = AttentiveSDKManager()
38
+
39
+ /// The Attentive SDK instance as AnyObject for Objective-C compatibility
40
+ /// This should be set when the SDK is initialized from React Native
41
+ /// Cast to ATTNNativeSDK in Swift code
42
+ @objc public var sdk: AnyObject?
43
+
44
+ private override init() {
45
+ super.init()
46
+ }
47
+
48
+ /// Helper method to get the SDK instance with proper type in Swift
49
+ public var nativeSDK: ATTNNativeSDK? {
50
+ return sdk as? ATTNNativeSDK
51
+ }
52
+
53
+ /// Helper method to set the SDK instance with proper type in Swift
54
+ public func setNativeSDK(_ nativeSDK: ATTNNativeSDK?) {
55
+ sdk = nativeSDK
56
+ }
57
+
58
+ // MARK: - Push Notification Handlers (for AppDelegate)
59
+
60
+ /**
61
+ * Handle a push notification when the app is in the foreground (active state).
62
+ * Call this from AppDelegate's userNotificationCenter(_:didReceive:withCompletionHandler:)
63
+ * when UIApplication.shared.applicationState == .active
64
+ *
65
+ * @param response The UNNotificationResponse from the notification center delegate
66
+ * @param authorizationStatus Current push authorization status from notification settings
67
+ */
68
+ @objc public func handleForegroundPush(response: UNNotificationResponse, authorizationStatus: UNAuthorizationStatus) {
69
+ nativeSDK?.handleForegroundPush(response: response, authorizationStatus: authorizationStatus)
70
+ }
71
+
72
+ /**
73
+ * Handle when a push notification is opened by the user (app in background/inactive state).
74
+ * Call this from AppDelegate's userNotificationCenter(_:didReceive:withCompletionHandler:)
75
+ * when UIApplication.shared.applicationState == .background or .inactive
76
+ *
77
+ * @param response The UNNotificationResponse from the notification center delegate
78
+ * @param authorizationStatus Current push authorization status from notification settings
79
+ */
80
+ @objc public func handlePushOpen(response: UNNotificationResponse, authorizationStatus: UNAuthorizationStatus) {
81
+ nativeSDK?.handlePushOpen(response: response, authorizationStatus: authorizationStatus)
82
+ }
83
+ }
package/ios/Podfile CHANGED
@@ -4,16 +4,8 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
4
4
  platform :ios, '14.0'
5
5
  prepare_react_native_project!
6
6
 
7
- # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
8
- # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
9
- #
10
- # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
11
- # ```js
12
- # module.exports = {
13
- # dependencies: {
14
- # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
15
- # ```
16
- flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
7
+ # Flipper is disabled by default in React Native 0.75+
8
+ # If you need Flipper, you'll need to add it manually
17
9
 
18
10
  linkage = ENV['USE_FRAMEWORKS']
19
11
  if linkage != nil
@@ -28,7 +20,7 @@ target 'AttentiveReactNativeSdk' do
28
20
  flags = get_default_flags()
29
21
 
30
22
  # Ensure Swift support
31
- pod 'attentive-ios-sdk', '0.6.0'
23
+ pod 'attentive-ios-sdk', '2.0.8'
32
24
 
33
25
  use_react_native!(
34
26
  :path => config[:reactNativePath],
@@ -37,11 +29,6 @@ target 'AttentiveReactNativeSdk' do
37
29
  # we make it explicit here to aid in the React Native upgrade process.
38
30
  :hermes_enabled => flags[:hermes_enabled],
39
31
  :fabric_enabled => flags[:fabric_enabled],
40
- # Enables Flipper.
41
- #
42
- # Note that if you have use_frameworks! enabled, Flipper will not work and
43
- # you should disable the next line.
44
- :flipper_configuration => flipper_config,
45
32
  # An absolute path to your application root.
46
33
  :app_path => "#{Pod::Config.instance.installation_root}/.."
47
34
  )
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _reactNative = require("react-native");
8
+ // Try to load via TurboModule first (new architecture)
9
+ // Fall back to NativeModules for old architecture
10
+ const isTurboModuleEnabled = global.__turboModuleProxy != null;
11
+ const AttentiveReactNativeSdkModule = isTurboModuleEnabled ? _reactNative.TurboModuleRegistry.get("AttentiveReactNativeSdk") : _reactNative.NativeModules.AttentiveReactNativeSdk;
12
+ var _default = AttentiveReactNativeSdkModule;
13
+ exports.default = _default;
14
+ //# sourceMappingURL=NativeAttentiveReactNativeSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","isTurboModuleEnabled","global","__turboModuleProxy","AttentiveReactNativeSdkModule","TurboModuleRegistry","get","NativeModules","AttentiveReactNativeSdk","_default","exports","default"],"sourceRoot":"../../src","sources":["NativeAttentiveReactNativeSdk.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AA8IA;AACA;AACA,MAAMC,oBAAoB,GAAIC,MAAM,CAASC,kBAAkB,IAAI,IAAI;AAEvE,MAAMC,6BAA6B,GAAGH,oBAAoB,GACtDI,gCAAmB,CAACC,GAAG,CAAO,yBAAyB,CAAC,GACxDC,0BAAa,CAACC,uBAAuB;AAAC,IAAAC,QAAA,GAE3BL,6BAA6B;AAAAM,OAAA,CAAAC,OAAA,GAAAF,QAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["eventTypes.tsx"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["eventTypes.tsx"],"mappings":"","ignoreList":[]}
@@ -3,67 +3,377 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Mode = exports.Attentive = void 0;
6
+ exports.clearUser = clearUser;
7
+ exports.destroyCreative = destroyCreative;
8
+ exports.exportDebugLogs = exportDebugLogs;
9
+ exports.handleForegroundNotification = handleForegroundNotification;
10
+ exports.handleForegroundPush = handleForegroundPush;
11
+ exports.handlePushOpen = handlePushOpen;
12
+ exports.handlePushOpened = handlePushOpened;
13
+ exports.handleRegularOpen = handleRegularOpen;
14
+ exports.identify = identify;
15
+ exports.initialize = initialize;
16
+ exports.invokeAttentiveDebugHelper = invokeAttentiveDebugHelper;
17
+ exports.recordAddToCartEvent = recordAddToCartEvent;
18
+ exports.recordCustomEvent = recordCustomEvent;
19
+ exports.recordProductViewEvent = recordProductViewEvent;
20
+ exports.recordPurchaseEvent = recordPurchaseEvent;
21
+ exports.registerDeviceToken = registerDeviceToken;
22
+ exports.registerDeviceTokenWithCallback = registerDeviceTokenWithCallback;
23
+ exports.registerForPushNotifications = registerForPushNotifications;
24
+ exports.triggerCreative = triggerCreative;
25
+ exports.updateDomain = updateDomain;
7
26
  var _reactNative = require("react-native");
27
+ var _NativeAttentiveReactNativeSdk = _interopRequireDefault(require("./NativeAttentiveReactNativeSdk"));
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
29
  const LINKING_ERROR = `The package 'attentive-react-native-sdk' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
9
30
  ios: "- You have run 'pod install'\n",
10
31
  default: ''
11
32
  }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
12
- const AttentiveReactNativeSdk = _reactNative.NativeModules.AttentiveReactNativeSdk ? _reactNative.NativeModules.AttentiveReactNativeSdk : new Proxy({}, {
33
+ const AttentiveReactNativeSdk = _NativeAttentiveReactNativeSdk.default ? _NativeAttentiveReactNativeSdk.default : new Proxy({}, {
13
34
  get() {
14
35
  throw new Error(LINKING_ERROR);
15
36
  }
16
37
  });
17
- let Mode = /*#__PURE__*/function (Mode) {
18
- Mode["Production"] = "production";
19
- Mode["Debug"] = "debug";
20
- return Mode;
21
- }({});
22
- exports.Mode = Mode;
23
- class Attentive {
24
- static initialize(configuration) {
25
- AttentiveReactNativeSdk.initialize(configuration);
26
- }
27
- static identify(userIdentifiers) {
28
- AttentiveReactNativeSdk.identify(userIdentifiers);
29
- }
30
- static clearUser() {
31
- AttentiveReactNativeSdk.clearUser();
32
- }
33
- static triggerCreative() {
34
- let creativeId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
35
- AttentiveReactNativeSdk.triggerCreative(creativeId);
36
- }
37
- static destroyCreative() {
38
- AttentiveReactNativeSdk.destroyCreative();
39
- }
40
- static updateDomain(domain) {
41
- AttentiveReactNativeSdk.updateDomain(domain);
42
- }
43
- static recordProductViewEvent(productViewEvent) {
44
- AttentiveReactNativeSdk.recordProductViewEvent(productViewEvent);
45
- }
46
- static recordAddToCartEvent(addToCartEvent) {
47
- AttentiveReactNativeSdk.recordAddToCartEvent(addToCartEvent);
48
- }
49
- static recordPurchaseEvent(purchaseEvent) {
50
- AttentiveReactNativeSdk.recordPurchaseEvent(purchaseEvent);
51
- }
52
- static recordCustomEvent(customEvent) {
53
- AttentiveReactNativeSdk.recordCustomEvent(customEvent);
54
- }
55
- static invokeAttentiveDebugHelper() {
56
- AttentiveReactNativeSdk.invokeAttentiveDebugHelper();
57
- }
58
38
 
59
- /**
60
- * Exports debug logs as a formatted string for sharing or analysis
61
- * Only available when debugging is enabled
62
- * @returns Promise<string> A formatted string containing all debug events in the current session
63
- */
64
- static async exportDebugLogs() {
65
- return AttentiveReactNativeSdk.exportDebugLogs();
66
- }
39
+ /**
40
+ * Initialize the Attentive SDK with the provided configuration
41
+ * @param configuration - Configuration object for the Attentive SDK
42
+ */
43
+ function initialize(configuration) {
44
+ AttentiveReactNativeSdk.initialize(configuration.attentiveDomain, configuration.mode, configuration.skipFatigueOnCreatives ?? false, configuration.enableDebugger ?? false);
45
+ }
46
+
47
+ /**
48
+ * Trigger a creative with an optional creative ID
49
+ * @param creativeId - Optional creative ID to trigger
50
+ */
51
+ function triggerCreative(creativeId) {
52
+ AttentiveReactNativeSdk.triggerCreative(creativeId);
53
+ }
54
+
55
+ /**
56
+ * Destroy the current creative
57
+ */
58
+ function destroyCreative() {
59
+ AttentiveReactNativeSdk.destroyCreative();
60
+ }
61
+
62
+ /**
63
+ * Update the Attentive domain
64
+ * @param domain - New domain to use
65
+ */
66
+ function updateDomain(domain) {
67
+ AttentiveReactNativeSdk.updateDomain(domain);
68
+ }
69
+
70
+ /**
71
+ * Identify a user with the provided identifiers
72
+ * @param identifiers - User identifier object containing phone, email, etc.
73
+ */
74
+ function identify(identifiers) {
75
+ AttentiveReactNativeSdk.identify(identifiers.phone, identifiers.email, identifiers.klaviyoId, identifiers.shopifyId, identifiers.clientUserId, identifiers.customIdentifiers);
76
+ }
77
+
78
+ /**
79
+ * Clear the current user identification
80
+ */
81
+ function clearUser() {
82
+ AttentiveReactNativeSdk.clearUser();
83
+ }
84
+
85
+ /**
86
+ * Record an add to cart event
87
+ * @param attrs - Event attributes containing items and optional deeplink
88
+ */
89
+ function recordAddToCartEvent(attrs) {
90
+ AttentiveReactNativeSdk.recordAddToCartEvent(attrs.items, attrs.deeplink);
91
+ }
92
+
93
+ /**
94
+ * Record a product view event
95
+ * @param attrs - Event attributes containing items and optional deeplink
96
+ */
97
+ function recordProductViewEvent(attrs) {
98
+ AttentiveReactNativeSdk.recordProductViewEvent(attrs.items, attrs.deeplink);
99
+ }
100
+
101
+ /**
102
+ * Record a purchase event
103
+ * @param attrs - Event attributes containing items, order ID, and optional cart details
104
+ */
105
+ function recordPurchaseEvent(attrs) {
106
+ AttentiveReactNativeSdk.recordPurchaseEvent(attrs.items, attrs.orderId, attrs.cartId, attrs.cartCoupon);
107
+ }
108
+
109
+ /**
110
+ * Record a custom event
111
+ * @param attrs - Custom event attributes containing type and properties
112
+ */
113
+ function recordCustomEvent(attrs) {
114
+ AttentiveReactNativeSdk.recordCustomEvent(attrs.type, attrs.properties);
115
+ }
116
+
117
+ /**
118
+ * Invoke the Attentive debug helper
119
+ */
120
+ function invokeAttentiveDebugHelper() {
121
+ AttentiveReactNativeSdk.invokeAttentiveDebugHelper();
122
+ }
123
+
124
+ /**
125
+ * Export debug logs
126
+ * @returns Promise that resolves to a string containing the debug logs
127
+ */
128
+ function exportDebugLogs() {
129
+ return AttentiveReactNativeSdk.exportDebugLogs();
130
+ }
131
+
132
+ // =============================================================================
133
+ // Push Notification Methods (iOS only - Android is no-op with TODO stubs)
134
+ // =============================================================================
135
+
136
+ /**
137
+ * Request push notification permission from the user.
138
+ * On iOS, this will trigger the system permission dialog.
139
+ * On Android, this is currently a no-op (TODO: implement FCM integration).
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * import { registerForPushNotifications } from 'attentive-react-native-sdk';
144
+ *
145
+ * // Request permission (typically called after user onboarding)
146
+ * registerForPushNotifications();
147
+ * ```
148
+ */
149
+ function registerForPushNotifications() {
150
+ AttentiveReactNativeSdk.registerForPushNotifications();
151
+ }
152
+
153
+ /**
154
+ * Register the device token received from APNs/FCM with the Attentive backend.
155
+ * Call this from your AppDelegate's didRegisterForRemoteNotificationsWithDeviceToken.
156
+ *
157
+ * On iOS, the token should be the hex-encoded string representation of the device token Data.
158
+ * On Android, this is currently a no-op (TODO: implement FCM integration).
159
+ *
160
+ * @param token - The device token as a hex-encoded string
161
+ * @param authorizationStatus - Current push authorization status
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * import { registerDeviceToken } from 'attentive-react-native-sdk';
166
+ *
167
+ * // In your native module or push notification handler:
168
+ * registerDeviceToken('abc123...', 'authorized');
169
+ * ```
170
+ */
171
+ function registerDeviceToken(token, authorizationStatus) {
172
+ AttentiveReactNativeSdk.registerDeviceToken(token, authorizationStatus);
173
+ }
174
+
175
+ /**
176
+ * Register the device token received from APNs with a callback.
177
+ * This is the callback-based version that allows you to handle the response from the Attentive API.
178
+ *
179
+ * On iOS, this will register the device token with the Attentive SDK and invoke the callback
180
+ * after the registration completes (success or failure).
181
+ * On Android, this is currently a no-op (TODO: implement FCM integration).
182
+ *
183
+ * @param token - The hex-encoded device token string from APNs
184
+ * @param authorizationStatus - Current push authorization status
185
+ * @param callback - Callback function invoked after registration completes
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * import { registerDeviceTokenWithCallback, handleRegularOpen } from 'attentive-react-native-sdk';
190
+ *
191
+ * // In your AppDelegate equivalent (TypeScript):
192
+ * registerDeviceTokenWithCallback(
193
+ * deviceToken,
194
+ * 'authorized',
195
+ * (data, url, response, error) => {
196
+ * console.log('Registration complete:', { data, url, response, error });
197
+ * // After registration, trigger regular open event
198
+ * handleRegularOpen('authorized');
199
+ * }
200
+ * );
201
+ * ```
202
+ */
203
+ function registerDeviceTokenWithCallback(token, authorizationStatus, callback) {
204
+ AttentiveReactNativeSdk.registerDeviceTokenWithCallback(token, authorizationStatus, callback);
205
+ }
206
+
207
+ /**
208
+ * Handle regular/direct app open (not from a push notification).
209
+ * This should be called after device token registration to track app opens.
210
+ *
211
+ * This is the TypeScript equivalent of the native iOS AppDelegate method:
212
+ * ```swift
213
+ * func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
214
+ * UNUserNotificationCenter.current().getNotificationSettings { [weak self] settings in
215
+ * guard let self = self else { return }
216
+ * let authStatus = settings.authorizationStatus
217
+ * attentiveSdk?.registerDeviceToken(deviceToken, authorizationStatus: authStatus, callback: { data, url, response, error in
218
+ * DispatchQueue.main.async {
219
+ * self.attentiveSdk?.handleRegularOpen(authorizationStatus: authStatus)
220
+ * }
221
+ * })
222
+ * }
223
+ * }
224
+ * ```
225
+ *
226
+ * On iOS, this will notify the Attentive SDK that the app was opened directly
227
+ * (not from a push notification tap).
228
+ * On Android, this is currently a no-op (TODO: implement FCM integration).
229
+ *
230
+ * @param authorizationStatus - Current push authorization status
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * import { registerDeviceTokenWithCallback, handleRegularOpen } from 'attentive-react-native-sdk';
235
+ * import PushNotificationIOS from '@react-native-community/push-notification-ios';
236
+ *
237
+ * // In your device token registration handler:
238
+ * PushNotificationIOS.addEventListener('register', (deviceToken: string) => {
239
+ * PushNotificationIOS.checkPermissions((permissions) => {
240
+ * let authStatus: PushAuthorizationStatus = 'notDetermined'
241
+ * if (permissions.alert || permissions.badge || permissions.sound) {
242
+ * authStatus = 'authorized'
243
+ * }
244
+ *
245
+ * // Register device token with callback
246
+ * registerDeviceTokenWithCallback(deviceToken, authStatus, (data, url, response, error) => {
247
+ * if (error) {
248
+ * console.error('Registration error:', error)
249
+ * }
250
+ * // After registration completes, trigger regular open event
251
+ * handleRegularOpen(authStatus)
252
+ * })
253
+ * })
254
+ * })
255
+ * ```
256
+ */
257
+ function handleRegularOpen(authorizationStatus) {
258
+ console.log('[AttentiveSDK] 🌉 Calling handleRegularOpen from TypeScript');
259
+ console.log(` Authorization Status: ${authorizationStatus}`);
260
+ console.log(' This should trigger: https://mobile.attentivemobile.com/mtctrl');
261
+ AttentiveReactNativeSdk.handleRegularOpen(authorizationStatus);
262
+ console.log('[AttentiveSDK] ✅ handleRegularOpen call completed');
263
+ }
264
+
265
+ /**
266
+ * Handle when a push notification is opened by the user.
267
+ * Call this from your notification handler when the user taps a notification.
268
+ *
269
+ * On iOS, this will track the push open event and handle the notification appropriately
270
+ * based on whether the app was in the foreground, background, or not running.
271
+ * On Android, this is currently a no-op (TODO: implement FCM integration).
272
+ *
273
+ * @param userInfo - The notification payload from the push notification
274
+ * @param applicationState - The app state when the notification was opened ('active', 'inactive', 'background')
275
+ * @param authorizationStatus - Current push authorization status
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * import { handlePushOpened } from 'attentive-react-native-sdk';
280
+ *
281
+ * // In your notification handler:
282
+ * handlePushOpened(
283
+ * notification.data,
284
+ * 'background',
285
+ * 'authorized'
286
+ * );
287
+ * ```
288
+ */
289
+ function handlePushOpened(userInfo, applicationState, authorizationStatus) {
290
+ AttentiveReactNativeSdk.handlePushOpened(userInfo, applicationState, authorizationStatus);
291
+ }
292
+
293
+ /**
294
+ * Handle when a push notification arrives while the app is in the foreground.
295
+ * Call this from your notification handler when a notification is received while the app is active.
296
+ *
297
+ * On iOS, this allows the Attentive SDK to track the notification event.
298
+ * On Android, this is currently a no-op (TODO: implement FCM integration).
299
+ *
300
+ * @param userInfo - The notification payload from the push notification
301
+ *
302
+ * @example
303
+ * ```typescript
304
+ * import { handleForegroundNotification } from 'attentive-react-native-sdk';
305
+ *
306
+ * // In your notification handler when app is in foreground:
307
+ * handleForegroundNotification(notification.data);
308
+ * ```
309
+ */
310
+ function handleForegroundNotification(userInfo) {
311
+ AttentiveReactNativeSdk.handleForegroundNotification(userInfo);
312
+ }
313
+
314
+ /**
315
+ * Handle a push notification when the app is in the foreground (active state).
316
+ * This is the React Native equivalent of the native iOS handleForegroundPush method.
317
+ *
318
+ * Call this when you receive a notification response and the app state is 'active'.
319
+ * This is part of implementing the native iOS pattern:
320
+ * ```swift
321
+ * case .active:
322
+ * self.attentiveSdk?.handleForegroundPush(response: response, authorizationStatus: authStatus)
323
+ * ```
324
+ *
325
+ * On iOS, this properly tracks foreground push notifications.
326
+ * On Android, this is currently a no-op (TODO: implement FCM integration).
327
+ *
328
+ * @param userInfo - The notification payload from the push notification
329
+ * @param authorizationStatus - Current push authorization status
330
+ *
331
+ * @example
332
+ * ```typescript
333
+ * import { handleForegroundPush } from 'attentive-react-native-sdk';
334
+ * import { AppState } from 'react-native';
335
+ *
336
+ * // In your notification handler:
337
+ * const appState = AppState.currentState;
338
+ * if (appState === 'active') {
339
+ * handleForegroundPush(notification.data, 'authorized');
340
+ * }
341
+ * ```
342
+ */
343
+ function handleForegroundPush(userInfo, authorizationStatus) {
344
+ AttentiveReactNativeSdk.handleForegroundPush(userInfo, authorizationStatus);
345
+ }
346
+
347
+ /**
348
+ * Handle when a push notification is opened by the user (app in background/inactive state).
349
+ * This is the React Native equivalent of the native iOS handlePushOpen method.
350
+ *
351
+ * Call this when you receive a notification response and the app state is 'background' or 'inactive'.
352
+ * This is part of implementing the native iOS pattern:
353
+ * ```swift
354
+ * case .background, .inactive:
355
+ * self.attentiveSdk?.handlePushOpen(response: response, authorizationStatus: authStatus)
356
+ * ```
357
+ *
358
+ * On iOS, this properly tracks push notification opens.
359
+ * On Android, this is currently a no-op (TODO: implement FCM integration).
360
+ *
361
+ * @param userInfo - The notification payload from the push notification
362
+ * @param authorizationStatus - Current push authorization status
363
+ *
364
+ * @example
365
+ * ```typescript
366
+ * import { handlePushOpen } from 'attentive-react-native-sdk';
367
+ * import { AppState } from 'react-native';
368
+ *
369
+ * // In your notification handler:
370
+ * const appState = AppState.currentState;
371
+ * if (appState === 'background' || appState === 'inactive') {
372
+ * handlePushOpen(notification.data, 'authorized');
373
+ * }
374
+ * ```
375
+ */
376
+ function handlePushOpen(userInfo, authorizationStatus) {
377
+ AttentiveReactNativeSdk.handlePushOpen(userInfo, authorizationStatus);
67
378
  }
68
- exports.Attentive = Attentive;
69
379
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","AttentiveReactNativeSdk","NativeModules","Proxy","get","Error","Mode","exports","Attentive","initialize","configuration","identify","userIdentifiers","clearUser","triggerCreative","creativeId","arguments","length","undefined","destroyCreative","updateDomain","domain","recordProductViewEvent","productViewEvent","recordAddToCartEvent","addToCartEvent","recordPurchaseEvent","purchaseEvent","recordCustomEvent","customEvent","invokeAttentiveDebugHelper","exportDebugLogs"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQA,MAAMC,aAAa,GAChB,qFAAoF,GACrFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,uBAAuB,GAAGC,0BAAa,CAACD,uBAAuB,GACjEC,0BAAa,CAACD,uBAAuB,GACrC,IAAIE,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACT,aAAa,CAAC;EAChC;AACF,CAAC,CACF;AAAC,IAEMU,IAAI,0BAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAA,OAAJA,IAAI;AAAA;AAAAC,OAAA,CAAAD,IAAA,GAAAA,IAAA;AAqBT,MAAME,SAAS,CAAC;EACrB,OAAOC,UAAUA,CAACC,aAAqC,EAAQ;IAC7DT,uBAAuB,CAACQ,UAAU,CAACC,aAAa,CAAC;EACnD;EAEA,OAAOC,QAAQA,CAACC,eAAgC,EAAQ;IACtDX,uBAAuB,CAACU,QAAQ,CAACC,eAAe,CAAC;EACnD;EAEA,OAAOC,SAASA,CAAA,EAAS;IACvBZ,uBAAuB,CAACY,SAAS,EAAE;EACrC;EAEA,OAAOC,eAAeA,CAAA,EAAyC;IAAA,IAAxCC,UAAyB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;IACrDf,uBAAuB,CAACa,eAAe,CAACC,UAAU,CAAC;EACrD;EAEA,OAAOI,eAAeA,CAAA,EAAS;IAC7BlB,uBAAuB,CAACkB,eAAe,EAAE;EAC3C;EAEA,OAAOC,YAAYA,CAACC,MAAc,EAAQ;IACxCpB,uBAAuB,CAACmB,YAAY,CAACC,MAAM,CAAC;EAC9C;EAEA,OAAOC,sBAAsBA,CAACC,gBAAkC,EAAQ;IACtEtB,uBAAuB,CAACqB,sBAAsB,CAACC,gBAAgB,CAAC;EAClE;EAEA,OAAOC,oBAAoBA,CAACC,cAA8B,EAAQ;IAChExB,uBAAuB,CAACuB,oBAAoB,CAACC,cAAc,CAAC;EAC9D;EAEA,OAAOC,mBAAmBA,CAACC,aAA4B,EAAQ;IAC7D1B,uBAAuB,CAACyB,mBAAmB,CAACC,aAAa,CAAC;EAC5D;EAEA,OAAOC,iBAAiBA,CAACC,WAAwB,EAAQ;IACvD5B,uBAAuB,CAAC2B,iBAAiB,CAACC,WAAW,CAAC;EACxD;EAEA,OAAOC,0BAA0BA,CAAA,EAAS;IACxC7B,uBAAuB,CAAC6B,0BAA0B,EAAE;EACtD;;EAEA;AACF;AACA;AACA;AACA;EACE,aAAaC,eAAeA,CAAA,EAAoB;IAC9C,OAAO9B,uBAAuB,CAAC8B,eAAe,EAAE;EAClD;AACF;AAACxB,OAAA,CAAAC,SAAA,GAAAA,SAAA"}
1
+ {"version":3,"names":["_reactNative","require","_NativeAttentiveReactNativeSdk","_interopRequireDefault","obj","__esModule","default","LINKING_ERROR","Platform","select","ios","AttentiveReactNativeSdk","NativeAttentiveReactNativeSdkModule","Proxy","get","Error","initialize","configuration","attentiveDomain","mode","skipFatigueOnCreatives","enableDebugger","triggerCreative","creativeId","destroyCreative","updateDomain","domain","identify","identifiers","phone","email","klaviyoId","shopifyId","clientUserId","customIdentifiers","clearUser","recordAddToCartEvent","attrs","items","deeplink","recordProductViewEvent","recordPurchaseEvent","orderId","cartId","cartCoupon","recordCustomEvent","type","properties","invokeAttentiveDebugHelper","exportDebugLogs","registerForPushNotifications","registerDeviceToken","token","authorizationStatus","registerDeviceTokenWithCallback","callback","handleRegularOpen","console","log","handlePushOpened","userInfo","applicationState","handleForegroundNotification","handleForegroundPush","handlePushOpen"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"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AACwC,mBAAmB,CAACC,KAAK,EAAEC,mBAAmB,CAAC;AACzE;;AAEA;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,SAASC,+BAA+BA,CACtCF,KAAa,EACbC,mBAA4C,EAC5CE,QAKS,EACH;EACN5C,uBAAuB,CAAC2C,+BAA+B,CACrDF,KAAK,EACLC,mBAAmB,EACnBE,QACF,CAAC;AACH;;AAEA;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAACH,mBAA4C,EAAQ;EAC7EI,OAAO,CAACC,GAAG,CAAC,6DAA6D,CAAC;EAC1ED,OAAO,CAACC,GAAG,CAAC,4BAA4BL,mBAAmB,EAAE,CAAC;EAC9DI,OAAO,CAACC,GAAG,CACT,mEACF,CAAC;EAED/C,uBAAuB,CAAC6C,iBAAiB,CAACH,mBAAmB,CAAC;EAE9DI,OAAO,CAACC,GAAG,CAAC,mDAAmD,CAAC;AAClE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CACvBC,QAAkC,EAClCC,gBAAkC,EAClCR,mBAA4C,EACtC;EACN1C,uBAAuB,CAACgD,gBAAgB,CACtCC,QAAQ,EACRC,gBAAgB,EAChBR,mBACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASS,4BAA4BA,CACnCF,QAAkC,EAC5B;EACNjD,uBAAuB,CAACmD,4BAA4B,CAACF,QAAkB,CAAC;AAC1E;;AAEA;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,SAASG,oBAAoBA,CAC3BH,QAAkC,EAClCP,mBAA4C,EACtC;EACN1C,uBAAuB,CAACoD,oBAAoB,CAC1CH,QAAQ,EACRP,mBACF,CAAC;AACH;;AAEA;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,SAASW,cAAcA,CACrBJ,QAAkC,EAClCP,mBAA4C,EACtC;EACN1C,uBAAuB,CAACqD,cAAc,CACpCJ,QAAQ,EACRP,mBACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import { TurboModuleRegistry, NativeModules } from "react-native";
2
+ // Try to load via TurboModule first (new architecture)
3
+ // Fall back to NativeModules for old architecture
4
+ const isTurboModuleEnabled = global.__turboModuleProxy != null;
5
+ const AttentiveReactNativeSdkModule = isTurboModuleEnabled ? TurboModuleRegistry.get("AttentiveReactNativeSdk") : NativeModules.AttentiveReactNativeSdk;
6
+ export default AttentiveReactNativeSdkModule;
7
+ //# sourceMappingURL=NativeAttentiveReactNativeSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TurboModuleRegistry","NativeModules","isTurboModuleEnabled","global","__turboModuleProxy","AttentiveReactNativeSdkModule","get","AttentiveReactNativeSdk"],"sourceRoot":"../../src","sources":["NativeAttentiveReactNativeSdk.ts"],"mappings":"AACA,SAASA,mBAAmB,EAAEC,aAAa,QAAQ,cAAc;AA8IjE;AACA;AACA,MAAMC,oBAAoB,GAAIC,MAAM,CAASC,kBAAkB,IAAI,IAAI;AAEvE,MAAMC,6BAA6B,GAAGH,oBAAoB,GACtDF,mBAAmB,CAACM,GAAG,CAAO,yBAAyB,CAAC,GACxDL,aAAa,CAACM,uBAAuB;AAEzC,eAAeF,6BAA6B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../src","sources":["eventTypes.tsx"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["eventTypes.tsx"],"mappings":"","ignoreList":[]}