@attentive-mobile/attentive-react-native-sdk 2.0.0-beta.5 → 2.0.0-beta.7
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 +117 -11
- package/android/build.gradle +4 -1
- package/android/src/main/kotlin/com/attentivereactnativesdk/AttentiveNotificationStore.kt +60 -0
- package/android/src/main/kotlin/com/attentivereactnativesdk/AttentivePushHelper.kt +15 -7
- package/android/src/main/kotlin/com/attentivereactnativesdk/AttentiveReactNativeSdkModule.kt +370 -140
- package/android/src/test/kotlin/com/attentivereactnativesdk/AttentiveNotificationStoreTest.kt +103 -0
- package/attentive-react-native-sdk.podspec +1 -1
- package/ios/AttentiveReactNativeSdk.mm +17 -2
- package/ios/AttentiveReactNativeSdk.xcodeproj/project.xcworkspace/xcuserdata/zheref.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Bridging/ATTNNativeSDK.swift +116 -46
- package/ios/Bridging/AttentiveSDKManager.swift +196 -27
- package/ios/Podfile +1 -1
- package/lib/commonjs/NativeAttentiveReactNativeSdk.js +1 -1
- package/lib/commonjs/NativeAttentiveReactNativeSdk.js.map +1 -1
- package/lib/commonjs/eventTypes.js.map +1 -1
- package/lib/commonjs/index.js +50 -17
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeAttentiveReactNativeSdk.js +2 -2
- package/lib/module/NativeAttentiveReactNativeSdk.js.map +1 -1
- package/lib/module/eventTypes.js.map +1 -1
- package/lib/module/index.js +50 -18
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/NativeAttentiveReactNativeSdk.d.ts +12 -1
- package/lib/typescript/NativeAttentiveReactNativeSdk.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +46 -18
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/NativeAttentiveReactNativeSdk.ts +69 -52
- package/src/index.tsx +53 -17
|
@@ -8,7 +8,7 @@ var _reactNative = require("react-native");
|
|
|
8
8
|
// Try to load via TurboModule first (new architecture)
|
|
9
9
|
// Fall back to NativeModules for old architecture
|
|
10
10
|
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
11
|
-
const AttentiveReactNativeSdkModule = isTurboModuleEnabled ? _reactNative.TurboModuleRegistry.get(
|
|
11
|
+
const AttentiveReactNativeSdkModule = isTurboModuleEnabled ? _reactNative.TurboModuleRegistry.get('AttentiveReactNativeSdk') : _reactNative.NativeModules.AttentiveReactNativeSdk;
|
|
12
12
|
var _default = AttentiveReactNativeSdkModule;
|
|
13
13
|
exports.default = _default;
|
|
14
14
|
//# sourceMappingURL=NativeAttentiveReactNativeSdk.js.map
|
|
@@ -1 +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;
|
|
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;AAwKA;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;AAAA,IAAAC,QAAA,GAE1BL,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":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.clearUser = clearUser;
|
|
7
7
|
exports.destroyCreative = destroyCreative;
|
|
8
8
|
exports.exportDebugLogs = exportDebugLogs;
|
|
9
|
+
exports.getInitialPushNotification = getInitialPushNotification;
|
|
9
10
|
exports.getPushAuthorizationStatus = getPushAuthorizationStatus;
|
|
10
11
|
exports.handleForegroundNotification = handleForegroundNotification;
|
|
11
12
|
exports.handleForegroundPush = handleForegroundPush;
|
|
@@ -38,7 +39,12 @@ const AttentiveReactNativeSdk = _NativeAttentiveReactNativeSdk.default ? _Native
|
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
|
-
* Initialize the Attentive SDK with the provided configuration
|
|
42
|
+
* Initialize the Attentive SDK with the provided configuration.
|
|
43
|
+
* This is the only supported entry point: the app (e.g. Bonni) must call this from TypeScript
|
|
44
|
+
* once at startup; the call is forwarded to the native module on each platform (iOS/Android),
|
|
45
|
+
* which then initializes the platform Attentive SDK. Native code must not initialize the SDK
|
|
46
|
+
* on its own (e.g. in Application onCreate or AppDelegate).
|
|
47
|
+
*
|
|
42
48
|
* @param configuration - Configuration object for the Attentive SDK
|
|
43
49
|
*/
|
|
44
50
|
function initialize(configuration) {
|
|
@@ -332,17 +338,16 @@ function handleForegroundNotification(userInfo) {
|
|
|
332
338
|
|
|
333
339
|
/**
|
|
334
340
|
* Handle a push notification when the app is in the foreground (active state).
|
|
335
|
-
* This is the React Native equivalent of the native iOS handleForegroundPush method.
|
|
336
341
|
*
|
|
337
342
|
* Call this when you receive a notification response and the app state is 'active'.
|
|
338
|
-
* This is part of implementing the native iOS pattern:
|
|
339
|
-
* ```swift
|
|
340
|
-
* case .active:
|
|
341
|
-
* self.attentiveSdk?.handleForegroundPush(response: response, authorizationStatus: authStatus)
|
|
342
|
-
* ```
|
|
343
343
|
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
344
|
+
* **iOS prerequisite:** Your AppDelegate's
|
|
345
|
+
* `userNotificationCenter(_:didReceive:withCompletionHandler:)` must call
|
|
346
|
+
* `AttentiveSDKManager.shared.handleNotificationResponse(response)` so that
|
|
347
|
+
* the SDK can cache the `UNNotificationResponse` required by the native iOS SDK.
|
|
348
|
+
* Without that one line of native code, this function cannot track the event.
|
|
349
|
+
*
|
|
350
|
+
* On Android, this tracks the foreground push as a custom event.
|
|
346
351
|
*
|
|
347
352
|
* @param userInfo - The notification payload from the push notification
|
|
348
353
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -365,17 +370,16 @@ function handleForegroundPush(userInfo, authorizationStatus) {
|
|
|
365
370
|
|
|
366
371
|
/**
|
|
367
372
|
* Handle when a push notification is opened by the user (app in background/inactive state).
|
|
368
|
-
* This is the React Native equivalent of the native iOS handlePushOpen method.
|
|
369
373
|
*
|
|
370
374
|
* Call this when you receive a notification response and the app state is 'background' or 'inactive'.
|
|
371
|
-
* This is part of implementing the native iOS pattern:
|
|
372
|
-
* ```swift
|
|
373
|
-
* case .background, .inactive:
|
|
374
|
-
* self.attentiveSdk?.handlePushOpen(response: response, authorizationStatus: authStatus)
|
|
375
|
-
* ```
|
|
376
375
|
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
376
|
+
* **iOS prerequisite:** Your AppDelegate's
|
|
377
|
+
* `userNotificationCenter(_:didReceive:withCompletionHandler:)` must call
|
|
378
|
+
* `AttentiveSDKManager.shared.handleNotificationResponse(response)` so that
|
|
379
|
+
* the SDK can cache the `UNNotificationResponse` required by the native iOS SDK.
|
|
380
|
+
* Without that one line of native code, this function cannot track the event.
|
|
381
|
+
*
|
|
382
|
+
* On Android, this tracks the push open as a custom event.
|
|
379
383
|
*
|
|
380
384
|
* @param userInfo - The notification payload from the push notification
|
|
381
385
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -395,4 +399,33 @@ function handleForegroundPush(userInfo, authorizationStatus) {
|
|
|
395
399
|
function handlePushOpen(userInfo, authorizationStatus) {
|
|
396
400
|
AttentiveReactNativeSdk.handlePushOpen(userInfo, authorizationStatus);
|
|
397
401
|
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Returns the push notification payload that launched the app from a killed state
|
|
405
|
+
* (i.e. the user tapped an FCM notification while the app was not running) and clears
|
|
406
|
+
* it so it is only delivered once.
|
|
407
|
+
*
|
|
408
|
+
* **Android only.** On iOS, use `PushNotificationIOS.getInitialNotification()` to
|
|
409
|
+
* achieve the same result — the Attentive iOS SDK event is tracked natively in
|
|
410
|
+
* `AppDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:)` via
|
|
411
|
+
* `AttentiveSDKManager.shared`.
|
|
412
|
+
*
|
|
413
|
+
* Call this once at app startup (after `initialize()`) to detect and handle the
|
|
414
|
+
* killed-state push-open scenario:
|
|
415
|
+
*
|
|
416
|
+
* ```typescript
|
|
417
|
+
* const initial = await getInitialPushNotification()
|
|
418
|
+
* if (initial) {
|
|
419
|
+
* const authStatus = await getPushAuthorizationStatus()
|
|
420
|
+
* handlePushOpen(initial as PushNotificationUserInfo, authStatus)
|
|
421
|
+
* }
|
|
422
|
+
* ```
|
|
423
|
+
*
|
|
424
|
+
* @returns A promise that resolves to the notification data object, or `null` if the
|
|
425
|
+
* app was not launched via a push notification tap.
|
|
426
|
+
*/
|
|
427
|
+
async function getInitialPushNotification() {
|
|
428
|
+
const result = await AttentiveReactNativeSdk.getInitialPushNotification();
|
|
429
|
+
return result;
|
|
430
|
+
}
|
|
398
431
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
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","getPushAuthorizationStatus","registerDeviceToken","token","authorizationStatus","registerDeviceTokenWithCallback","callback","handleRegularOpen","console","log","handlePushOpened","userInfo","applicationState","handleForegroundNotification","handleForegroundPush","handlePushOpen"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"
|
|
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","getPushAuthorizationStatus","registerDeviceToken","token","authorizationStatus","registerDeviceTokenWithCallback","callback","handleRegularOpen","console","log","handlePushOpened","userInfo","applicationState","handleForegroundNotification","handleForegroundPush","handlePushOpen","getInitialPushNotification","result"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAcA,IAAAC,8BAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEwC,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,E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0B,CAAC,CAAC;AAC7D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,mBAAmBA,CAC1BC,KAAa,EACbC,mBAA4C,EACtC;EACN3C,uBAAuB,CAACyC,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;EACN7C,uBAAuB,CAAC4C,+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;EAEDhD,uBAAuB,CAAC8C,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;EACN3C,uBAAuB,CAACiD,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;EACNlD,uBAAuB,CAACoD,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,SAASG,oBAAoBA,CAC3BH,QAAkC,EAClCP,mBAA4C,EACtC;EACN3C,uBAAuB,CAACqD,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,SAASW,cAAcA,CACrBJ,QAAkC,EAClCP,mBAA4C,EACtC;EACN3C,uBAAuB,CAACsD,cAAc,CACpCJ,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,eAAeY,0BAA0BA,CAAA,EAG/B;EACR,MAAMC,MAAM,GAAG,MAAMxD,uBAAuB,CAACuD,0BAA0B,CAAC,CAAC;EACzE,OAAOC,MAAM;AACf","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TurboModuleRegistry, NativeModules } from
|
|
1
|
+
import { TurboModuleRegistry, NativeModules } from 'react-native';
|
|
2
2
|
// Try to load via TurboModule first (new architecture)
|
|
3
3
|
// Fall back to NativeModules for old architecture
|
|
4
4
|
const isTurboModuleEnabled = global.__turboModuleProxy != null;
|
|
5
|
-
const AttentiveReactNativeSdkModule = isTurboModuleEnabled ? TurboModuleRegistry.get(
|
|
5
|
+
const AttentiveReactNativeSdkModule = isTurboModuleEnabled ? TurboModuleRegistry.get('AttentiveReactNativeSdk') : NativeModules.AttentiveReactNativeSdk;
|
|
6
6
|
export default AttentiveReactNativeSdkModule;
|
|
7
7
|
//# sourceMappingURL=NativeAttentiveReactNativeSdk.js.map
|
|
@@ -1 +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;
|
|
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;AAwKjE;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":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -11,7 +11,12 @@ const AttentiveReactNativeSdk = NativeAttentiveReactNativeSdkModule ? NativeAtte
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Initialize the Attentive SDK with the provided configuration
|
|
14
|
+
* Initialize the Attentive SDK with the provided configuration.
|
|
15
|
+
* This is the only supported entry point: the app (e.g. Bonni) must call this from TypeScript
|
|
16
|
+
* once at startup; the call is forwarded to the native module on each platform (iOS/Android),
|
|
17
|
+
* which then initializes the platform Attentive SDK. Native code must not initialize the SDK
|
|
18
|
+
* on its own (e.g. in Application onCreate or AppDelegate).
|
|
19
|
+
*
|
|
15
20
|
* @param configuration - Configuration object for the Attentive SDK
|
|
16
21
|
*/
|
|
17
22
|
function initialize(configuration) {
|
|
@@ -305,17 +310,16 @@ function handleForegroundNotification(userInfo) {
|
|
|
305
310
|
|
|
306
311
|
/**
|
|
307
312
|
* Handle a push notification when the app is in the foreground (active state).
|
|
308
|
-
* This is the React Native equivalent of the native iOS handleForegroundPush method.
|
|
309
313
|
*
|
|
310
314
|
* Call this when you receive a notification response and the app state is 'active'.
|
|
311
|
-
* This is part of implementing the native iOS pattern:
|
|
312
|
-
* ```swift
|
|
313
|
-
* case .active:
|
|
314
|
-
* self.attentiveSdk?.handleForegroundPush(response: response, authorizationStatus: authStatus)
|
|
315
|
-
* ```
|
|
316
315
|
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
316
|
+
* **iOS prerequisite:** Your AppDelegate's
|
|
317
|
+
* `userNotificationCenter(_:didReceive:withCompletionHandler:)` must call
|
|
318
|
+
* `AttentiveSDKManager.shared.handleNotificationResponse(response)` so that
|
|
319
|
+
* the SDK can cache the `UNNotificationResponse` required by the native iOS SDK.
|
|
320
|
+
* Without that one line of native code, this function cannot track the event.
|
|
321
|
+
*
|
|
322
|
+
* On Android, this tracks the foreground push as a custom event.
|
|
319
323
|
*
|
|
320
324
|
* @param userInfo - The notification payload from the push notification
|
|
321
325
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -338,17 +342,16 @@ function handleForegroundPush(userInfo, authorizationStatus) {
|
|
|
338
342
|
|
|
339
343
|
/**
|
|
340
344
|
* Handle when a push notification is opened by the user (app in background/inactive state).
|
|
341
|
-
* This is the React Native equivalent of the native iOS handlePushOpen method.
|
|
342
345
|
*
|
|
343
346
|
* Call this when you receive a notification response and the app state is 'background' or 'inactive'.
|
|
344
|
-
* This is part of implementing the native iOS pattern:
|
|
345
|
-
* ```swift
|
|
346
|
-
* case .background, .inactive:
|
|
347
|
-
* self.attentiveSdk?.handlePushOpen(response: response, authorizationStatus: authStatus)
|
|
348
|
-
* ```
|
|
349
347
|
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
348
|
+
* **iOS prerequisite:** Your AppDelegate's
|
|
349
|
+
* `userNotificationCenter(_:didReceive:withCompletionHandler:)` must call
|
|
350
|
+
* `AttentiveSDKManager.shared.handleNotificationResponse(response)` so that
|
|
351
|
+
* the SDK can cache the `UNNotificationResponse` required by the native iOS SDK.
|
|
352
|
+
* Without that one line of native code, this function cannot track the event.
|
|
353
|
+
*
|
|
354
|
+
* On Android, this tracks the push open as a custom event.
|
|
352
355
|
*
|
|
353
356
|
* @param userInfo - The notification payload from the push notification
|
|
354
357
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -368,7 +371,36 @@ function handleForegroundPush(userInfo, authorizationStatus) {
|
|
|
368
371
|
function handlePushOpen(userInfo, authorizationStatus) {
|
|
369
372
|
AttentiveReactNativeSdk.handlePushOpen(userInfo, authorizationStatus);
|
|
370
373
|
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Returns the push notification payload that launched the app from a killed state
|
|
377
|
+
* (i.e. the user tapped an FCM notification while the app was not running) and clears
|
|
378
|
+
* it so it is only delivered once.
|
|
379
|
+
*
|
|
380
|
+
* **Android only.** On iOS, use `PushNotificationIOS.getInitialNotification()` to
|
|
381
|
+
* achieve the same result — the Attentive iOS SDK event is tracked natively in
|
|
382
|
+
* `AppDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:)` via
|
|
383
|
+
* `AttentiveSDKManager.shared`.
|
|
384
|
+
*
|
|
385
|
+
* Call this once at app startup (after `initialize()`) to detect and handle the
|
|
386
|
+
* killed-state push-open scenario:
|
|
387
|
+
*
|
|
388
|
+
* ```typescript
|
|
389
|
+
* const initial = await getInitialPushNotification()
|
|
390
|
+
* if (initial) {
|
|
391
|
+
* const authStatus = await getPushAuthorizationStatus()
|
|
392
|
+
* handlePushOpen(initial as PushNotificationUserInfo, authStatus)
|
|
393
|
+
* }
|
|
394
|
+
* ```
|
|
395
|
+
*
|
|
396
|
+
* @returns A promise that resolves to the notification data object, or `null` if the
|
|
397
|
+
* app was not launched via a push notification tap.
|
|
398
|
+
*/
|
|
399
|
+
async function getInitialPushNotification() {
|
|
400
|
+
const result = await AttentiveReactNativeSdk.getInitialPushNotification();
|
|
401
|
+
return result;
|
|
402
|
+
}
|
|
371
403
|
export { initialize, triggerCreative, destroyCreative, updateDomain, identify, clearUser, recordAddToCartEvent, recordProductViewEvent, recordPurchaseEvent, recordCustomEvent, invokeAttentiveDebugHelper, exportDebugLogs,
|
|
372
404
|
// Push Notification Methods
|
|
373
|
-
registerForPushNotifications, getPushAuthorizationStatus, registerDeviceToken, registerDeviceTokenWithCallback, handleRegularOpen, handlePushOpened, handleForegroundNotification, handleForegroundPush, handlePushOpen };
|
|
405
|
+
registerForPushNotifications, getPushAuthorizationStatus, registerDeviceToken, registerDeviceTokenWithCallback, handleRegularOpen, handlePushOpened, handleForegroundNotification, handleForegroundPush, handlePushOpen, getInitialPushNotification };
|
|
374
406
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","NativeAttentiveReactNativeSdkModule","LINKING_ERROR","select","ios","default","AttentiveReactNativeSdk","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","getPushAuthorizationStatus","registerDeviceToken","token","authorizationStatus","registerDeviceTokenWithCallback","callback","handleRegularOpen","console","log","handlePushOpened","userInfo","applicationState","handleForegroundNotification","handleForegroundPush","handlePushOpen"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAcvC,OAAOC,mCAAmC,MAEnC,iCAAiC;AAExC,MAAMC,aAAa,
|
|
1
|
+
{"version":3,"names":["Platform","NativeAttentiveReactNativeSdkModule","LINKING_ERROR","select","ios","default","AttentiveReactNativeSdk","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","getPushAuthorizationStatus","registerDeviceToken","token","authorizationStatus","registerDeviceTokenWithCallback","callback","handleRegularOpen","console","log","handlePushOpened","userInfo","applicationState","handleForegroundNotification","handleForegroundPush","handlePushOpen","getInitialPushNotification","result"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAcvC,OAAOC,mCAAmC,MAEnC,iCAAiC;AAExC,MAAMC,aAAa,GACjB,qFAAqF,GACrFF,QAAQ,CAACG,MAAM,CAAC;EACdC,GAAG,EAAE,gCAAgC;EACrCC,OAAO,EAAE;AACX,CAAC,CAAC,GACF,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,uBAAuB,GAC3BL,mCAAmC,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ACA;AACA;AACA;AACA,SAASC,sBAAsBA,CAACH,KAAkB,EAAE;EAClDzB,uBAAuB,CAAC4B,sBAAsB,CAACH,KAAK,CAACC,KAAK,EAAED,KAAK,CAACE,QAAQ,CAAC;AAC7E;;AAEA;AACA;AACA;AACA;AACA,SAASE,mBAAmBA,CAACJ,KAAe,EAAE;EAC5CzB,uBAAuB,CAAC6B,mBAAmB,CACzCJ,KAAK,CAACC,KAAK,EACXD,KAAK,CAACK,OAAO,EACbL,KAAK,CAACM,MAAM,EACZN,KAAK,CAACO,UACR,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAACR,KAAkB,EAAE;EAC7CzB,uBAAuB,CAACiC,iBAAiB,CAACR,KAAK,CAACS,IAAI,EAAET,KAAK,CAACU,UAAU,CAAC;AACzE;;AAEA;AACA;AACA;AACA,SAASC,0BAA0BA,CAAA,EAAG;EACpCpC,uBAAuB,CAACoC,0BAA0B,CAAC,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CAAA,EAAoB;EAC1C,OAAOrC,uBAAuB,CAACqC,eAAe,CAAC,CAAC;AAClD;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,4BAA4BA,CAAA,EAAS;EAC5CtC,uBAAuB,CAACsC,4BAA4B,CAAC,CAAC;AACxD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,0BAA0BA,CAAA,EAAqC;EACtE,OAAOvC,uBAAuB,CAACuC,0BAA0B,CAAC,CAAC;AAC7D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,mBAAmBA,CAC1BC,KAAa,EACbC,mBAA4C,EACtC;EACN1C,uBAAuB,CAACwC,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,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,SAASW,cAAcA,CACrBJ,QAAkC,EAClCP,mBAA4C,EACtC;EACN1C,uBAAuB,CAACqD,cAAc,CACpCJ,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,eAAeY,0BAA0BA,CAAA,EAG/B;EACR,MAAMC,MAAM,GAAG,MAAMvD,uBAAuB,CAACsD,0BAA0B,CAAC,CAAC;EACzE,OAAOC,MAAM;AACf;AAEA,SACEnD,UAAU,EACVM,eAAe,EACfE,eAAe,EACfC,YAAY,EACZE,QAAQ,EACRQ,SAAS,EACTC,oBAAoB,EACpBI,sBAAsB,EACtBC,mBAAmB,EACnBI,iBAAiB,EACjBG,0BAA0B,EAC1BC,eAAe;AACf;AACAC,4BAA4B,EAC5BC,0BAA0B,EAC1BC,mBAAmB,EACnBG,+BAA+B,EAC/BE,iBAAiB,EACjBG,gBAAgB,EAChBG,4BAA4B,EAC5BC,oBAAoB,EACpBC,cAAc,EACdC,0BAA0B","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TurboModule } from
|
|
1
|
+
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
|
|
2
2
|
export interface Spec extends TurboModule {
|
|
3
3
|
initialize: (attentiveDomain: string, mode: string, skipFatigueOnCreatives: boolean, enableDebugger: boolean) => void;
|
|
4
4
|
triggerCreative: (creativeId?: string) => void;
|
|
@@ -105,6 +105,17 @@ export interface Spec extends TurboModule {
|
|
|
105
105
|
* @param authorizationStatus - Current push authorization status
|
|
106
106
|
*/
|
|
107
107
|
handlePushOpen: (userInfo: Object, authorizationStatus: string) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Returns the push notification payload that launched the app from a killed state
|
|
110
|
+
* (i.e. the user tapped a notification when the app was not running), then clears it
|
|
111
|
+
* so it is only delivered once.
|
|
112
|
+
*
|
|
113
|
+
* Android only — on iOS use `PushNotificationIOS.getInitialNotification()` instead.
|
|
114
|
+
*
|
|
115
|
+
* @returns Promise resolving to a notification data map, or null if the app was not
|
|
116
|
+
* launched from a push notification tap.
|
|
117
|
+
*/
|
|
118
|
+
getInitialPushNotification: () => Promise<Object | null>;
|
|
108
119
|
}
|
|
109
120
|
declare const _default: Spec | null;
|
|
110
121
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeAttentiveReactNativeSdk.d.ts","sourceRoot":"","sources":["../../src/NativeAttentiveReactNativeSdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8CAA8C,
|
|
1
|
+
{"version":3,"file":"NativeAttentiveReactNativeSdk.d.ts","sourceRoot":"","sources":["../../src/NativeAttentiveReactNativeSdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAA;AAG/E,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,UAAU,EAAE,CACV,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,MAAM,EACZ,sBAAsB,EAAE,OAAO,EAC/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MAAM,EACxB,mBAAmB,EAAE,MAAM,KACxB,IAAI,CAAA;IAET;;;;OAIG;IACH,4BAA4B,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IAExD;;;;;;OAMG;IACH,oBAAoB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,KAAK,IAAI,CAAA;IAE7E;;;;;;OAMG;IACH,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,KAAK,IAAI,CAAA;IAEvE;;;;;;;;;OASG;IACH,0BAA0B,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;CACzD;;AAUD,wBAA2D"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { UserIdentifiers, AttentiveSdkConfiguration, ProductView, Purchase, AddToCart, CustomEvent, Item, PushAuthorizationStatus, ApplicationState, PushNotificationUserInfo, PushRegistrationResult } from './eventTypes';
|
|
2
2
|
/**
|
|
3
|
-
* Initialize the Attentive SDK with the provided configuration
|
|
3
|
+
* Initialize the Attentive SDK with the provided configuration.
|
|
4
|
+
* This is the only supported entry point: the app (e.g. Bonni) must call this from TypeScript
|
|
5
|
+
* once at startup; the call is forwarded to the native module on each platform (iOS/Android),
|
|
6
|
+
* which then initializes the platform Attentive SDK. Native code must not initialize the SDK
|
|
7
|
+
* on its own (e.g. in Application onCreate or AppDelegate).
|
|
8
|
+
*
|
|
4
9
|
* @param configuration - Configuration object for the Attentive SDK
|
|
5
10
|
*/
|
|
6
11
|
declare function initialize(configuration: AttentiveSdkConfiguration): void;
|
|
@@ -229,17 +234,16 @@ declare function handlePushOpened(userInfo: PushNotificationUserInfo, applicatio
|
|
|
229
234
|
declare function handleForegroundNotification(userInfo: PushNotificationUserInfo): void;
|
|
230
235
|
/**
|
|
231
236
|
* Handle a push notification when the app is in the foreground (active state).
|
|
232
|
-
* This is the React Native equivalent of the native iOS handleForegroundPush method.
|
|
233
237
|
*
|
|
234
238
|
* Call this when you receive a notification response and the app state is 'active'.
|
|
235
|
-
* This is part of implementing the native iOS pattern:
|
|
236
|
-
* ```swift
|
|
237
|
-
* case .active:
|
|
238
|
-
* self.attentiveSdk?.handleForegroundPush(response: response, authorizationStatus: authStatus)
|
|
239
|
-
* ```
|
|
240
239
|
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
240
|
+
* **iOS prerequisite:** Your AppDelegate's
|
|
241
|
+
* `userNotificationCenter(_:didReceive:withCompletionHandler:)` must call
|
|
242
|
+
* `AttentiveSDKManager.shared.handleNotificationResponse(response)` so that
|
|
243
|
+
* the SDK can cache the `UNNotificationResponse` required by the native iOS SDK.
|
|
244
|
+
* Without that one line of native code, this function cannot track the event.
|
|
245
|
+
*
|
|
246
|
+
* On Android, this tracks the foreground push as a custom event.
|
|
243
247
|
*
|
|
244
248
|
* @param userInfo - The notification payload from the push notification
|
|
245
249
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -259,17 +263,16 @@ declare function handleForegroundNotification(userInfo: PushNotificationUserInfo
|
|
|
259
263
|
declare function handleForegroundPush(userInfo: PushNotificationUserInfo, authorizationStatus: PushAuthorizationStatus): void;
|
|
260
264
|
/**
|
|
261
265
|
* Handle when a push notification is opened by the user (app in background/inactive state).
|
|
262
|
-
* This is the React Native equivalent of the native iOS handlePushOpen method.
|
|
263
266
|
*
|
|
264
267
|
* Call this when you receive a notification response and the app state is 'background' or 'inactive'.
|
|
265
|
-
* This is part of implementing the native iOS pattern:
|
|
266
|
-
* ```swift
|
|
267
|
-
* case .background, .inactive:
|
|
268
|
-
* self.attentiveSdk?.handlePushOpen(response: response, authorizationStatus: authStatus)
|
|
269
|
-
* ```
|
|
270
268
|
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
269
|
+
* **iOS prerequisite:** Your AppDelegate's
|
|
270
|
+
* `userNotificationCenter(_:didReceive:withCompletionHandler:)` must call
|
|
271
|
+
* `AttentiveSDKManager.shared.handleNotificationResponse(response)` so that
|
|
272
|
+
* the SDK can cache the `UNNotificationResponse` required by the native iOS SDK.
|
|
273
|
+
* Without that one line of native code, this function cannot track the event.
|
|
274
|
+
*
|
|
275
|
+
* On Android, this tracks the push open as a custom event.
|
|
273
276
|
*
|
|
274
277
|
* @param userInfo - The notification payload from the push notification
|
|
275
278
|
* @param authorizationStatus - Current push authorization status
|
|
@@ -287,6 +290,31 @@ declare function handleForegroundPush(userInfo: PushNotificationUserInfo, author
|
|
|
287
290
|
* ```
|
|
288
291
|
*/
|
|
289
292
|
declare function handlePushOpen(userInfo: PushNotificationUserInfo, authorizationStatus: PushAuthorizationStatus): void;
|
|
290
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Returns the push notification payload that launched the app from a killed state
|
|
295
|
+
* (i.e. the user tapped an FCM notification while the app was not running) and clears
|
|
296
|
+
* it so it is only delivered once.
|
|
297
|
+
*
|
|
298
|
+
* **Android only.** On iOS, use `PushNotificationIOS.getInitialNotification()` to
|
|
299
|
+
* achieve the same result — the Attentive iOS SDK event is tracked natively in
|
|
300
|
+
* `AppDelegate.userNotificationCenter(_:didReceive:withCompletionHandler:)` via
|
|
301
|
+
* `AttentiveSDKManager.shared`.
|
|
302
|
+
*
|
|
303
|
+
* Call this once at app startup (after `initialize()`) to detect and handle the
|
|
304
|
+
* killed-state push-open scenario:
|
|
305
|
+
*
|
|
306
|
+
* ```typescript
|
|
307
|
+
* const initial = await getInitialPushNotification()
|
|
308
|
+
* if (initial) {
|
|
309
|
+
* const authStatus = await getPushAuthorizationStatus()
|
|
310
|
+
* handlePushOpen(initial as PushNotificationUserInfo, authStatus)
|
|
311
|
+
* }
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @returns A promise that resolves to the notification data object, or `null` if the
|
|
315
|
+
* app was not launched via a push notification tap.
|
|
316
|
+
*/
|
|
317
|
+
declare function getInitialPushNotification(): Promise<Record<string, string> | null>;
|
|
318
|
+
export { initialize, triggerCreative, destroyCreative, updateDomain, identify, clearUser, recordAddToCartEvent, recordProductViewEvent, recordPurchaseEvent, recordCustomEvent, invokeAttentiveDebugHelper, exportDebugLogs, registerForPushNotifications, getPushAuthorizationStatus, registerDeviceToken, registerDeviceTokenWithCallback, handleRegularOpen, handlePushOpened, handleForegroundNotification, handleForegroundPush, handlePushOpen, getInitialPushNotification, };
|
|
291
319
|
export type { UserIdentifiers, AttentiveSdkConfiguration, ProductView, Purchase, AddToCart, CustomEvent, Item, PushAuthorizationStatus, ApplicationState, PushNotificationUserInfo, PushRegistrationResult, };
|
|
292
320
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,yBAAyB,EACzB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,WAAW,EACX,IAAI,EACJ,uBAAuB,EACvB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,cAAc,CAAA;AA2BrB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,yBAAyB,EACzB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,WAAW,EACX,IAAI,EACJ,uBAAuB,EACvB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,cAAc,CAAA;AA2BrB;;;;;;;;GAQG;AACH,iBAAS,UAAU,CAAC,aAAa,EAAE,yBAAyB,QAO3D;AAED;;;GAGG;AACH,iBAAS,eAAe,CAAC,UAAU,CAAC,EAAE,MAAM,QAE3C;AAED;;GAEG;AACH,iBAAS,eAAe,SAEvB;AAED;;;GAGG;AACH,iBAAS,YAAY,CAAC,MAAM,EAAE,MAAM,QAEnC;AAED;;;GAGG;AACH,iBAAS,QAAQ,CAAC,WAAW,EAAE,eAAe,QAS7C;AAED;;GAEG;AAC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AC3C,IAAI,CAMN;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,4BAA4B,CACnC,QAAQ,EAAE,wBAAwB,GACjC,IAAI,CAEN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,iBAAS,oBAAoB,CAC3B,QAAQ,EAAE,wBAAwB,EAClC,mBAAmB,EAAE,uBAAuB,GAC3C,IAAI,CAKN;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,iBAAS,cAAc,CACrB,QAAQ,EAAE,wBAAwB,EAClC,mBAAmB,EAAE,uBAAuB,GAC3C,IAAI,CAKN;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,iBAAe,0BAA0B,IAAI,OAAO,CAAC,MAAM,CACzD,MAAM,EACN,MAAM,CACP,GAAG,IAAI,CAAC,CAGR;AAED,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EAEf,4BAA4B,EAC5B,0BAA0B,EAC1B,mBAAmB,EACnB,+BAA+B,EAC/B,iBAAiB,EACjB,gBAAgB,EAChB,4BAA4B,EAC5B,oBAAoB,EACpB,cAAc,EACd,0BAA0B,GAC3B,CAAA;AAED,YAAY,EACV,eAAe,EACf,yBAAyB,EACzB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,WAAW,EACX,IAAI,EAEJ,uBAAuB,EACvB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,GACvB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attentive-mobile/attentive-react-native-sdk",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.7",
|
|
4
4
|
"description": "React Native Module for the Attentive SDK",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -180,6 +180,7 @@
|
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
182
|
"dependencies": {
|
|
183
|
-
"@babel/runtime": "^7.27.0"
|
|
183
|
+
"@babel/runtime": "^7.27.0",
|
|
184
|
+
"metro-react-native-babel-preset": "^0.77.0"
|
|
184
185
|
}
|
|
185
186
|
}
|