reteno-react-native-sdk 1.7.8 → 2.0.0
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 +14 -4
- package/android/build.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +13 -3
- package/android/src/main/java/com/retenosdk/RetenoCustomReceiverInAppData.java +1 -11
- package/android/src/main/java/com/retenosdk/RetenoEcomEvent.java +20 -5
- package/android/src/main/java/com/retenosdk/RetenoMessagingService.java +5 -0
- package/android/src/main/java/com/retenosdk/RetenoSdkModule.java +439 -91
- package/ios/RetenoEcomEvent.swift +16 -25
- package/ios/RetenoSdk.m +20 -1
- package/ios/RetenoSdk.swift +286 -21
- package/lib/commonjs/index.js +127 -15
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +118 -15
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +102 -10
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +4 -7
- package/reteno-react-native-sdk.podspec +2 -17
- package/src/index.ts +186 -17
- package/android/src/main/java/com/retenosdk/RetenoReactNativeApplication.java +0 -7
- package/ios/RetenoSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RetenoSdk.xcodeproj/project.xcworkspace/xcuserdata/oleksandr.vasylkov.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RetenoSdk.xcodeproj/xcuserdata/oleksandr.vasylkov.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
|
@@ -5,6 +5,8 @@ import androidx.annotation.Nullable;
|
|
|
5
5
|
import android.content.Context;
|
|
6
6
|
import android.content.Intent;
|
|
7
7
|
import android.os.Bundle;
|
|
8
|
+
import android.os.Handler;
|
|
9
|
+
import android.os.Looper;
|
|
8
10
|
|
|
9
11
|
import androidx.annotation.NonNull;
|
|
10
12
|
|
|
@@ -16,11 +18,13 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
|
16
18
|
import com.facebook.react.bridge.ReactMethod;
|
|
17
19
|
import com.facebook.react.bridge.ReadableMap;
|
|
18
20
|
import com.facebook.react.bridge.ReadableArray;
|
|
21
|
+
import com.facebook.react.bridge.ReadableType;
|
|
19
22
|
import com.facebook.react.bridge.WritableMap;
|
|
20
23
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
21
24
|
import com.facebook.react.bridge.WritableArray;
|
|
22
25
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
23
|
-
import com.reteno.core.
|
|
26
|
+
import com.reteno.core.Reteno;
|
|
27
|
+
import com.reteno.core.RetenoConfig;
|
|
24
28
|
import com.reteno.core.data.remote.model.recommendation.get.Recoms;
|
|
25
29
|
import com.reteno.core.domain.callback.appinbox.RetenoResultCallback;
|
|
26
30
|
import com.reteno.core.domain.model.appinbox.AppInboxMessages;
|
|
@@ -31,6 +35,7 @@ import com.reteno.core.domain.model.recommendation.get.RecomRequest;
|
|
|
31
35
|
import com.reteno.core.domain.model.recommendation.post.RecomEvent;
|
|
32
36
|
import com.reteno.core.domain.model.recommendation.post.RecomEventType;
|
|
33
37
|
import com.reteno.core.domain.model.recommendation.post.RecomEvents;
|
|
38
|
+
import com.reteno.core.domain.model.event.LifecycleTrackingOptions;
|
|
34
39
|
import com.reteno.core.features.appinbox.AppInboxStatus;
|
|
35
40
|
import com.reteno.core.view.iam.callback.InAppData;
|
|
36
41
|
import com.reteno.core.view.iam.callback.InAppCloseData;
|
|
@@ -38,6 +43,13 @@ import com.reteno.core.view.iam.callback.InAppErrorData;
|
|
|
38
43
|
import com.reteno.core.view.iam.callback.InAppLifecycleCallback;
|
|
39
44
|
import com.reteno.core.features.recommendation.GetRecommendationResponseCallback;
|
|
40
45
|
import com.reteno.core.domain.model.ecom.EcomEvent;
|
|
46
|
+
import com.reteno.core.features.iam.InAppPauseBehaviour;
|
|
47
|
+
import com.reteno.push.RetenoNotifications;
|
|
48
|
+
import com.reteno.push.permission.NotificationStatus;
|
|
49
|
+
import com.reteno.push.events.InAppCustomData;
|
|
50
|
+
import com.reteno.core.util.Procedure;
|
|
51
|
+
|
|
52
|
+
import kotlin.Unit;
|
|
41
53
|
|
|
42
54
|
import android.util.Log;
|
|
43
55
|
import android.content.SharedPreferences;
|
|
@@ -46,13 +58,14 @@ import java.util.HashMap;
|
|
|
46
58
|
import java.util.List;
|
|
47
59
|
import java.time.ZonedDateTime;
|
|
48
60
|
import java.util.Map;
|
|
49
|
-
|
|
50
|
-
import kotlin.Unit;
|
|
61
|
+
import java.util.concurrent.CompletableFuture;
|
|
51
62
|
|
|
52
63
|
public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
53
64
|
public static final String NAME = "RetenoSdk";
|
|
54
65
|
private static final String PREFS_NAME = "RetenoPrefs";
|
|
55
66
|
private static final String AUTO_OPEN_LINKS_KEY = "autoOpenLinks";
|
|
67
|
+
private static volatile boolean sdkInitialized = false;
|
|
68
|
+
private static volatile ReactApplicationContext sharedReactContext;
|
|
56
69
|
ReactApplicationContext context;
|
|
57
70
|
|
|
58
71
|
public static boolean isAutoOpenLinksEnabled(Context context) {
|
|
@@ -60,9 +73,14 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
60
73
|
return prefs.getBoolean(AUTO_OPEN_LINKS_KEY, true); // default true
|
|
61
74
|
}
|
|
62
75
|
|
|
76
|
+
public static ReactApplicationContext getSharedReactContext() {
|
|
77
|
+
return sharedReactContext;
|
|
78
|
+
}
|
|
79
|
+
|
|
63
80
|
public RetenoSdkModule(ReactApplicationContext reactContext) {
|
|
64
81
|
super(reactContext);
|
|
65
82
|
context = reactContext;
|
|
83
|
+
sharedReactContext = reactContext;
|
|
66
84
|
}
|
|
67
85
|
|
|
68
86
|
@Override
|
|
@@ -71,8 +89,159 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
71
89
|
return NAME;
|
|
72
90
|
}
|
|
73
91
|
|
|
92
|
+
@Override
|
|
93
|
+
public void onCatalystInstanceDestroy() {
|
|
94
|
+
cleanupRetenoNotificationsListeners();
|
|
95
|
+
super.onCatalystInstanceDestroy();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@Override
|
|
99
|
+
public void invalidate() {
|
|
100
|
+
cleanupRetenoNotificationsListeners();
|
|
101
|
+
super.invalidate();
|
|
102
|
+
}
|
|
103
|
+
|
|
74
104
|
@ReactMethod
|
|
75
105
|
public void setDeviceToken(String deviceToken, Promise promise) {
|
|
106
|
+
promise.resolve(true);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@ReactMethod
|
|
110
|
+
public synchronized void initialize(ReadableMap payload, Promise promise) {
|
|
111
|
+
if (sdkInitialized) {
|
|
112
|
+
promise.resolve(true);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
String apiKey = (payload != null && payload.hasKey("apiKey") && !payload.isNull("apiKey"))
|
|
117
|
+
? payload.getString("apiKey")
|
|
118
|
+
: null;
|
|
119
|
+
|
|
120
|
+
if (apiKey == null || apiKey.trim().isEmpty()) {
|
|
121
|
+
promise.reject("100", "Missing argument: apiKey");
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
boolean debugMode = payload != null && payload.hasKey("isDebugMode")
|
|
127
|
+
&& !payload.isNull("isDebugMode") && payload.getBoolean("isDebugMode");
|
|
128
|
+
boolean pauseInAppMessages = payload != null && payload.hasKey("pauseInAppMessages")
|
|
129
|
+
&& !payload.isNull("pauseInAppMessages") && payload.getBoolean("pauseInAppMessages");
|
|
130
|
+
|
|
131
|
+
RetenoConfig.Builder builder = new RetenoConfig.Builder()
|
|
132
|
+
.accessKey(apiKey.trim())
|
|
133
|
+
.setDebug(debugMode);
|
|
134
|
+
|
|
135
|
+
if (pauseInAppMessages) {
|
|
136
|
+
builder.pauseInAppMessages(true);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
com.facebook.react.bridge.Dynamic lifecycleDynamic = null;
|
|
140
|
+
if (payload != null && payload.hasKey("lifecycleTrackingOptions")) {
|
|
141
|
+
lifecycleDynamic = payload.getDynamic("lifecycleTrackingOptions");
|
|
142
|
+
}
|
|
143
|
+
LifecycleTrackingOptions lifecycleOptions = parseLifecycleTrackingOption(lifecycleDynamic);
|
|
144
|
+
if (payload != null && payload.hasKey("lifecycleTrackingOptions") && lifecycleOptions == null) {
|
|
145
|
+
promise.reject(
|
|
146
|
+
"InvalidArgument",
|
|
147
|
+
"Invalid argument: lifecycleTrackingOptions. Expected 'ALL', 'NONE', or lifecycle options object."
|
|
148
|
+
);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (lifecycleOptions != null) {
|
|
152
|
+
builder.lifecycleTrackingOptions(lifecycleOptions);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (payload != null && payload.hasKey("sessionDurationSeconds") && !payload.isNull("sessionDurationSeconds")) {
|
|
156
|
+
double sessionDurationSeconds = payload.getDouble("sessionDurationSeconds");
|
|
157
|
+
if (sessionDurationSeconds > 0D) {
|
|
158
|
+
builder.sessionDuration((long) (sessionDurationSeconds * 1000L));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
sdkInitialized = true;
|
|
163
|
+
|
|
164
|
+
Runnable initTask = () -> {
|
|
165
|
+
try {
|
|
166
|
+
Reteno.initWithConfig(builder.build());
|
|
167
|
+
promise.resolve(true);
|
|
168
|
+
} catch (Exception e) {
|
|
169
|
+
sdkInitialized = false;
|
|
170
|
+
promise.reject("Reteno Android SDK initialize Error", e);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
if (Looper.myLooper() == Looper.getMainLooper()) {
|
|
175
|
+
initTask.run();
|
|
176
|
+
} else {
|
|
177
|
+
new Handler(Looper.getMainLooper()).post(initTask);
|
|
178
|
+
}
|
|
179
|
+
} catch (Exception e) {
|
|
180
|
+
sdkInitialized = false;
|
|
181
|
+
promise.reject("Reteno Android SDK initialize Error", e);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private LifecycleTrackingOptions parseLifecycleTrackingOption(@Nullable com.facebook.react.bridge.Dynamic value) {
|
|
186
|
+
if (value == null || value.isNull()) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
ReadableType type = value.getType();
|
|
191
|
+
if (type == ReadableType.String) {
|
|
192
|
+
String raw = value.asString();
|
|
193
|
+
if (raw == null) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
String normalized = raw.trim().toUpperCase();
|
|
197
|
+
if ("ALL".equals(normalized)) {
|
|
198
|
+
return new LifecycleTrackingOptions(true, true, true, true, true);
|
|
199
|
+
}
|
|
200
|
+
if ("NONE".equals(normalized)) {
|
|
201
|
+
return new LifecycleTrackingOptions(false, false, false, false, false);
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (type != ReadableType.Map) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
ReadableMap map = value.asMap();
|
|
211
|
+
|
|
212
|
+
boolean appLifecycleEnabled = map.hasKey("appLifecycleEnabled")
|
|
213
|
+
? map.getBoolean("appLifecycleEnabled")
|
|
214
|
+
: true;
|
|
215
|
+
boolean foregroundLifecycleEnabled = map.hasKey("foregroundLifecycleEnabled")
|
|
216
|
+
? map.getBoolean("foregroundLifecycleEnabled")
|
|
217
|
+
: false;
|
|
218
|
+
boolean pushSubscriptionEnabled = map.hasKey("pushSubscriptionEnabled")
|
|
219
|
+
? map.getBoolean("pushSubscriptionEnabled")
|
|
220
|
+
: true;
|
|
221
|
+
|
|
222
|
+
boolean legacySessionEventsEnabled = map.hasKey("sessionEventsEnabled")
|
|
223
|
+
? map.getBoolean("sessionEventsEnabled")
|
|
224
|
+
: true;
|
|
225
|
+
boolean sessionStartEventsEnabled = map.hasKey("sessionStartEventsEnabled")
|
|
226
|
+
? map.getBoolean("sessionStartEventsEnabled")
|
|
227
|
+
: legacySessionEventsEnabled;
|
|
228
|
+
|
|
229
|
+
boolean sessionEndEventsEnabled;
|
|
230
|
+
if (map.hasKey("sessionEndEventsEnabled")) {
|
|
231
|
+
sessionEndEventsEnabled = map.getBoolean("sessionEndEventsEnabled");
|
|
232
|
+
} else if (map.hasKey("sessionEventsEnabled")) {
|
|
233
|
+
sessionEndEventsEnabled = legacySessionEventsEnabled;
|
|
234
|
+
} else {
|
|
235
|
+
sessionEndEventsEnabled = false;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return new LifecycleTrackingOptions(
|
|
239
|
+
appLifecycleEnabled,
|
|
240
|
+
foregroundLifecycleEnabled,
|
|
241
|
+
pushSubscriptionEnabled,
|
|
242
|
+
sessionStartEventsEnabled,
|
|
243
|
+
sessionEndEventsEnabled
|
|
244
|
+
);
|
|
76
245
|
}
|
|
77
246
|
|
|
78
247
|
@ReactMethod
|
|
@@ -85,8 +254,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
85
254
|
}
|
|
86
255
|
|
|
87
256
|
try {
|
|
88
|
-
(
|
|
89
|
-
.getRetenoInstance()
|
|
257
|
+
getRetenoInstance()
|
|
90
258
|
.setUserAttributes(externalUserId, user);
|
|
91
259
|
} catch (Exception e) {
|
|
92
260
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -101,45 +269,27 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
101
269
|
}
|
|
102
270
|
|
|
103
271
|
public static void onRetenoPushReceived(Context context, Intent intent) {
|
|
104
|
-
ReactContext reactContext = null;
|
|
105
|
-
try {
|
|
106
|
-
reactContext = ((RetenoReactNativeApplication) context.getApplicationContext())
|
|
107
|
-
.getReactContext();
|
|
108
|
-
} catch (Exception e) {
|
|
109
|
-
Log.w(NAME, "Could not get ReactContext for push received", e);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
272
|
RetenoEventQueue.getInstance().dispatch(
|
|
113
273
|
"reteno-push-received",
|
|
114
274
|
parseIntent(intent),
|
|
115
|
-
|
|
275
|
+
sharedReactContext
|
|
116
276
|
);
|
|
117
277
|
}
|
|
118
278
|
|
|
119
279
|
public static void onRetenoPushClicked(Context context, Intent intent) {
|
|
120
|
-
ReactContext reactContext = null;
|
|
121
|
-
try {
|
|
122
|
-
reactContext = ((RetenoReactNativeApplication) context.getApplicationContext())
|
|
123
|
-
.getReactContext();
|
|
124
|
-
} catch (Exception e) {
|
|
125
|
-
Log.w(NAME, "Could not get ReactContext for push clicked", e);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
280
|
RetenoEventQueue.getInstance().dispatch(
|
|
129
281
|
"reteno-push-clicked",
|
|
130
282
|
parseIntent(intent),
|
|
131
|
-
|
|
283
|
+
sharedReactContext
|
|
132
284
|
);
|
|
133
285
|
}
|
|
134
286
|
|
|
135
|
-
private static WritableMap
|
|
287
|
+
private static WritableMap parseBundle(Bundle bundle) {
|
|
136
288
|
WritableMap params = Arguments.createMap();
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (extras != null) {
|
|
289
|
+
if (bundle != null) {
|
|
140
290
|
try {
|
|
141
|
-
for (String key :
|
|
142
|
-
Object value =
|
|
291
|
+
for (String key : bundle.keySet()) {
|
|
292
|
+
Object value = bundle.get(key);
|
|
143
293
|
if (value instanceof HashMap) {
|
|
144
294
|
@SuppressWarnings("unchecked")
|
|
145
295
|
WritableMap map = convertHashMap((HashMap<String, Object>) value);
|
|
@@ -149,13 +299,16 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
149
299
|
}
|
|
150
300
|
}
|
|
151
301
|
} catch (Exception e) {
|
|
152
|
-
Log.e("
|
|
302
|
+
Log.e("parseBundle", "Error converting Bundle to WritableMap: " + e.getMessage(), e);
|
|
153
303
|
}
|
|
154
304
|
}
|
|
155
|
-
|
|
156
305
|
return params;
|
|
157
306
|
}
|
|
158
307
|
|
|
308
|
+
private static WritableMap parseIntent(Intent intent) {
|
|
309
|
+
return parseBundle(intent.getExtras());
|
|
310
|
+
}
|
|
311
|
+
|
|
159
312
|
private static WritableMap convertHashMap(HashMap<String, Object> map) {
|
|
160
313
|
WritableMap writableMap = Arguments.createMap();
|
|
161
314
|
|
|
@@ -196,8 +349,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
196
349
|
@ReactMethod
|
|
197
350
|
public void logEvent(ReadableMap payload, Promise promise) {
|
|
198
351
|
try {
|
|
199
|
-
(
|
|
200
|
-
.getRetenoInstance()
|
|
352
|
+
getRetenoInstance()
|
|
201
353
|
.logEvent(RetenoEvent.buildEventFromPayload(payload));
|
|
202
354
|
} catch (Exception e) {
|
|
203
355
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -215,8 +367,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
215
367
|
UserAttributesAnonymous anonymousUser = RetenoUserAttributes.buildAnonymousUserFromPayload(payload);
|
|
216
368
|
|
|
217
369
|
try {
|
|
218
|
-
(
|
|
219
|
-
.getRetenoInstance()
|
|
370
|
+
getRetenoInstance()
|
|
220
371
|
.setAnonymousUserAttributes(anonymousUser);
|
|
221
372
|
} catch (Exception e) {
|
|
222
373
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -233,8 +384,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
233
384
|
@ReactMethod
|
|
234
385
|
public void forcePushData(Promise promise) {
|
|
235
386
|
try {
|
|
236
|
-
(
|
|
237
|
-
.getRetenoInstance().forcePushData();
|
|
387
|
+
getRetenoInstance().forcePushData();
|
|
238
388
|
promise.resolve(true);
|
|
239
389
|
} catch (Exception e) {
|
|
240
390
|
promise.reject("Reteno Android SDK forcePushData Error", e);
|
|
@@ -244,8 +394,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
244
394
|
@ReactMethod
|
|
245
395
|
public void pauseInAppMessages(Boolean isPaused, Promise promise) {
|
|
246
396
|
try {
|
|
247
|
-
(
|
|
248
|
-
.getRetenoInstance()
|
|
397
|
+
getRetenoInstance()
|
|
249
398
|
.pauseInAppMessages(isPaused);
|
|
250
399
|
promise.resolve(true);
|
|
251
400
|
} catch (Exception e) {
|
|
@@ -253,11 +402,63 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
253
402
|
}
|
|
254
403
|
}
|
|
255
404
|
|
|
405
|
+
@ReactMethod
|
|
406
|
+
public void setInAppMessagesPauseBehaviour(String behaviour, Promise promise) {
|
|
407
|
+
if (behaviour == null || behaviour.trim().isEmpty()) {
|
|
408
|
+
promise.reject("InvalidArgument", "Missing argument: behaviour ('SKIP_IN_APPS' or 'POSTPONE_IN_APPS')");
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
String normalized = behaviour.trim().toUpperCase();
|
|
413
|
+
InAppPauseBehaviour parsedBehaviour;
|
|
414
|
+
|
|
415
|
+
if ("SKIP_IN_APPS".equals(normalized)) {
|
|
416
|
+
parsedBehaviour = InAppPauseBehaviour.SKIP_IN_APPS;
|
|
417
|
+
} else if ("POSTPONE_IN_APPS".equals(normalized)) {
|
|
418
|
+
parsedBehaviour = InAppPauseBehaviour.POSTPONE_IN_APPS;
|
|
419
|
+
} else {
|
|
420
|
+
promise.reject("InvalidArgument", "Invalid argument: behaviour must be 'SKIP_IN_APPS' or 'POSTPONE_IN_APPS'");
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
try {
|
|
425
|
+
getRetenoInstance()
|
|
426
|
+
.setInAppMessagesPauseBehaviour(parsedBehaviour);
|
|
427
|
+
promise.resolve(true);
|
|
428
|
+
} catch (Exception e) {
|
|
429
|
+
promise.reject("Reteno Android SDK setInAppMessagesPauseBehaviour Error", e);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
@ReactMethod
|
|
434
|
+
public void setMultiAccountUserAttributes(ReadableMap payload, Promise promise) {
|
|
435
|
+
String externalUserId = (payload.hasKey("externalUserId") && !payload.isNull("externalUserId"))
|
|
436
|
+
? payload.getString("externalUserId")
|
|
437
|
+
: null;
|
|
438
|
+
if (externalUserId == null || externalUserId.isEmpty()) {
|
|
439
|
+
promise.reject("Parsing error", "externalUserId cannot be null");
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
User user = RetenoUserAttributes.buildUserFromPayload(payload);
|
|
444
|
+
|
|
445
|
+
try {
|
|
446
|
+
getRetenoInstance()
|
|
447
|
+
.setMultiAccountUserAttributes(externalUserId, user);
|
|
448
|
+
} catch (Exception e) {
|
|
449
|
+
promise.reject("Reteno Android SDK Error", e);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
WritableMap res = new WritableNativeMap();
|
|
454
|
+
res.putBoolean("success", true);
|
|
455
|
+
promise.resolve(res);
|
|
456
|
+
}
|
|
457
|
+
|
|
256
458
|
@ReactMethod
|
|
257
459
|
public void updatePushPermissionStatusAndroid(Promise promise) {
|
|
258
460
|
try {
|
|
259
|
-
(
|
|
260
|
-
.getRetenoInstance().updatePushPermissionStatus();
|
|
461
|
+
getRetenoInstance().updatePushPermissionStatus();
|
|
261
462
|
promise.resolve(true);
|
|
262
463
|
} catch (Exception e) {
|
|
263
464
|
promise.reject("Reteno Android SDK forcePushData Error", e);
|
|
@@ -265,9 +466,90 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
265
466
|
}
|
|
266
467
|
|
|
267
468
|
private void sendEventToJS(String eventName, WritableMap eventData) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
469
|
+
RetenoEventQueue.getInstance().dispatch(eventName, eventData, sharedReactContext);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
private Procedure<Bundle> pushDismissedListener;
|
|
473
|
+
private Procedure<Bundle> customPushListener;
|
|
474
|
+
private Procedure<InAppCustomData> inAppCustomDataRetenoListener;
|
|
475
|
+
private boolean notificationsListenersSetup = false;
|
|
476
|
+
|
|
477
|
+
private void setupRetenoNotificationsListeners() {
|
|
478
|
+
if (notificationsListenersSetup) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
notificationsListenersSetup = true;
|
|
482
|
+
try {
|
|
483
|
+
pushDismissedListener = bundle -> {
|
|
484
|
+
sendEventToJS("reteno-push-dismissed", parseBundle(bundle));
|
|
485
|
+
};
|
|
486
|
+
RetenoNotifications.INSTANCE.getClose().addListener(pushDismissedListener);
|
|
487
|
+
} catch (Exception e) {
|
|
488
|
+
Log.w(NAME, "Could not register push dismissed listener", e);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
try {
|
|
492
|
+
customPushListener = bundle -> {
|
|
493
|
+
sendEventToJS("reteno-custom-push-received", parseBundle(bundle));
|
|
494
|
+
};
|
|
495
|
+
RetenoNotifications.INSTANCE.getCustom().addListener(customPushListener);
|
|
496
|
+
} catch (Exception e) {
|
|
497
|
+
Log.w(NAME, "Could not register custom push listener", e);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
try {
|
|
501
|
+
inAppCustomDataRetenoListener = inAppCustomData -> {
|
|
502
|
+
WritableMap eventData = Arguments.createMap();
|
|
503
|
+
eventData.putString("url", inAppCustomData.getUrl());
|
|
504
|
+
eventData.putString("inapp_source", inAppCustomData.getSource());
|
|
505
|
+
eventData.putString("inapp_id", inAppCustomData.getInAppId());
|
|
506
|
+
WritableMap customDataMap = Arguments.createMap();
|
|
507
|
+
if (inAppCustomData.getData() != null) {
|
|
508
|
+
for (Map.Entry<String, String> entry : inAppCustomData.getData().entrySet()) {
|
|
509
|
+
customDataMap.putString(entry.getKey(), entry.getValue());
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
eventData.putMap("customData", customDataMap);
|
|
513
|
+
sendEventToJS("reteno-in-app-custom-data-received", eventData);
|
|
514
|
+
};
|
|
515
|
+
RetenoNotifications.INSTANCE.getInAppCustomDataReceived().addListener(inAppCustomDataRetenoListener);
|
|
516
|
+
} catch (Exception e) {
|
|
517
|
+
Log.w(NAME, "Could not register in-app custom data listener", e);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
private void cleanupRetenoNotificationsListeners() {
|
|
522
|
+
if (!notificationsListenersSetup) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
notificationsListenersSetup = false;
|
|
526
|
+
|
|
527
|
+
try {
|
|
528
|
+
if (pushDismissedListener != null) {
|
|
529
|
+
RetenoNotifications.INSTANCE.getClose().removeListener(pushDismissedListener);
|
|
530
|
+
pushDismissedListener = null;
|
|
531
|
+
}
|
|
532
|
+
} catch (Exception e) {
|
|
533
|
+
Log.w(NAME, "Could not unregister push dismissed listener", e);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
try {
|
|
537
|
+
if (customPushListener != null) {
|
|
538
|
+
RetenoNotifications.INSTANCE.getCustom().removeListener(customPushListener);
|
|
539
|
+
customPushListener = null;
|
|
540
|
+
}
|
|
541
|
+
} catch (Exception e) {
|
|
542
|
+
Log.w(NAME, "Could not unregister custom push listener", e);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
try {
|
|
546
|
+
if (inAppCustomDataRetenoListener != null) {
|
|
547
|
+
RetenoNotifications.INSTANCE.getInAppCustomDataReceived().removeListener(inAppCustomDataRetenoListener);
|
|
548
|
+
inAppCustomDataRetenoListener = null;
|
|
549
|
+
}
|
|
550
|
+
} catch (Exception e) {
|
|
551
|
+
Log.w(NAME, "Could not unregister in-app custom data listener", e);
|
|
552
|
+
}
|
|
271
553
|
}
|
|
272
554
|
|
|
273
555
|
private InAppLifecycleCallback inAppLifecycleCallback;
|
|
@@ -319,8 +601,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
319
601
|
sendEventToJS("reteno-on-in-app-error", eventData);
|
|
320
602
|
}
|
|
321
603
|
};
|
|
322
|
-
(
|
|
323
|
-
.getRetenoInstance().setInAppLifecycleCallback(inAppLifecycleCallback);
|
|
604
|
+
getRetenoInstance().setInAppLifecycleCallback(inAppLifecycleCallback);
|
|
324
605
|
promise.resolve(true);
|
|
325
606
|
} catch (Exception e) {
|
|
326
607
|
promise.reject("Reteno Android SDK setInAppLifecycleCallback Error", e);
|
|
@@ -331,7 +612,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
331
612
|
public void removeInAppLifecycleCallback(Promise promise) {
|
|
332
613
|
try {
|
|
333
614
|
if (inAppLifecycleCallback != null) {
|
|
334
|
-
|
|
615
|
+
getRetenoInstance().setInAppLifecycleCallback(null);
|
|
335
616
|
inAppLifecycleCallback = null;
|
|
336
617
|
}
|
|
337
618
|
promise.resolve(true);
|
|
@@ -370,8 +651,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
370
651
|
|
|
371
652
|
RecomRequest request = new RecomRequest(productIds, categoryId, fields, null);
|
|
372
653
|
|
|
373
|
-
(
|
|
374
|
-
.getRetenoInstance().getRecommendation().fetchRecommendation(recomVariantId, request, RetenoRecommendationsResponse.class, new GetRecommendationResponseCallback<RetenoRecommendationsResponse>() {
|
|
654
|
+
getRetenoInstance().getRecommendation().fetchRecommendation(recomVariantId, request, RetenoRecommendationsResponse.class, new GetRecommendationResponseCallback<RetenoRecommendationsResponse>() {
|
|
375
655
|
@Override
|
|
376
656
|
public void onSuccess(@NonNull Recoms<RetenoRecommendationsResponse> response) {
|
|
377
657
|
List<WritableMap> recoms = new ArrayList<>();
|
|
@@ -439,8 +719,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
439
719
|
|
|
440
720
|
RecomEvents recomEvents = new RecomEvents(recomVariantId, events);
|
|
441
721
|
|
|
442
|
-
(
|
|
443
|
-
.getRetenoInstance().getRecommendation().logRecommendations(recomEvents);
|
|
722
|
+
getRetenoInstance().getRecommendation().logRecommendations(recomEvents);
|
|
444
723
|
|
|
445
724
|
promise.resolve(true);
|
|
446
725
|
} catch (IllegalArgumentException e) {
|
|
@@ -474,8 +753,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
474
753
|
}
|
|
475
754
|
|
|
476
755
|
try {
|
|
477
|
-
(
|
|
478
|
-
.getRetenoInstance()
|
|
756
|
+
getRetenoInstance()
|
|
479
757
|
.getAppInbox()
|
|
480
758
|
.getAppInboxMessages(page, pageSize, status, new RetenoResultCallback<AppInboxMessages>() {
|
|
481
759
|
@Override
|
|
@@ -513,8 +791,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
513
791
|
@ReactMethod
|
|
514
792
|
public void getAppInboxMessagesCount(Promise promise) {
|
|
515
793
|
try {
|
|
516
|
-
(
|
|
517
|
-
.getRetenoInstance()
|
|
794
|
+
getRetenoInstance()
|
|
518
795
|
.getAppInbox()
|
|
519
796
|
.getAppInboxMessagesCount(new RetenoResultCallback<Integer>() {
|
|
520
797
|
@Override
|
|
@@ -535,8 +812,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
535
812
|
@ReactMethod
|
|
536
813
|
public void markAsOpened(String messageId, Promise promise) {
|
|
537
814
|
try {
|
|
538
|
-
(
|
|
539
|
-
.getRetenoInstance()
|
|
815
|
+
getRetenoInstance()
|
|
540
816
|
.getAppInbox()
|
|
541
817
|
.markAsOpened(messageId);
|
|
542
818
|
promise.resolve(true);
|
|
@@ -548,8 +824,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
548
824
|
@ReactMethod
|
|
549
825
|
public void markAllAsOpened(Promise promise) {
|
|
550
826
|
try {
|
|
551
|
-
(
|
|
552
|
-
.getRetenoInstance()
|
|
827
|
+
getRetenoInstance()
|
|
553
828
|
.getAppInbox()
|
|
554
829
|
.markAllMessagesAsOpened(new RetenoResultCallback<Unit>() {
|
|
555
830
|
@Override
|
|
@@ -569,9 +844,13 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
569
844
|
|
|
570
845
|
@ReactMethod
|
|
571
846
|
public void unsubscribeAllMessagesCountChanged(Promise promise) {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
847
|
+
try {
|
|
848
|
+
getRetenoInstance().getAppInbox().unsubscribeAllMessagesCountChanged();
|
|
849
|
+
messagesCountChangedCallback = null;
|
|
850
|
+
promise.resolve(null);
|
|
851
|
+
} catch (Exception e) {
|
|
852
|
+
promise.reject("UnsubscribeError", e);
|
|
853
|
+
}
|
|
575
854
|
}
|
|
576
855
|
|
|
577
856
|
private RetenoResultCallback<Integer> messagesCountChangedCallback;
|
|
@@ -597,8 +876,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
597
876
|
};
|
|
598
877
|
|
|
599
878
|
try {
|
|
600
|
-
(
|
|
601
|
-
.getRetenoInstance().getAppInbox().subscribeOnMessagesCountChanged(messagesCountChangedCallback);
|
|
879
|
+
getRetenoInstance().getAppInbox().subscribeOnMessagesCountChanged(messagesCountChangedCallback);
|
|
602
880
|
promise.resolve(null);
|
|
603
881
|
} catch (Exception e) {
|
|
604
882
|
promise.reject("SubscriptionError", e);
|
|
@@ -607,28 +885,40 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
607
885
|
|
|
608
886
|
@ReactMethod
|
|
609
887
|
public void unsubscribeMessagesCountChanged(Promise promise) {
|
|
610
|
-
|
|
611
|
-
(
|
|
612
|
-
|
|
613
|
-
|
|
888
|
+
try {
|
|
889
|
+
if (messagesCountChangedCallback != null) {
|
|
890
|
+
getRetenoInstance().getAppInbox().unsubscribeMessagesCountChanged(messagesCountChangedCallback);
|
|
891
|
+
messagesCountChangedCallback = null;
|
|
892
|
+
} else {
|
|
893
|
+
getRetenoInstance().getAppInbox().unsubscribeAllMessagesCountChanged();
|
|
894
|
+
}
|
|
614
895
|
promise.resolve(null);
|
|
615
|
-
}
|
|
616
|
-
promise.reject("
|
|
896
|
+
} catch (Exception e) {
|
|
897
|
+
promise.reject("UnsubscribeError", e);
|
|
617
898
|
}
|
|
618
899
|
}
|
|
619
900
|
|
|
620
901
|
@ReactMethod
|
|
621
902
|
public void initializeEventHandler(Promise promise) {
|
|
622
903
|
try {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
RetenoEventQueue.getInstance().setInitialized(reactContext);
|
|
904
|
+
RetenoEventQueue.getInstance().setInitialized(sharedReactContext);
|
|
905
|
+
setupRetenoNotificationsListeners();
|
|
626
906
|
promise.resolve(true);
|
|
627
907
|
} catch (Exception e) {
|
|
628
908
|
promise.reject("Reteno Android SDK initializeEventHandler Error", e);
|
|
629
909
|
}
|
|
630
910
|
}
|
|
631
911
|
|
|
912
|
+
private Reteno getRetenoInstance() {
|
|
913
|
+
Reteno reteno = Reteno.getInstance();
|
|
914
|
+
if (reteno == null) {
|
|
915
|
+
throw new IllegalStateException(
|
|
916
|
+
"Reteno SDK is not initialized. Call initialize(apiKey) before using SDK methods."
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
return reteno;
|
|
920
|
+
}
|
|
921
|
+
|
|
632
922
|
@ReactMethod
|
|
633
923
|
public void setAutoOpenLinks(boolean enabled, Promise promise) {
|
|
634
924
|
SharedPreferences prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
|
|
@@ -653,8 +943,7 @@ public void logEcomEventProductViewed(ReadableMap payload, Promise promise) {
|
|
|
653
943
|
promise.reject("Payload Error", "Payload cannot be null");
|
|
654
944
|
return;
|
|
655
945
|
}
|
|
656
|
-
(
|
|
657
|
-
.getRetenoInstance()
|
|
946
|
+
getRetenoInstance()
|
|
658
947
|
.logEcommerceEvent(event);
|
|
659
948
|
} catch (Exception e) {
|
|
660
949
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -673,8 +962,7 @@ public void logEcomEventProductCategoryViewed(ReadableMap payload, Promise promi
|
|
|
673
962
|
promise.reject("Payload Error", "Payload cannot be null");
|
|
674
963
|
return;
|
|
675
964
|
}
|
|
676
|
-
(
|
|
677
|
-
.getRetenoInstance()
|
|
965
|
+
getRetenoInstance()
|
|
678
966
|
.logEcommerceEvent(event);
|
|
679
967
|
} catch (Exception e) {
|
|
680
968
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -693,8 +981,7 @@ public void logEcomEventProductAddedToWishlist(ReadableMap payload, Promise prom
|
|
|
693
981
|
promise.reject("Payload Error", "Payload cannot be null");
|
|
694
982
|
return;
|
|
695
983
|
}
|
|
696
|
-
(
|
|
697
|
-
.getRetenoInstance()
|
|
984
|
+
getRetenoInstance()
|
|
698
985
|
.logEcommerceEvent(event);
|
|
699
986
|
} catch (Exception e) {
|
|
700
987
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -713,8 +1000,7 @@ public void logEcomEventCartUpdated(ReadableMap payload, Promise promise) {
|
|
|
713
1000
|
promise.reject("Payload Error", "Payload cannot be null");
|
|
714
1001
|
return;
|
|
715
1002
|
}
|
|
716
|
-
(
|
|
717
|
-
.getRetenoInstance()
|
|
1003
|
+
getRetenoInstance()
|
|
718
1004
|
.logEcommerceEvent(event);
|
|
719
1005
|
} catch (Exception e) {
|
|
720
1006
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -733,8 +1019,7 @@ public void logEcomEventOrderCreated(ReadableMap payload, Promise promise) {
|
|
|
733
1019
|
promise.reject("Payload Error", "Payload cannot be null");
|
|
734
1020
|
return;
|
|
735
1021
|
}
|
|
736
|
-
(
|
|
737
|
-
.getRetenoInstance()
|
|
1022
|
+
getRetenoInstance()
|
|
738
1023
|
.logEcommerceEvent(event);
|
|
739
1024
|
} catch (Exception e) {
|
|
740
1025
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -753,8 +1038,7 @@ public void logEcomEventOrderUpdated(ReadableMap payload, Promise promise) {
|
|
|
753
1038
|
promise.reject("Payload Error", "Payload cannot be null");
|
|
754
1039
|
return;
|
|
755
1040
|
}
|
|
756
|
-
(
|
|
757
|
-
.getRetenoInstance()
|
|
1041
|
+
getRetenoInstance()
|
|
758
1042
|
.logEcommerceEvent(event);
|
|
759
1043
|
} catch (Exception e) {
|
|
760
1044
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -773,8 +1057,7 @@ public void logEcomEventOrderDelivered(ReadableMap payload, Promise promise) {
|
|
|
773
1057
|
promise.reject("Payload Error", "Payload cannot be null");
|
|
774
1058
|
return;
|
|
775
1059
|
}
|
|
776
|
-
(
|
|
777
|
-
.getRetenoInstance()
|
|
1060
|
+
getRetenoInstance()
|
|
778
1061
|
.logEcommerceEvent(event);
|
|
779
1062
|
} catch (Exception e) {
|
|
780
1063
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -793,8 +1076,7 @@ public void logEcomEventOrderCancelled(ReadableMap payload, Promise promise) {
|
|
|
793
1076
|
promise.reject("Payload Error", "Payload cannot be null");
|
|
794
1077
|
return;
|
|
795
1078
|
}
|
|
796
|
-
(
|
|
797
|
-
.getRetenoInstance()
|
|
1079
|
+
getRetenoInstance()
|
|
798
1080
|
.logEcommerceEvent(event);
|
|
799
1081
|
} catch (Exception e) {
|
|
800
1082
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -813,8 +1095,7 @@ public void logEcomEventSearchRequest(ReadableMap payload, Promise promise) {
|
|
|
813
1095
|
promise.reject("Payload Error", "Payload cannot be null");
|
|
814
1096
|
return;
|
|
815
1097
|
}
|
|
816
|
-
(
|
|
817
|
-
.getRetenoInstance()
|
|
1098
|
+
getRetenoInstance()
|
|
818
1099
|
.logEcommerceEvent(event);
|
|
819
1100
|
} catch (Exception e) {
|
|
820
1101
|
promise.reject("Reteno Android SDK Error", e);
|
|
@@ -824,4 +1105,71 @@ public void logEcomEventSearchRequest(ReadableMap payload, Promise promise) {
|
|
|
824
1105
|
res.putBoolean("success", true);
|
|
825
1106
|
promise.resolve(res);
|
|
826
1107
|
}
|
|
1108
|
+
|
|
1109
|
+
@ReactMethod
|
|
1110
|
+
public void requestNotificationPermission(Promise promise) {
|
|
1111
|
+
try {
|
|
1112
|
+
CompletableFuture<Boolean> future = RetenoNotifications.INSTANCE.requestNotificationPermissionFuture();
|
|
1113
|
+
future.thenAccept(granted -> promise.resolve(granted))
|
|
1114
|
+
.exceptionally(throwable -> {
|
|
1115
|
+
promise.reject("requestNotificationPermission Error", throwable.getMessage());
|
|
1116
|
+
return null;
|
|
1117
|
+
});
|
|
1118
|
+
} catch (Exception e) {
|
|
1119
|
+
promise.reject("Reteno Android SDK requestNotificationPermission Error", e);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
@ReactMethod
|
|
1124
|
+
public void getNotificationPermissionStatus(Promise promise) {
|
|
1125
|
+
try {
|
|
1126
|
+
CompletableFuture<NotificationStatus> future = RetenoNotifications.INSTANCE.getNotificationPermissionStatusFuture();
|
|
1127
|
+
future.thenAccept(status -> promise.resolve(status.name()))
|
|
1128
|
+
.exceptionally(throwable -> {
|
|
1129
|
+
promise.reject("getNotificationPermissionStatus Error", throwable.getMessage());
|
|
1130
|
+
return null;
|
|
1131
|
+
});
|
|
1132
|
+
} catch (Exception e) {
|
|
1133
|
+
promise.reject("Reteno Android SDK getNotificationPermissionStatus Error", e);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
@ReactMethod
|
|
1138
|
+
public void pausePushInAppMessages(Boolean isPaused, Promise promise) {
|
|
1139
|
+
try {
|
|
1140
|
+
getRetenoInstance()
|
|
1141
|
+
.pausePushInAppMessages(isPaused);
|
|
1142
|
+
promise.resolve(true);
|
|
1143
|
+
} catch (Exception e) {
|
|
1144
|
+
promise.reject("Reteno Android SDK pausePushInAppMessages Error", e);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
@ReactMethod
|
|
1149
|
+
public void setPushInAppMessagesPauseBehaviour(String behaviour, Promise promise) {
|
|
1150
|
+
if (behaviour == null || behaviour.trim().isEmpty()) {
|
|
1151
|
+
promise.reject("InvalidArgument", "Missing argument: behaviour ('SKIP_IN_APPS' or 'POSTPONE_IN_APPS')");
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
String normalized = behaviour.trim().toUpperCase();
|
|
1156
|
+
InAppPauseBehaviour parsedBehaviour;
|
|
1157
|
+
|
|
1158
|
+
if ("SKIP_IN_APPS".equals(normalized)) {
|
|
1159
|
+
parsedBehaviour = InAppPauseBehaviour.SKIP_IN_APPS;
|
|
1160
|
+
} else if ("POSTPONE_IN_APPS".equals(normalized)) {
|
|
1161
|
+
parsedBehaviour = InAppPauseBehaviour.POSTPONE_IN_APPS;
|
|
1162
|
+
} else {
|
|
1163
|
+
promise.reject("InvalidArgument", "Invalid argument: behaviour must be 'SKIP_IN_APPS' or 'POSTPONE_IN_APPS'");
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
try {
|
|
1168
|
+
getRetenoInstance()
|
|
1169
|
+
.setPushInAppMessagesPauseBehaviour(parsedBehaviour);
|
|
1170
|
+
promise.resolve(true);
|
|
1171
|
+
} catch (Exception e) {
|
|
1172
|
+
promise.reject("Reteno Android SDK setPushInAppMessagesPauseBehaviour Error", e);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
827
1175
|
}
|