cordova-plugin-reteno 2.2.0 → 2.2.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 +2 -4
- package/docs/Cordova/Action Buttons/README.md +62 -0
- package/docs/Cordova/AppInbox/README.md +55 -0
- package/docs/Cordova/AppLifeCycleEvents/README.md +80 -0
- package/docs/Cordova/Ecommerce/README.md +144 -0
- package/docs/Cordova/InAppMessages/README.md +72 -0
- package/docs/Cordova/Push notification/README.md +129 -0
- package/docs/Cordova/Recommendations/README.md +62 -0
- package/docs/Cordova/SetupGuide/Android.md +135 -0
- package/docs/Cordova/SetupGuide/IOS.md +325 -0
- package/docs/Cordova/SetupGuide/README.md +91 -0
- package/docs/Cordova/Tracking user behaviour/README.md +52 -0
- package/docs/Cordova/Tracking user information/README.md +112 -0
- package/docs/Ionic/Action Buttons/README.md +66 -0
- package/docs/Ionic/AppInbox/README.md +61 -0
- package/docs/Ionic/AppLifeCycleEvents/README.md +77 -0
- package/docs/Ionic/Ecommerce/README.md +139 -0
- package/docs/Ionic/InAppMessages/README.md +65 -0
- package/docs/Ionic/Push notification/README.md +133 -0
- package/docs/Ionic/Recommendations/README.md +46 -0
- package/docs/Ionic/SetupGuide/Android.md +173 -0
- package/docs/Ionic/SetupGuide/IOS.md +354 -0
- package/docs/Ionic/SetupGuide/README.md +167 -0
- package/docs/Ionic/Tracking user behaviour/README.md +31 -0
- package/docs/Ionic/Tracking user information/README.md +98 -0
- package/package.json +1 -1
- package/plugin.xml +20 -2
- package/scripts/ios-podfile-use-modular-headers.js +109 -0
- package/scripts/validate-install.js +37 -9
- package/src/android/app/build.gradle +1 -1
- package/src/android/app/src/main/java/com/reteno/plugin/RetenoPlugin.java +29 -9
- package/src/android/reteno.gradle +19 -9
- package/src/ios/RetenoPlugin.swift +37 -5
- package/src/ios/RetenoPluginBootstrap.m +117 -0
- package/types/index.ts +1 -1
- package/docs/android.md +0 -264
- package/docs/api.md +0 -734
- package/docs/ios.md +0 -495
package/docs/api.md
DELETED
|
@@ -1,734 +0,0 @@
|
|
|
1
|
-
## API
|
|
2
|
-
|
|
3
|
-
Notes:
|
|
4
|
-
|
|
5
|
-
- Recommended: call `RetenoPlugin.init(...)` once on app startup before calling SDK-dependent methods like `logEvent`, `setUserAttributes`, `setAnonymousUserAttributes`, or `setDeviceToken`.
|
|
6
|
-
- As a convenience, the JS wrapper will auto-call init when you call those methods, but explicit init gives you clearer error handling and predictable timing.
|
|
7
|
-
- All methods that call native code return a `Promise`. Optional `success` / `error` callbacks are still supported for backward compatibility.
|
|
8
|
-
- Android SDK support: see the current Reteno Android SDK compatibility in release notes.
|
|
9
|
-
- Push deeplinks: Reteno can deliver links in push payloads, but routing them to the correct screen in a hybrid app usually requires a separate deeplink solution (for example, Branch.io, custom URL schemes, or Universal/App Links handling in the host app).
|
|
10
|
-
|
|
11
|
-
### Initialization
|
|
12
|
-
|
|
13
|
-
| Method | Supported platform | Description |
|
|
14
|
-
| ---------------------------------------------------------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
-
| [init](../www/cordova-plugin-reteno.js) | iOS, Android | Initializes Reteno SDK. Accepts optional `RetenoInitializeOptions` with `accessKey`, `pauseInAppMessages`, `pausePushInAppMessages`, `inAppMessagesPauseBehaviour` (iOS), `lifecycleTrackingOptions`, `sessionDurationSeconds` (Android 2.9.6+, iOS 2.7.2+), `isAutomaticScreenReportingEnabled` (iOS; see note below) and `isDebugMode`. [Types](../types/index.ts) |
|
|
16
|
-
| [requestNotificationPermission](../www/cordova-plugin-reteno.js) | iOS, Android | Requests push permission (iOS) or `POST_NOTIFICATIONS` (Android 13+). Returns `0` or `1` on Android (`RequestNotificationPermissionResult`) in [types](../types/index.ts). |
|
|
17
|
-
| [setLifecycleTrackingOptions](../www/cordova-plugin-reteno.js) | iOS, Android | Configures automatic tracking for app lifecycle, push subscription, and session events. Android: applies immediately. iOS: supported only before initialization (stored and applied during `init(...)`). [Types](../types/index.ts) |
|
|
18
|
-
|
|
19
|
-
### User data
|
|
20
|
-
|
|
21
|
-
| Method | Supported platform | Description |
|
|
22
|
-
| ---------------------------------------------------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
-
| [setUserAttributes](../www/cordova-plugin-reteno.js) | iOS, Android | Supports `marketId` with the bundled Android 2.9.6+ and iOS 2.7.2+ SDKs. Pass `""` to clear. [Types](../types/index.ts) |
|
|
24
|
-
| [setAnonymousUserAttributes](../www/cordova-plugin-reteno.js) | iOS, Android | Supports `marketId` with the bundled Android 2.9.6+ and iOS 2.7.2+ SDKs. Pass `""` to clear. [Types](../types/index.ts) |
|
|
25
|
-
| [setMultiAccountUserAttributes](../www/cordova-plugin-reteno.js) | iOS, Android | Supports `marketId` with the bundled Android 2.9.6+ and iOS 2.7.2+ SDKs. Pass `""` to clear. [Types](../types/index.ts) |
|
|
26
|
-
|
|
27
|
-
### Event tracking
|
|
28
|
-
|
|
29
|
-
| Method | Supported platform | Description |
|
|
30
|
-
| ---------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
31
|
-
| [logEvent](../www/cordova-plugin-reteno.js) | iOS, Android | [Types](../types/index.ts) |
|
|
32
|
-
| [logEcommerceEvent](../www/cordova-plugin-reteno.js) | iOS, Android | Tracks ecommerce activity (product views, cart updates, orders, search requests, etc.). [Types](../types/index.ts) |
|
|
33
|
-
| [logScreenView](../www/cordova-plugin-reteno.js) | iOS, Android | Logs a screen view for manual tracking. |
|
|
34
|
-
| [forcePushData](../www/cordova-plugin-reteno.js) | iOS, Android | Forces Reteno to sync queued data. On iOS the plugin performs a technical `logEvent(..., forcePush: true)` call under the hood. |
|
|
35
|
-
|
|
36
|
-
### Push notifications
|
|
37
|
-
|
|
38
|
-
| Method | Supported platform | Description |
|
|
39
|
-
| ---------------------------------------------------------------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
40
|
-
| [setDeviceToken](../www/cordova-plugin-reteno.js) | iOS, Android | Forwards the device token to Reteno (use when another plugin owns push callbacks/token, e.g. Firebasex messaging enabled). |
|
|
41
|
-
| [getInitialNotification](../www/cordova-plugin-reteno.js) | iOS, Android | Returns push notification that triggered creating app instance. |
|
|
42
|
-
| [setOnRetenoPushReceivedListener](../www/cordova-plugin-reteno.js) | iOS, Android | Sets listener for newly received push notification. |
|
|
43
|
-
| [removeOnRetenoPushReceivedListener](../www/cordova-plugin-reteno.js) | iOS, Android | Removes listener for push notification received events. |
|
|
44
|
-
| [setOnRetenoNotificationClickedListener](../www/cordova-plugin-reteno.js) | iOS, Android | Sets listener for notification click events. |
|
|
45
|
-
| [removeOnRetenoNotificationClickedListener](../www/cordova-plugin-reteno.js) | iOS, Android | Removes listener for notification click events. |
|
|
46
|
-
| [setOnRetenoPushDismissedListener](../www/cordova-plugin-reteno.js) | Android | Sets listener for push dismissed (swipe) events. |
|
|
47
|
-
| [removeOnRetenoPushDismissedListener](../www/cordova-plugin-reteno.js) | Android | Removes listener for push dismissed (swipe) events. |
|
|
48
|
-
| [setOnRetenoCustomPushReceivedListener](../www/cordova-plugin-reteno.js) | Android | Sets listener for custom push received events. |
|
|
49
|
-
| [removeOnRetenoCustomPushReceivedListener](../www/cordova-plugin-reteno.js) | Android | Removes listener for custom push received events. |
|
|
50
|
-
| [setOnRetenoPushButtonClickedListener](../www/cordova-plugin-reteno.js) | iOS, Android | Sets listener for push notification action button click events. Emits `reteno-push-button-clicked`. [Types](../types/index.ts) |
|
|
51
|
-
| [removeOnRetenoPushButtonClickedListener](../www/cordova-plugin-reteno.js) | iOS, Android | Removes listener for push notification action button click events. |
|
|
52
|
-
| [setNotificationActionHandler](../www/cordova-plugin-reteno.js) | iOS, Android | On iOS, installs the native action button handler when both `enabled` (default: `true`) and `emitEvent` are true — e.g. `{ emitEvent: true }` or `{ enabled: true, emitEvent: true }`. Any other value (e.g. `false`, `null`, `true`, `{ enabled: true }`) clears the handler. On Android, this is a no-op (button clicks are detected automatically). [Types](../types/index.ts) |
|
|
53
|
-
| [setWillPresentNotificationOptions](../www/cordova-plugin-reteno.js) | iOS | Sets presentation options for foreground notifications. Optionally emits `reteno-push-received`. [Types](../types/index.ts) |
|
|
54
|
-
| [setDidReceiveNotificationResponseHandler](../www/cordova-plugin-reteno.js) | iOS | Enables a response handler for notification taps. Optionally emits `reteno-notification-clicked`. [Types](../types/index.ts) |
|
|
55
|
-
| [updateDefaultNotificationChannel](../www/cordova-plugin-reteno.js) | Android | Updates the default notification channel name and description for existing users. [Types](../types/index.ts) |
|
|
56
|
-
| [setNotificationGroupingRule](../www/cordova-plugin-reteno.js) | Android | Groups notifications by a push payload field or a constant group ID. The rule is persisted natively and restored before background push handling. Pass `null` to disable. [Types](../types/index.ts) |
|
|
57
|
-
|
|
58
|
-
### In-app messages
|
|
59
|
-
|
|
60
|
-
Bundled native SDKs support the `DOES_NOT_EQUAL` in-app rule condition: Android SDK 2.9.6+ and iOS SDK 2.7.2+.
|
|
61
|
-
|
|
62
|
-
| Method | Supported platform | Description |
|
|
63
|
-
| --------------------------------------------------------------------------------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
64
|
-
| [pauseInAppMessages](../www/cordova-plugin-reteno.js) | iOS, Android | Pauses or resumes in-app messages at runtime. Pass `true` to pause, `false` to resume. |
|
|
65
|
-
| [setInAppMessagesPauseBehaviour](../www/cordova-plugin-reteno.js) | iOS, Android | Sets how paused in-app messages are handled: `SKIP_IN_APPS` or `POSTPONE_IN_APPS`. [Types](../types/index.ts) |
|
|
66
|
-
| [setOnInAppLifecycleCallback](../www/cordova-plugin-reteno.js) | iOS, Android | Subscribes to in-app status/lifecycle events (beforeDisplay, onDisplay, beforeClose, afterClose, onError). Pass `null` to unsubscribe. [Types](../types/index.ts) |
|
|
67
|
-
| [setOnInAppMessageCustomDataReceivedListener](../www/cordova-plugin-reteno.js) | Android | Sets listener for in-app message custom data events. |
|
|
68
|
-
| [removeOnInAppMessageCustomDataReceivedListener](../www/cordova-plugin-reteno.js) | Android | Removes listener for in-app message custom data events. |
|
|
69
|
-
|
|
70
|
-
### App Inbox
|
|
71
|
-
|
|
72
|
-
| Method | Supported platform | Description |
|
|
73
|
-
| ------------------------------------------------------------------ | ------------------ | ---------------------------------------------------------------------------------------------------------- |
|
|
74
|
-
| [getAppInboxMessages](../www/cordova-plugin-reteno.js) | iOS, Android | Fetches App Inbox messages with pagination. Returns `{ messages, totalPages }`. [Types](../types/index.ts) |
|
|
75
|
-
| [getAppInboxMessagesCount](../www/cordova-plugin-reteno.js) | iOS, Android | Fetches count of App Inbox messages. Returns a number. |
|
|
76
|
-
| [subscribeOnMessagesCountChanged](../www/cordova-plugin-reteno.js) | iOS, Android | Subscribes to App Inbox messages count changes. |
|
|
77
|
-
| [unsubscribeMessagesCountChanged](../www/cordova-plugin-reteno.js) | iOS, Android | Unsubscribes from App Inbox messages count changes. |
|
|
78
|
-
| [markAsOpened](../www/cordova-plugin-reteno.js) | iOS, Android | Marks an App Inbox message as opened. |
|
|
79
|
-
| [markAllMessagesAsOpened](../www/cordova-plugin-reteno.js) | iOS, Android | Marks all App Inbox messages as opened. |
|
|
80
|
-
|
|
81
|
-
### Recommendations
|
|
82
|
-
|
|
83
|
-
| Method | Supported platform | Description |
|
|
84
|
-
| ----------------------------------------------------- | ------------------ | ---------------------------------------------------------------------------------------------------- |
|
|
85
|
-
| [getRecommendations](../www/cordova-plugin-reteno.js) | iOS, Android | Fetches product or category recommendations. Returns `{ recoms: [...] }`. [Types](../types/index.ts) |
|
|
86
|
-
| [logRecommendations](../www/cordova-plugin-reteno.js) | iOS, Android | Sends recommendation impressions or clicks. [Types](../types/index.ts) |
|
|
87
|
-
|
|
88
|
-
### init example
|
|
89
|
-
|
|
90
|
-
Initialize the Reteno SDK with optional configuration. Payload type: `RetenoInitializeOptions` in [types](../types/index.ts).
|
|
91
|
-
|
|
92
|
-
```js
|
|
93
|
-
// Initialize with default options (in-app messages enabled).
|
|
94
|
-
RetenoPlugin.init()
|
|
95
|
-
.then(() => console.log('init: OK'))
|
|
96
|
-
.catch((err) => console.error('init: ERROR', err));
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
```js
|
|
100
|
-
// Initialize with in-app messages paused and lifecycle tracking configured.
|
|
101
|
-
// pauseInAppMessages: pauses all in-app messages until resumed.
|
|
102
|
-
// pausePushInAppMessages: pauses in-app messages triggered by push notifications.
|
|
103
|
-
// inAppMessagesPauseBehaviour: (iOS) defines handling while paused: 'SKIP_IN_APPS' or 'POSTPONE_IN_APPS'.
|
|
104
|
-
// lifecycleTrackingOptions: configures app lifecycle, push subscription, and session event tracking ('ALL', 'NONE', or an object).
|
|
105
|
-
// sessionDurationSeconds (Android 2.9.6+, iOS 2.7.2+): optional session reset duration.
|
|
106
|
-
// isAutomaticScreenReportingEnabled: enables automatic native screen view tracking on iOS.
|
|
107
|
-
// Keep this false in Cordova/Ionic WebView apps (including Android demos).
|
|
108
|
-
// Defaults to false. Note: in Cordova/Ionic apps the UI runs inside a single WebView,
|
|
109
|
-
// so automatic tracking captures native UIViewController transitions (e.g. CDVViewController),
|
|
110
|
-
// NOT your JS screen navigations. For meaningful screen tracking, use logScreenView()
|
|
111
|
-
// manually (e.g. by subscribing to your router's navigation events).
|
|
112
|
-
// On Android the native SDK tracks Fragment transitions, which is equally irrelevant
|
|
113
|
-
// in a WebView-based app — use logScreenView() instead.
|
|
114
|
-
// isDebugMode: enables debug mode for near real-time event monitoring in the Reteno dashboard.
|
|
115
|
-
// Use only with test devices or developer accounts.
|
|
116
|
-
RetenoPlugin.init({
|
|
117
|
-
pauseInAppMessages: true,
|
|
118
|
-
pausePushInAppMessages: false,
|
|
119
|
-
inAppMessagesPauseBehaviour: 'SKIP_IN_APPS', // iOS
|
|
120
|
-
isAutomaticScreenReportingEnabled: false, // keep false for hybrid/WebView apps
|
|
121
|
-
isDebugMode: true, // enables debug mode
|
|
122
|
-
sessionDurationSeconds: 30 * 60, // Android 2.9.6+, iOS 2.7.2+: 30 minutes
|
|
123
|
-
lifecycleTrackingOptions: {
|
|
124
|
-
appLifecycleEnabled: true,
|
|
125
|
-
foregroundLifecycleEnabled: false,
|
|
126
|
-
pushSubscriptionEnabled: true,
|
|
127
|
-
sessionStartEventsEnabled: true,
|
|
128
|
-
sessionEndEventsEnabled: false,
|
|
129
|
-
},
|
|
130
|
-
})
|
|
131
|
-
.then(() => console.log('init: OK'))
|
|
132
|
-
.catch((err) => console.error('init: ERROR', err));
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
```js
|
|
136
|
-
// Shorthand lifecycle tracking values:
|
|
137
|
-
RetenoPlugin.init({ lifecycleTrackingOptions: 'ALL' });
|
|
138
|
-
RetenoPlugin.init({ lifecycleTrackingOptions: 'NONE' });
|
|
139
|
-
// Legacy alias (deprecated): sessionEventsEnabled controls both start/end at once.
|
|
140
|
-
RetenoPlugin.init({ lifecycleTrackingOptions: { sessionEventsEnabled: false } });
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### setUserAttributes payload example
|
|
144
|
-
|
|
145
|
-
```js
|
|
146
|
-
// `externalUserId` is required and must be a non-empty string.
|
|
147
|
-
// `user` is optional (you can omit it or pass null).
|
|
148
|
-
RetenoPlugin.setUserAttributes({
|
|
149
|
-
externalUserId: 'user-123',
|
|
150
|
-
user: {
|
|
151
|
-
userAttributes: {
|
|
152
|
-
email: 'john.doe@example.com',
|
|
153
|
-
phone: '+1234567890',
|
|
154
|
-
firstName: 'John',
|
|
155
|
-
lastName: 'Doe',
|
|
156
|
-
languageCode: 'en',
|
|
157
|
-
timeZone: 'Europe/Kyiv',
|
|
158
|
-
address: {
|
|
159
|
-
region: 'Kyivska',
|
|
160
|
-
town: 'Kyiv',
|
|
161
|
-
address: 'Khreshchatyk St, 1',
|
|
162
|
-
postcode: '01001',
|
|
163
|
-
},
|
|
164
|
-
fields: [{ key: 'plan', value: 'premium' }],
|
|
165
|
-
marketId: 'market_1',
|
|
166
|
-
},
|
|
167
|
-
subscriptionKeys: ['news', 'promotions'],
|
|
168
|
-
groupNamesInclude: ['beta-testers'],
|
|
169
|
-
groupNamesExclude: ['unsubscribed'],
|
|
170
|
-
},
|
|
171
|
-
})
|
|
172
|
-
.then(() => console.log('setUserAttributes: OK'))
|
|
173
|
-
.catch((err) => console.error('setUserAttributes: ERROR', err));
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### setAnonymousUserAttributes payload example
|
|
177
|
-
|
|
178
|
-
```js
|
|
179
|
-
// Anonymous attributes are used before contact identification.
|
|
180
|
-
// Note: Unlike setUserAttributes, this payload does NOT include phone/email.
|
|
181
|
-
RetenoPlugin.setAnonymousUserAttributes({
|
|
182
|
-
firstName: 'John',
|
|
183
|
-
lastName: 'Doe',
|
|
184
|
-
languageCode: 'en',
|
|
185
|
-
timeZone: 'Europe/Kyiv',
|
|
186
|
-
address: {
|
|
187
|
-
region: 'Kyivska',
|
|
188
|
-
town: 'Kyiv',
|
|
189
|
-
address: 'Khreshchatyk St, 1',
|
|
190
|
-
postcode: '01001',
|
|
191
|
-
},
|
|
192
|
-
fields: [{ key: 'utm_source', value: 'google' }],
|
|
193
|
-
marketId: 'market_1',
|
|
194
|
-
})
|
|
195
|
-
.then(() => console.log('setAnonymousUserAttributes: OK'))
|
|
196
|
-
.catch((err) => console.error('setAnonymousUserAttributes: ERROR', err));
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
### setMultiAccountUserAttributes payload example
|
|
200
|
-
|
|
201
|
-
```js
|
|
202
|
-
// Since 2.8.0 it is possible to share push notification token between user accounts.
|
|
203
|
-
// If it is required to receive push notifications on accounts that aren't currently logged in,
|
|
204
|
-
// but they share the same device, always use setMultiAccountUserAttributes instead of setUserAttributes.
|
|
205
|
-
// If you want to switch back to default behavior, just replace usages of
|
|
206
|
-
// setMultiAccountUserAttributes to setUserAttributes. This will roll back to
|
|
207
|
-
// 1 token per device behavior.
|
|
208
|
-
// `externalUserId` is required and must be a non-empty string.
|
|
209
|
-
// `user` is required and must be an object.
|
|
210
|
-
RetenoPlugin.setMultiAccountUserAttributes({
|
|
211
|
-
externalUserId: 'user-123',
|
|
212
|
-
user: {
|
|
213
|
-
userAttributes: {
|
|
214
|
-
email: 'john.doe@example.com',
|
|
215
|
-
phone: '+1234567890',
|
|
216
|
-
firstName: 'John',
|
|
217
|
-
lastName: 'Doe',
|
|
218
|
-
languageCode: 'en',
|
|
219
|
-
timeZone: 'Europe/Kyiv',
|
|
220
|
-
address: {
|
|
221
|
-
region: 'Kyivska',
|
|
222
|
-
town: 'Kyiv',
|
|
223
|
-
address: 'Khreshchatyk St, 1',
|
|
224
|
-
postcode: '01001',
|
|
225
|
-
},
|
|
226
|
-
fields: [{ key: 'plan', value: 'premium' }],
|
|
227
|
-
marketId: 'market_1',
|
|
228
|
-
},
|
|
229
|
-
subscriptionKeys: ['news', 'promotions'],
|
|
230
|
-
groupNamesInclude: ['beta-testers'],
|
|
231
|
-
groupNamesExclude: ['unsubscribed'],
|
|
232
|
-
},
|
|
233
|
-
})
|
|
234
|
-
.then(() => console.log('setMultiAccountUserAttributes: OK'))
|
|
235
|
-
.catch((err) => console.error('setMultiAccountUserAttributes: ERROR', err));
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### setLifecycleTrackingOptions example
|
|
239
|
-
|
|
240
|
-
```js
|
|
241
|
-
// Enable/disable specific lifecycle tracking features.
|
|
242
|
-
// Unspecified fields default to true.
|
|
243
|
-
// Android: applies immediately.
|
|
244
|
-
// iOS: this works only BEFORE SDK initialization (before calling init()).
|
|
245
|
-
// Deprecated: sessionEventsEnabled (if used) toggles both sessionStart and sessionEnd.
|
|
246
|
-
RetenoPlugin.setLifecycleTrackingOptions({
|
|
247
|
-
sessionStartEventsEnabled: true,
|
|
248
|
-
sessionEndEventsEnabled: true,
|
|
249
|
-
})
|
|
250
|
-
.then(() => console.log('setLifecycleTrackingOptions: OK'))
|
|
251
|
-
.catch((err) => console.error('setLifecycleTrackingOptions: ERROR', err));
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
```js
|
|
255
|
-
// Convenience values:
|
|
256
|
-
RetenoPlugin.setLifecycleTrackingOptions('ALL');
|
|
257
|
-
RetenoPlugin.setLifecycleTrackingOptions('NONE');
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
If `init()` has already started/completed on iOS, `setLifecycleTrackingOptions(...)` returns an error.
|
|
261
|
-
Invalid values (anything except `'ALL'`, `'NONE'`, or an object with known fields) return an error.
|
|
262
|
-
|
|
263
|
-
### logEvent payload example
|
|
264
|
-
|
|
265
|
-
Payload type: `LogEventPayload` in [types](../types/index.ts).
|
|
266
|
-
|
|
267
|
-
```js
|
|
268
|
-
RetenoPlugin.logEvent({
|
|
269
|
-
eventName: 'purchase',
|
|
270
|
-
// Optional ISO 8601 string. If omitted, current time is used.
|
|
271
|
-
date: new Date().toISOString(),
|
|
272
|
-
parameters: [
|
|
273
|
-
{ name: 'orderId', value: 'A-123' },
|
|
274
|
-
{ name: 'amount', value: '19.99' },
|
|
275
|
-
],
|
|
276
|
-
})
|
|
277
|
-
.then(() => console.log('logEvent: OK'))
|
|
278
|
-
.catch((err) => console.error('logEvent: ERROR', err));
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### logEcommerceEvent examples
|
|
282
|
-
|
|
283
|
-
Tracks ecommerce activity. Payload type: `LogEcommerceEventPayload` in [types](../types/index.ts).
|
|
284
|
-
Supported event types: `productViewed`, `productCategoryViewed`, `productAddedToWishlist`, `cartUpdated`, `orderCreated`, `orderUpdated`, `orderDelivered`, `orderCancelled`, `searchRequest`.
|
|
285
|
-
|
|
286
|
-
See also: [Reteno ecommerce activity tracking](https://docs.reteno.com/reference/android-ecommerce-activity-tracking).
|
|
287
|
-
|
|
288
|
-
```js
|
|
289
|
-
// Product viewed
|
|
290
|
-
RetenoPlugin.logEcommerceEvent({
|
|
291
|
-
eventType: 'productViewed',
|
|
292
|
-
product: {
|
|
293
|
-
productId: 'SKU-123',
|
|
294
|
-
price: 29.99,
|
|
295
|
-
isInStock: true,
|
|
296
|
-
attributes: [{ name: 'color', value: ['red', 'blue'] }],
|
|
297
|
-
},
|
|
298
|
-
currencyCode: 'USD',
|
|
299
|
-
})
|
|
300
|
-
.then(() => console.log('logEcommerceEvent: OK'))
|
|
301
|
-
.catch((err) => console.error('logEcommerceEvent: ERROR', err));
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
```js
|
|
305
|
-
// Cart updated
|
|
306
|
-
RetenoPlugin.logEcommerceEvent({
|
|
307
|
-
eventType: 'cartUpdated',
|
|
308
|
-
cartId: 'cart-456',
|
|
309
|
-
products: [
|
|
310
|
-
{
|
|
311
|
-
productId: 'SKU-123',
|
|
312
|
-
quantity: 2,
|
|
313
|
-
price: 29.99,
|
|
314
|
-
name: 'T-Shirt',
|
|
315
|
-
category: 'Apparel',
|
|
316
|
-
},
|
|
317
|
-
],
|
|
318
|
-
currencyCode: 'USD',
|
|
319
|
-
})
|
|
320
|
-
.then(() => console.log('logEcommerceEvent: OK'))
|
|
321
|
-
.catch((err) => console.error('logEcommerceEvent: ERROR', err));
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
```js
|
|
325
|
-
// Order created
|
|
326
|
-
RetenoPlugin.logEcommerceEvent({
|
|
327
|
-
eventType: 'orderCreated',
|
|
328
|
-
order: {
|
|
329
|
-
externalOrderId: 'ORD-789',
|
|
330
|
-
totalCost: 59.98,
|
|
331
|
-
status: 'INITIALIZED',
|
|
332
|
-
date: new Date().toISOString(),
|
|
333
|
-
items: [
|
|
334
|
-
{
|
|
335
|
-
externalItemId: 'SKU-123',
|
|
336
|
-
name: 'T-Shirt',
|
|
337
|
-
category: 'Apparel',
|
|
338
|
-
quantity: 2,
|
|
339
|
-
cost: 29.99,
|
|
340
|
-
url: 'https://example.com/products/SKU-123',
|
|
341
|
-
},
|
|
342
|
-
],
|
|
343
|
-
},
|
|
344
|
-
currencyCode: 'USD',
|
|
345
|
-
})
|
|
346
|
-
.then(() => console.log('logEcommerceEvent: OK'))
|
|
347
|
-
.catch((err) => console.error('logEcommerceEvent: ERROR', err));
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
```js
|
|
351
|
-
// Search request
|
|
352
|
-
RetenoPlugin.logEcommerceEvent({
|
|
353
|
-
eventType: 'searchRequest',
|
|
354
|
-
search: 'red t-shirt',
|
|
355
|
-
isFound: true,
|
|
356
|
-
})
|
|
357
|
-
.then(() => console.log('logEcommerceEvent: OK'))
|
|
358
|
-
.catch((err) => console.error('logEcommerceEvent: ERROR', err));
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
### logScreenView example
|
|
362
|
-
|
|
363
|
-
```js
|
|
364
|
-
RetenoPlugin.logScreenView('HomeScreen')
|
|
365
|
-
.then(() => console.log('logScreenView: OK'))
|
|
366
|
-
.catch((err) => console.error('logScreenView: ERROR', err));
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### forcePushData example
|
|
370
|
-
|
|
371
|
-
```js
|
|
372
|
-
RetenoPlugin.forcePushData()
|
|
373
|
-
.then(() => console.log('forcePushData: OK'))
|
|
374
|
-
.catch((err) => console.error('forcePushData: ERROR', err));
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
On iOS, `forcePushData()` is implemented through a technical `logEvent` call with `forcePush: true`.
|
|
378
|
-
|
|
379
|
-
### pauseInAppMessages example
|
|
380
|
-
|
|
381
|
-
Pause or resume in-app messages at runtime.
|
|
382
|
-
|
|
383
|
-
```js
|
|
384
|
-
// Pause in-app messages
|
|
385
|
-
RetenoPlugin.pauseInAppMessages(true)
|
|
386
|
-
.then(() => console.log('pauseInAppMessages: paused'))
|
|
387
|
-
.catch((err) => console.error('pauseInAppMessages: ERROR', err));
|
|
388
|
-
|
|
389
|
-
// Resume in-app messages
|
|
390
|
-
RetenoPlugin.pauseInAppMessages(false)
|
|
391
|
-
.then(() => console.log('pauseInAppMessages: resumed'))
|
|
392
|
-
.catch((err) => console.error('pauseInAppMessages: ERROR', err));
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
### setInAppMessagesPauseBehaviour example
|
|
396
|
-
|
|
397
|
-
Configure how paused in-app messages are handled. Type: `InAppPauseBehaviour` in [types](../types/index.ts).
|
|
398
|
-
On iOS, you can also preconfigure this during `init(...)` via `inAppMessagesPauseBehaviour`.
|
|
399
|
-
|
|
400
|
-
```js
|
|
401
|
-
// Discard messages received while paused
|
|
402
|
-
RetenoPlugin.setInAppMessagesPauseBehaviour('SKIP_IN_APPS')
|
|
403
|
-
.then(() => console.log('setInAppMessagesPauseBehaviour: OK'))
|
|
404
|
-
.catch((err) => console.error('setInAppMessagesPauseBehaviour: ERROR', err));
|
|
405
|
-
|
|
406
|
-
// Save the first queued message and display it when unpaused
|
|
407
|
-
RetenoPlugin.setInAppMessagesPauseBehaviour('POSTPONE_IN_APPS')
|
|
408
|
-
.then(() => console.log('setInAppMessagesPauseBehaviour: OK'))
|
|
409
|
-
.catch((err) => console.error('setInAppMessagesPauseBehaviour: ERROR', err));
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
### setOnInAppLifecycleCallback example
|
|
413
|
-
|
|
414
|
-
Subscribe to in-app message status/lifecycle events. The listener receives events with `event` (lifecycle stage) and `data` (context-specific payload). Types: `InAppLifecyclePayload`, `InAppData`, `InAppCloseData`, `InAppErrorData` in [types](../types/index.ts).
|
|
415
|
-
|
|
416
|
-
```js
|
|
417
|
-
function onInAppStatus(event) {
|
|
418
|
-
var detail = event.detail || event;
|
|
419
|
-
console.log('In-app status:', detail.event, detail.data);
|
|
420
|
-
// detail.event is one of: 'beforeDisplay', 'onDisplay', 'beforeClose', 'afterClose', 'onError'
|
|
421
|
-
//
|
|
422
|
-
// detail.data per platform:
|
|
423
|
-
//
|
|
424
|
-
// | Event | Android | iOS |
|
|
425
|
-
// |----------------|--------------------------------|----------------------------------------------|
|
|
426
|
-
// | beforeDisplay | { id } | {} (empty) |
|
|
427
|
-
// | onDisplay | { id } | {} (empty) |
|
|
428
|
-
// | beforeClose | { id, closeAction } | { closeAction, action } |
|
|
429
|
-
// | afterClose | { id, closeAction } | { closeAction, action } |
|
|
430
|
-
// | onError | { id, errorMessage } | { errorMessage } |
|
|
431
|
-
//
|
|
432
|
-
// closeAction values:
|
|
433
|
-
// Android: string from native SDK (e.g. via InAppCloseData.getCloseAction())
|
|
434
|
-
// iOS: "closeButtonClicked", "buttonClicked", "openUrlClicked", or "unknown"
|
|
435
|
-
//
|
|
436
|
-
// action (iOS only): { isCloseButtonClicked, isButtonClicked, isOpenUrlClicked }
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
RetenoPlugin.setOnInAppLifecycleCallback(onInAppStatus);
|
|
440
|
-
|
|
441
|
-
// Later, to unsubscribe:
|
|
442
|
-
RetenoPlugin.setOnInAppLifecycleCallback(null);
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
### setOnInAppMessageCustomDataReceivedListener example
|
|
446
|
-
|
|
447
|
-
Subscribe to in-app message custom data events when a button is clicked.
|
|
448
|
-
|
|
449
|
-
Important: once you register this receiver, Reteno SDK will not open button links automatically. Instead, it will pass all custom data to your listener, including the link under the `url` key. You are responsible for handling navigation.
|
|
450
|
-
|
|
451
|
-
```js
|
|
452
|
-
RetenoPlugin.setOnInAppMessageCustomDataReceivedListener(function (event) {
|
|
453
|
-
// event.detail contains the custom data payload
|
|
454
|
-
// If a link was assigned to the button, it will be under event.detail.url
|
|
455
|
-
console.log('In-app custom data:', event.detail);
|
|
456
|
-
});
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
### setDeviceToken example
|
|
460
|
-
|
|
461
|
-
If you obtain a token outside this plugin (for example via another plugin/SDK), you can forward it to Reteno so it can register the device for push.
|
|
462
|
-
|
|
463
|
-
Notes:
|
|
464
|
-
|
|
465
|
-
- On Android, if Reteno receives FCM callbacks directly, you generally don't need to call `setDeviceToken`.
|
|
466
|
-
- On iOS with Firebase, prefer the default `IOS_DEVICE_TOKEN_HANDLING_MODE=manual` flow with automatic forwarding in `init()`, described in [iOS docs](./ios.md#using-fcm-firebase-cloud-messaging-on-ios).
|
|
467
|
-
|
|
468
|
-
```js
|
|
469
|
-
// 1) Initialize Reteno first.
|
|
470
|
-
RetenoPlugin.init()
|
|
471
|
-
.then(() => {
|
|
472
|
-
// Forward token from your token source (replace this with your integration).
|
|
473
|
-
getFcmTokenFromSomewhere(
|
|
474
|
-
(token) => {
|
|
475
|
-
if (token) RetenoPlugin.setDeviceToken(token);
|
|
476
|
-
},
|
|
477
|
-
(err) => console.error('getFcmTokenFromSomewhere: ERROR', err)
|
|
478
|
-
);
|
|
479
|
-
})
|
|
480
|
-
.catch((err) => console.error('RetenoPlugin.init: ERROR', err));
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
### setOnRetenoPushReceivedListener example
|
|
484
|
-
|
|
485
|
-
Subscribe to push received events while the app is running.
|
|
486
|
-
|
|
487
|
-
Notes:
|
|
488
|
-
|
|
489
|
-
- On Android this is based on the SDK 2.9.6 `EventListener` / `Procedure` API (`RetenoNotifications.getReceived()`).
|
|
490
|
-
- This listener is not a replacement for `getInitialNotification()` (cold start): if the app was launched by tapping a notification, use `getInitialNotification()`.
|
|
491
|
-
|
|
492
|
-
```js
|
|
493
|
-
// Subscribe to push received events
|
|
494
|
-
function onPushReceived(event) {
|
|
495
|
-
// `event` contains the payload fields from intent extras.
|
|
496
|
-
// The exact keys depend on what Reteno/FCM delivered.
|
|
497
|
-
console.log('reteno-push-received:', event);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
RetenoPlugin.setOnRetenoPushReceivedListener(onPushReceived);
|
|
501
|
-
|
|
502
|
-
// Later, to unsubscribe:
|
|
503
|
-
RetenoPlugin.removeOnRetenoPushReceivedListener(onPushReceived);
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
### setOnRetenoNotificationClickedListener example
|
|
507
|
-
|
|
508
|
-
Subscribe to notification click events while the app is running.
|
|
509
|
-
|
|
510
|
-
```js
|
|
511
|
-
// Subscribe to notification click events
|
|
512
|
-
function onNotificationClicked(event) {
|
|
513
|
-
console.log('reteno-notification-clicked:', event);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
RetenoPlugin.setOnRetenoNotificationClickedListener(onNotificationClicked);
|
|
517
|
-
|
|
518
|
-
// Later, to unsubscribe:
|
|
519
|
-
RetenoPlugin.removeOnRetenoNotificationClickedListener(onNotificationClicked);
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
### setOnRetenoPushButtonClickedListener example
|
|
523
|
-
|
|
524
|
-
Subscribe to push notification action button click events. When a user long-presses a push notification and taps one of the action buttons, this listener fires with `actionId`, `link`, `customData`, and `userInfo`.
|
|
525
|
-
|
|
526
|
-
- **iOS**: supports up to 4 buttons per notification. You must enable the native handler via `setNotificationActionHandler({ emitEvent: true })` (or the explicit `{ enabled: true, emitEvent: true }`).
|
|
527
|
-
- **Android**: supports up to 3 buttons per notification. Action button clicks are automatically detected from the notification-clicked bundle — `setNotificationActionHandler` is a no-op on Android.
|
|
528
|
-
|
|
529
|
-
Payload type: `RetenoPushButtonClickedPayload` in [types](../types/index.ts).
|
|
530
|
-
|
|
531
|
-
```js
|
|
532
|
-
// 1. Enable notification action handler with event emission (enabled defaults to true)
|
|
533
|
-
RetenoPlugin.setNotificationActionHandler({ emitEvent: true })
|
|
534
|
-
.then(() => console.log('setNotificationActionHandler: enabled'))
|
|
535
|
-
.catch((err) => console.error('setNotificationActionHandler: ERROR', err));
|
|
536
|
-
|
|
537
|
-
// 2. Subscribe to action button click events
|
|
538
|
-
function onPushButtonClicked(event) {
|
|
539
|
-
var detail = event && event.detail !== undefined ? event.detail : event;
|
|
540
|
-
console.log('reteno-push-button-clicked:', detail);
|
|
541
|
-
// detail.actionId - the unique button identifier
|
|
542
|
-
// detail.link - URL/deeplink associated with the button
|
|
543
|
-
// detail.customData - additional data from the button (object or raw string on Android)
|
|
544
|
-
// detail.userInfo - original notification payload
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
RetenoPlugin.setOnRetenoPushButtonClickedListener(onPushButtonClicked);
|
|
548
|
-
|
|
549
|
-
// Later, to unsubscribe:
|
|
550
|
-
RetenoPlugin.removeOnRetenoPushButtonClickedListener(onPushButtonClicked);
|
|
551
|
-
|
|
552
|
-
// To disable the handler entirely:
|
|
553
|
-
RetenoPlugin.setNotificationActionHandler(false);
|
|
554
|
-
```
|
|
555
|
-
|
|
556
|
-
### updateDefaultNotificationChannel example
|
|
557
|
-
|
|
558
|
-
Updates the default notification channel parameters for existing users on Android devices. This is useful when you need to change how notifications appear to users who already have the app installed.
|
|
559
|
-
|
|
560
|
-
Payload type: `NotificationChannelConfig` in [types](../types/index.ts).
|
|
561
|
-
|
|
562
|
-
```js
|
|
563
|
-
RetenoPlugin.updateDefaultNotificationChannel({
|
|
564
|
-
name: 'New Channel Name',
|
|
565
|
-
description: 'New Channel Description',
|
|
566
|
-
})
|
|
567
|
-
.then(() => console.log('updateDefaultNotificationChannel: OK'))
|
|
568
|
-
.catch((err) => console.error('updateDefaultNotificationChannel: ERROR', err));
|
|
569
|
-
```
|
|
570
|
-
|
|
571
|
-
### setNotificationGroupingRule example
|
|
572
|
-
|
|
573
|
-
Configures Android notification grouping without a JavaScript callback, so the rule also works when the WebView is not running. Payload type: `NotificationGroupingRule` in [types](../types/index.ts).
|
|
574
|
-
|
|
575
|
-
```js
|
|
576
|
-
// Use the value of `chatId` from each push payload as its Android group key.
|
|
577
|
-
await RetenoPlugin.setNotificationGroupingRule({ payloadKey: 'chatId' });
|
|
578
|
-
|
|
579
|
-
// Or put every Reteno notification into one constant group.
|
|
580
|
-
await RetenoPlugin.setNotificationGroupingRule({ groupId: 'messages' });
|
|
581
|
-
|
|
582
|
-
// Disable grouping.
|
|
583
|
-
await RetenoPlugin.setNotificationGroupingRule(null);
|
|
584
|
-
```
|
|
585
|
-
|
|
586
|
-
The SDK assigns `NotificationCompat.Builder.setGroup(...)`; displaying a group-summary notification remains the application's responsibility.
|
|
587
|
-
|
|
588
|
-
### getAppInboxMessages example
|
|
589
|
-
|
|
590
|
-
Fetches paginated App Inbox messages. Payload type: `GetAppInboxMessagesPayload` in [types](../types/index.ts).
|
|
591
|
-
|
|
592
|
-
Returns `AppInboxMessages`: `{ messages: AppInboxMessage[], totalPages: number }`.
|
|
593
|
-
|
|
594
|
-
```js
|
|
595
|
-
RetenoPlugin.getAppInboxMessages({
|
|
596
|
-
page: 1,
|
|
597
|
-
pageSize: 20,
|
|
598
|
-
status: 'UNOPENED', // optional: 'OPENED' | 'UNOPENED'
|
|
599
|
-
})
|
|
600
|
-
.then((result) => {
|
|
601
|
-
// result.messages — array of AppInboxMessage objects
|
|
602
|
-
// result.totalPages — total number of pages
|
|
603
|
-
console.log(
|
|
604
|
-
'getAppInboxMessages: OK',
|
|
605
|
-
result.messages.length,
|
|
606
|
-
'of',
|
|
607
|
-
result.totalPages,
|
|
608
|
-
'pages'
|
|
609
|
-
);
|
|
610
|
-
})
|
|
611
|
-
.catch((err) => console.error('getAppInboxMessages: ERROR', err));
|
|
612
|
-
```
|
|
613
|
-
|
|
614
|
-
### getAppInboxMessagesCount example
|
|
615
|
-
|
|
616
|
-
Fetches count of App Inbox messages. Returns a `number`.
|
|
617
|
-
|
|
618
|
-
```js
|
|
619
|
-
RetenoPlugin.getAppInboxMessagesCount()
|
|
620
|
-
.then((count) => console.log('Unread messages:', count))
|
|
621
|
-
.catch((err) => console.error('getAppInboxMessagesCount: ERROR', err));
|
|
622
|
-
```
|
|
623
|
-
|
|
624
|
-
### subscribeOnMessagesCountChanged example
|
|
625
|
-
|
|
626
|
-
Subscribes to App Inbox messages count changes.
|
|
627
|
-
|
|
628
|
-
```js
|
|
629
|
-
function onInboxCountChanged(count) {
|
|
630
|
-
console.log('App Inbox count changed:', count);
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
RetenoPlugin.subscribeOnMessagesCountChanged(onInboxCountChanged, (err) => {
|
|
634
|
-
console.error('subscribeOnMessagesCountChanged: ERROR', err);
|
|
635
|
-
});
|
|
636
|
-
```
|
|
637
|
-
|
|
638
|
-
### unsubscribeMessagesCountChanged example
|
|
639
|
-
|
|
640
|
-
Unsubscribes from App Inbox messages count changes.
|
|
641
|
-
|
|
642
|
-
```js
|
|
643
|
-
RetenoPlugin.unsubscribeMessagesCountChanged()
|
|
644
|
-
.then(() => console.log('unsubscribeMessagesCountChanged: OK'))
|
|
645
|
-
.catch((err) => console.error('unsubscribeMessagesCountChanged: ERROR', err));
|
|
646
|
-
```
|
|
647
|
-
|
|
648
|
-
### markAsOpened example
|
|
649
|
-
|
|
650
|
-
Marks an App Inbox message as opened.
|
|
651
|
-
|
|
652
|
-
```js
|
|
653
|
-
RetenoPlugin.markAsOpened('message-id')
|
|
654
|
-
.then(() => console.log('markAsOpened: OK'))
|
|
655
|
-
.catch((err) => console.error('markAsOpened: ERROR', err));
|
|
656
|
-
```
|
|
657
|
-
|
|
658
|
-
### markAllMessagesAsOpened example
|
|
659
|
-
|
|
660
|
-
Marks all App Inbox messages as opened.
|
|
661
|
-
|
|
662
|
-
```js
|
|
663
|
-
RetenoPlugin.markAllMessagesAsOpened()
|
|
664
|
-
.then(() => console.log('markAllMessagesAsOpened: OK'))
|
|
665
|
-
.catch((err) => console.error('markAllMessagesAsOpened: ERROR', err));
|
|
666
|
-
```
|
|
667
|
-
|
|
668
|
-
### getRecommendations example
|
|
669
|
-
|
|
670
|
-
Fetches recommendations. Payload type: `GetRecommendationsPayload` in [types](../types/index.ts).
|
|
671
|
-
|
|
672
|
-
Returns `RecommendationsResponse`: `{ recoms: RecommendationItem[] }`. Each item contains `productId` plus the fields you requested.
|
|
673
|
-
|
|
674
|
-
```js
|
|
675
|
-
// Product-based recommendations.
|
|
676
|
-
RetenoPlugin.getRecommendations({
|
|
677
|
-
recomVariantId: 'variant-id',
|
|
678
|
-
productIds: ['product-1', 'product-2'],
|
|
679
|
-
fields: ['name', 'price', 'image', 'link'],
|
|
680
|
-
})
|
|
681
|
-
.then((result) => {
|
|
682
|
-
// result.recoms — array of recommendation items
|
|
683
|
-
// each item has productId + requested fields (name, price, etc.)
|
|
684
|
-
result.recoms.forEach((item) => console.log(item.productId, item.name));
|
|
685
|
-
})
|
|
686
|
-
.catch((err) => console.error('getRecommendations: ERROR', err));
|
|
687
|
-
```
|
|
688
|
-
|
|
689
|
-
```js
|
|
690
|
-
// Category-based recommendations.
|
|
691
|
-
RetenoPlugin.getRecommendations({
|
|
692
|
-
recomVariantId: 'variant-id',
|
|
693
|
-
categoryId: 'category-1',
|
|
694
|
-
fields: ['name', 'price'],
|
|
695
|
-
})
|
|
696
|
-
.then((result) => console.log('getRecommendations: OK', result))
|
|
697
|
-
.catch((err) => console.error('getRecommendations: ERROR', err));
|
|
698
|
-
```
|
|
699
|
-
|
|
700
|
-
```js
|
|
701
|
-
// With filters.
|
|
702
|
-
RetenoPlugin.getRecommendations({
|
|
703
|
-
recomVariantId: 'variant-id',
|
|
704
|
-
productIds: ['product-1'],
|
|
705
|
-
fields: ['name', 'price'],
|
|
706
|
-
filters: [{ name: 'category', values: ['shoes', 'boots'] }],
|
|
707
|
-
})
|
|
708
|
-
.then((result) => console.log('getRecommendations: OK', result))
|
|
709
|
-
.catch((err) => console.error('getRecommendations: ERROR', err));
|
|
710
|
-
```
|
|
711
|
-
|
|
712
|
-
### logRecommendations example
|
|
713
|
-
|
|
714
|
-
Sends recommendation events. Payload type: `LogRecommendationsPayload` in [types](../types/index.ts).
|
|
715
|
-
|
|
716
|
-
```js
|
|
717
|
-
RetenoPlugin.logRecommendations({
|
|
718
|
-
recomVariantId: 'variant-id',
|
|
719
|
-
recomEvents: [
|
|
720
|
-
{
|
|
721
|
-
recomEventType: 'IMPRESSIONS',
|
|
722
|
-
occurred: new Date().toISOString(),
|
|
723
|
-
productId: 'product-1',
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
recomEventType: 'CLICKS',
|
|
727
|
-
occurred: new Date().toISOString(),
|
|
728
|
-
productId: 'product-2',
|
|
729
|
-
},
|
|
730
|
-
],
|
|
731
|
-
})
|
|
732
|
-
.then(() => console.log('logRecommendations: OK'))
|
|
733
|
-
.catch((err) => console.error('logRecommendations: ERROR', err));
|
|
734
|
-
```
|