reteno-react-native-sdk 1.7.7 → 1.8.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 +5 -2
- package/android/src/main/java/com/retenosdk/RetenoEcomEvent.java +20 -5
- package/android/src/main/java/com/retenosdk/RetenoSdkModule.java +276 -19
- package/ios/RetenoEcomEvent.swift +16 -25
- package/ios/RetenoSdk.m +16 -1
- package/ios/RetenoSdk.swift +93 -11
- package/lib/commonjs/index.js +107 -15
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +99 -15
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +66 -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 +128 -17
- 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
package/README.md
CHANGED
|
@@ -4,12 +4,22 @@ Reteno SDK
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install reteno-react-native-sdk
|
|
9
|
+
```
|
|
9
10
|
|
|
10
|
-
##
|
|
11
|
+
## Documentation
|
|
11
12
|
|
|
12
|
-
- [
|
|
13
|
+
- [React Native SDK Overview](https://docs.reteno.com/reference/react-native-sdk)
|
|
14
|
+
|
|
15
|
+
### Setup Guides
|
|
16
|
+
|
|
17
|
+
- [React Native iOS SDK Setup](https://docs.reteno.com/reference/react-native-ios-sdk)
|
|
18
|
+
- [React Native Android SDK Setup](https://docs.reteno.com/reference/react-native-android-sdk)
|
|
19
|
+
|
|
20
|
+
### Additional
|
|
21
|
+
|
|
22
|
+
- [React Native SDK Release Notes](https://docs.reteno.com/page/react-native-sdk-release-notes)
|
|
13
23
|
|
|
14
24
|
## License
|
|
15
25
|
|
package/android/build.gradle
CHANGED
|
@@ -72,7 +72,7 @@ dependencies {
|
|
|
72
72
|
//noinspection GradleDynamicVersion
|
|
73
73
|
implementation "com.facebook.react:react-native"
|
|
74
74
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
75
|
-
implementation 'com.reteno:fcm:2.
|
|
75
|
+
implementation 'com.reteno:fcm:2.9.2'
|
|
76
76
|
implementation "com.google.firebase:firebase-messaging:23.1.0"
|
|
77
77
|
implementation "com.google.firebase:firebase-messaging-ktx:23.1.0"
|
|
78
78
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
2
3
|
package="com.retenosdk">
|
|
3
4
|
<application>
|
|
4
5
|
<receiver
|
|
@@ -20,14 +21,16 @@
|
|
|
20
21
|
</receiver>
|
|
21
22
|
<meta-data
|
|
22
23
|
android:name="com.reteno.Receiver.PushReceived"
|
|
23
|
-
android:value="com.retenosdk.RetenoPushReceiver"
|
|
24
|
+
android:value="com.retenosdk.RetenoPushReceiver"
|
|
25
|
+
tools:replace="android:value" />
|
|
24
26
|
<receiver
|
|
25
27
|
android:name="com.retenosdk.RetenoClickReceiver"
|
|
26
28
|
android:enabled="true"
|
|
27
29
|
android:exported="true"/>
|
|
28
30
|
<meta-data
|
|
29
31
|
android:name="com.reteno.Receiver.NotificationClicked"
|
|
30
|
-
android:value="com.retenosdk.RetenoClickReceiver"
|
|
32
|
+
android:value="com.retenosdk.RetenoClickReceiver"
|
|
33
|
+
tools:replace="android:value" />
|
|
31
34
|
</application>
|
|
32
35
|
</manifest>
|
|
33
36
|
|
|
@@ -30,6 +30,21 @@ import javax.annotation.Nullable;
|
|
|
30
30
|
|
|
31
31
|
public class RetenoEcomEvent {
|
|
32
32
|
|
|
33
|
+
@Nullable
|
|
34
|
+
private static String getNullableString(ReadableMap payload, String key) {
|
|
35
|
+
if (payload == null || !payload.hasKey(key) || payload.isNull(key)) return null;
|
|
36
|
+
return payload.getString(key);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Nullable
|
|
40
|
+
private static Double getNullableDouble(ReadableMap payload, String key) {
|
|
41
|
+
if (payload == null || !payload.hasKey(key) || payload.isNull(key)) return null;
|
|
42
|
+
if (payload.getType(key) == ReadableType.Number) {
|
|
43
|
+
return payload.getDouble(key);
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
33
48
|
@Nullable
|
|
34
49
|
static Attributes buildAttributesFromPayload(ReadableMap payload) {
|
|
35
50
|
if (payload == null) return null;
|
|
@@ -167,7 +182,7 @@ public class RetenoEcomEvent {
|
|
|
167
182
|
}
|
|
168
183
|
}
|
|
169
184
|
|
|
170
|
-
String currencyCode = payload
|
|
185
|
+
String currencyCode = getNullableString(payload, "currencyCode");
|
|
171
186
|
|
|
172
187
|
return new CartUpdated(
|
|
173
188
|
cartId,
|
|
@@ -183,9 +198,9 @@ public class RetenoEcomEvent {
|
|
|
183
198
|
if (productId == null) return null;
|
|
184
199
|
int quantity = payload.getInt("quantity");
|
|
185
200
|
double price = payload.getDouble("price");
|
|
186
|
-
Double discount = payload
|
|
187
|
-
String name = payload
|
|
188
|
-
String category = payload
|
|
201
|
+
Double discount = getNullableDouble(payload, "discount");
|
|
202
|
+
String name = getNullableString(payload, "name");
|
|
203
|
+
String category = getNullableString(payload, "category");
|
|
189
204
|
|
|
190
205
|
ReadableArray attributesArray = payload.getArray("attributes");
|
|
191
206
|
ArrayList<Attributes> attributesList = null;
|
|
@@ -387,4 +402,4 @@ public class RetenoEcomEvent {
|
|
|
387
402
|
isFound
|
|
388
403
|
);
|
|
389
404
|
}
|
|
390
|
-
}
|
|
405
|
+
}
|
|
@@ -38,6 +38,13 @@ import com.reteno.core.view.iam.callback.InAppErrorData;
|
|
|
38
38
|
import com.reteno.core.view.iam.callback.InAppLifecycleCallback;
|
|
39
39
|
import com.reteno.core.features.recommendation.GetRecommendationResponseCallback;
|
|
40
40
|
import com.reteno.core.domain.model.ecom.EcomEvent;
|
|
41
|
+
import com.reteno.core.features.iam.InAppPauseBehaviour;
|
|
42
|
+
import com.reteno.push.RetenoNotifications;
|
|
43
|
+
import com.reteno.push.permission.NotificationStatus;
|
|
44
|
+
import com.reteno.push.events.InAppCustomData;
|
|
45
|
+
import com.reteno.core.util.Procedure;
|
|
46
|
+
|
|
47
|
+
import kotlin.Unit;
|
|
41
48
|
|
|
42
49
|
import android.util.Log;
|
|
43
50
|
import android.content.SharedPreferences;
|
|
@@ -46,8 +53,7 @@ import java.util.HashMap;
|
|
|
46
53
|
import java.util.List;
|
|
47
54
|
import java.time.ZonedDateTime;
|
|
48
55
|
import java.util.Map;
|
|
49
|
-
|
|
50
|
-
import kotlin.Unit;
|
|
56
|
+
import java.util.concurrent.CompletableFuture;
|
|
51
57
|
|
|
52
58
|
public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
53
59
|
public static final String NAME = "RetenoSdk";
|
|
@@ -71,6 +77,18 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
71
77
|
return NAME;
|
|
72
78
|
}
|
|
73
79
|
|
|
80
|
+
@Override
|
|
81
|
+
public void onCatalystInstanceDestroy() {
|
|
82
|
+
cleanupRetenoNotificationsListeners();
|
|
83
|
+
super.onCatalystInstanceDestroy();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@Override
|
|
87
|
+
public void invalidate() {
|
|
88
|
+
cleanupRetenoNotificationsListeners();
|
|
89
|
+
super.invalidate();
|
|
90
|
+
}
|
|
91
|
+
|
|
74
92
|
@ReactMethod
|
|
75
93
|
public void setDeviceToken(String deviceToken, Promise promise) {
|
|
76
94
|
}
|
|
@@ -132,14 +150,12 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
132
150
|
);
|
|
133
151
|
}
|
|
134
152
|
|
|
135
|
-
private static WritableMap
|
|
153
|
+
private static WritableMap parseBundle(Bundle bundle) {
|
|
136
154
|
WritableMap params = Arguments.createMap();
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (extras != null) {
|
|
155
|
+
if (bundle != null) {
|
|
140
156
|
try {
|
|
141
|
-
for (String key :
|
|
142
|
-
Object value =
|
|
157
|
+
for (String key : bundle.keySet()) {
|
|
158
|
+
Object value = bundle.get(key);
|
|
143
159
|
if (value instanceof HashMap) {
|
|
144
160
|
@SuppressWarnings("unchecked")
|
|
145
161
|
WritableMap map = convertHashMap((HashMap<String, Object>) value);
|
|
@@ -149,13 +165,16 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
149
165
|
}
|
|
150
166
|
}
|
|
151
167
|
} catch (Exception e) {
|
|
152
|
-
Log.e("
|
|
168
|
+
Log.e("parseBundle", "Error converting Bundle to WritableMap: " + e.getMessage(), e);
|
|
153
169
|
}
|
|
154
170
|
}
|
|
155
|
-
|
|
156
171
|
return params;
|
|
157
172
|
}
|
|
158
173
|
|
|
174
|
+
private static WritableMap parseIntent(Intent intent) {
|
|
175
|
+
return parseBundle(intent.getExtras());
|
|
176
|
+
}
|
|
177
|
+
|
|
159
178
|
private static WritableMap convertHashMap(HashMap<String, Object> map) {
|
|
160
179
|
WritableMap writableMap = Arguments.createMap();
|
|
161
180
|
|
|
@@ -253,6 +272,71 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
253
272
|
}
|
|
254
273
|
}
|
|
255
274
|
|
|
275
|
+
@ReactMethod
|
|
276
|
+
public void setInAppMessagesPauseBehaviour(String behaviour, Promise promise) {
|
|
277
|
+
if (behaviour == null || behaviour.trim().isEmpty()) {
|
|
278
|
+
promise.reject("InvalidArgument", "Missing argument: behaviour ('SKIP_IN_APPS' or 'POSTPONE_IN_APPS')");
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
String normalized = behaviour.trim().toUpperCase();
|
|
283
|
+
InAppPauseBehaviour parsedBehaviour;
|
|
284
|
+
|
|
285
|
+
if ("SKIP_IN_APPS".equals(normalized)) {
|
|
286
|
+
parsedBehaviour = InAppPauseBehaviour.SKIP_IN_APPS;
|
|
287
|
+
} else if ("POSTPONE_IN_APPS".equals(normalized)) {
|
|
288
|
+
parsedBehaviour = InAppPauseBehaviour.POSTPONE_IN_APPS;
|
|
289
|
+
} else {
|
|
290
|
+
promise.reject("InvalidArgument", "Invalid argument: behaviour must be 'SKIP_IN_APPS' or 'POSTPONE_IN_APPS'");
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
try {
|
|
295
|
+
Activity currentActivity = getCurrentActivity();
|
|
296
|
+
if (currentActivity == null) {
|
|
297
|
+
promise.reject("ActivityUnavailable", "Current activity is not available");
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
((RetenoApplication) currentActivity.getApplication())
|
|
301
|
+
.getRetenoInstance()
|
|
302
|
+
.setInAppMessagesPauseBehaviour(parsedBehaviour);
|
|
303
|
+
promise.resolve(true);
|
|
304
|
+
} catch (Exception e) {
|
|
305
|
+
promise.reject("Reteno Android SDK setInAppMessagesPauseBehaviour Error", e);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
@ReactMethod
|
|
310
|
+
public void setMultiAccountUserAttributes(ReadableMap payload, Promise promise) {
|
|
311
|
+
String externalUserId = (payload.hasKey("externalUserId") && !payload.isNull("externalUserId"))
|
|
312
|
+
? payload.getString("externalUserId")
|
|
313
|
+
: null;
|
|
314
|
+
if (externalUserId == null || externalUserId.isEmpty()) {
|
|
315
|
+
promise.reject("Parsing error", "externalUserId cannot be null");
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
User user = RetenoUserAttributes.buildUserFromPayload(payload);
|
|
320
|
+
|
|
321
|
+
try {
|
|
322
|
+
Activity currentActivity = getCurrentActivity();
|
|
323
|
+
if (currentActivity == null) {
|
|
324
|
+
promise.reject("ActivityUnavailable", "Current activity is not available");
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
((RetenoApplication) currentActivity.getApplication())
|
|
328
|
+
.getRetenoInstance()
|
|
329
|
+
.setMultiAccountUserAttributes(externalUserId, user);
|
|
330
|
+
} catch (Exception e) {
|
|
331
|
+
promise.reject("Reteno Android SDK Error", e);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
WritableMap res = new WritableNativeMap();
|
|
336
|
+
res.putBoolean("success", true);
|
|
337
|
+
promise.resolve(res);
|
|
338
|
+
}
|
|
339
|
+
|
|
256
340
|
@ReactMethod
|
|
257
341
|
public void updatePushPermissionStatusAndroid(Promise promise) {
|
|
258
342
|
try {
|
|
@@ -270,6 +354,89 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
270
354
|
RetenoEventQueue.getInstance().dispatch(eventName, eventData, reactContext);
|
|
271
355
|
}
|
|
272
356
|
|
|
357
|
+
private Procedure<Bundle> pushDismissedListener;
|
|
358
|
+
private Procedure<Bundle> customPushListener;
|
|
359
|
+
private Procedure<InAppCustomData> inAppCustomDataRetenoListener;
|
|
360
|
+
private boolean notificationsListenersSetup = false;
|
|
361
|
+
|
|
362
|
+
private void setupRetenoNotificationsListeners() {
|
|
363
|
+
if (notificationsListenersSetup) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
notificationsListenersSetup = true;
|
|
367
|
+
try {
|
|
368
|
+
pushDismissedListener = bundle -> {
|
|
369
|
+
sendEventToJS("reteno-push-dismissed", parseBundle(bundle));
|
|
370
|
+
};
|
|
371
|
+
RetenoNotifications.INSTANCE.getClose().addListener(pushDismissedListener);
|
|
372
|
+
} catch (Exception e) {
|
|
373
|
+
Log.w(NAME, "Could not register push dismissed listener", e);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
try {
|
|
377
|
+
customPushListener = bundle -> {
|
|
378
|
+
sendEventToJS("reteno-custom-push-received", parseBundle(bundle));
|
|
379
|
+
};
|
|
380
|
+
RetenoNotifications.INSTANCE.getCustom().addListener(customPushListener);
|
|
381
|
+
} catch (Exception e) {
|
|
382
|
+
Log.w(NAME, "Could not register custom push listener", e);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
try {
|
|
386
|
+
inAppCustomDataRetenoListener = inAppCustomData -> {
|
|
387
|
+
WritableMap eventData = Arguments.createMap();
|
|
388
|
+
eventData.putString("url", inAppCustomData.getUrl());
|
|
389
|
+
eventData.putString("inapp_source", inAppCustomData.getSource());
|
|
390
|
+
eventData.putString("inapp_id", inAppCustomData.getInAppId());
|
|
391
|
+
WritableMap customDataMap = Arguments.createMap();
|
|
392
|
+
if (inAppCustomData.getData() != null) {
|
|
393
|
+
for (Map.Entry<String, String> entry : inAppCustomData.getData().entrySet()) {
|
|
394
|
+
customDataMap.putString(entry.getKey(), entry.getValue());
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
eventData.putMap("customData", customDataMap);
|
|
398
|
+
sendEventToJS("reteno-in-app-custom-data-received", eventData);
|
|
399
|
+
};
|
|
400
|
+
RetenoNotifications.INSTANCE.getInAppCustomDataReceived().addListener(inAppCustomDataRetenoListener);
|
|
401
|
+
} catch (Exception e) {
|
|
402
|
+
Log.w(NAME, "Could not register in-app custom data listener", e);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
private void cleanupRetenoNotificationsListeners() {
|
|
407
|
+
if (!notificationsListenersSetup) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
notificationsListenersSetup = false;
|
|
411
|
+
|
|
412
|
+
try {
|
|
413
|
+
if (pushDismissedListener != null) {
|
|
414
|
+
RetenoNotifications.INSTANCE.getClose().removeListener(pushDismissedListener);
|
|
415
|
+
pushDismissedListener = null;
|
|
416
|
+
}
|
|
417
|
+
} catch (Exception e) {
|
|
418
|
+
Log.w(NAME, "Could not unregister push dismissed listener", e);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
try {
|
|
422
|
+
if (customPushListener != null) {
|
|
423
|
+
RetenoNotifications.INSTANCE.getCustom().removeListener(customPushListener);
|
|
424
|
+
customPushListener = null;
|
|
425
|
+
}
|
|
426
|
+
} catch (Exception e) {
|
|
427
|
+
Log.w(NAME, "Could not unregister custom push listener", e);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
try {
|
|
431
|
+
if (inAppCustomDataRetenoListener != null) {
|
|
432
|
+
RetenoNotifications.INSTANCE.getInAppCustomDataReceived().removeListener(inAppCustomDataRetenoListener);
|
|
433
|
+
inAppCustomDataRetenoListener = null;
|
|
434
|
+
}
|
|
435
|
+
} catch (Exception e) {
|
|
436
|
+
Log.w(NAME, "Could not unregister in-app custom data listener", e);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
273
440
|
private InAppLifecycleCallback inAppLifecycleCallback;
|
|
274
441
|
|
|
275
442
|
@ReactMethod
|
|
@@ -569,9 +736,14 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
569
736
|
|
|
570
737
|
@ReactMethod
|
|
571
738
|
public void unsubscribeAllMessagesCountChanged(Promise promise) {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
739
|
+
try {
|
|
740
|
+
((RetenoApplication) this.context.getCurrentActivity().getApplication())
|
|
741
|
+
.getRetenoInstance().getAppInbox().unsubscribeAllMessagesCountChanged();
|
|
742
|
+
messagesCountChangedCallback = null;
|
|
743
|
+
promise.resolve(null);
|
|
744
|
+
} catch (Exception e) {
|
|
745
|
+
promise.reject("UnsubscribeError", e);
|
|
746
|
+
}
|
|
575
747
|
}
|
|
576
748
|
|
|
577
749
|
private RetenoResultCallback<Integer> messagesCountChangedCallback;
|
|
@@ -607,13 +779,18 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
607
779
|
|
|
608
780
|
@ReactMethod
|
|
609
781
|
public void unsubscribeMessagesCountChanged(Promise promise) {
|
|
610
|
-
|
|
611
|
-
(
|
|
612
|
-
|
|
613
|
-
|
|
782
|
+
try {
|
|
783
|
+
if (messagesCountChangedCallback != null) {
|
|
784
|
+
((RetenoApplication) this.context.getCurrentActivity().getApplication())
|
|
785
|
+
.getRetenoInstance().getAppInbox().unsubscribeMessagesCountChanged(messagesCountChangedCallback);
|
|
786
|
+
messagesCountChangedCallback = null;
|
|
787
|
+
} else {
|
|
788
|
+
((RetenoApplication) this.context.getCurrentActivity().getApplication())
|
|
789
|
+
.getRetenoInstance().getAppInbox().unsubscribeAllMessagesCountChanged();
|
|
790
|
+
}
|
|
614
791
|
promise.resolve(null);
|
|
615
|
-
}
|
|
616
|
-
promise.reject("
|
|
792
|
+
} catch (Exception e) {
|
|
793
|
+
promise.reject("UnsubscribeError", e);
|
|
617
794
|
}
|
|
618
795
|
}
|
|
619
796
|
|
|
@@ -623,6 +800,7 @@ public class RetenoSdkModule extends ReactContextBaseJavaModule {
|
|
|
623
800
|
ReactContext reactContext = ((RetenoReactNativeApplication) this.context.getApplicationContext())
|
|
624
801
|
.getReactContext();
|
|
625
802
|
RetenoEventQueue.getInstance().setInitialized(reactContext);
|
|
803
|
+
setupRetenoNotificationsListeners();
|
|
626
804
|
promise.resolve(true);
|
|
627
805
|
} catch (Exception e) {
|
|
628
806
|
promise.reject("Reteno Android SDK initializeEventHandler Error", e);
|
|
@@ -824,4 +1002,83 @@ public void logEcomEventSearchRequest(ReadableMap payload, Promise promise) {
|
|
|
824
1002
|
res.putBoolean("success", true);
|
|
825
1003
|
promise.resolve(res);
|
|
826
1004
|
}
|
|
1005
|
+
|
|
1006
|
+
@ReactMethod
|
|
1007
|
+
public void requestNotificationPermission(Promise promise) {
|
|
1008
|
+
try {
|
|
1009
|
+
CompletableFuture<Boolean> future = RetenoNotifications.INSTANCE.requestNotificationPermissionFuture();
|
|
1010
|
+
future.thenAccept(granted -> promise.resolve(granted))
|
|
1011
|
+
.exceptionally(throwable -> {
|
|
1012
|
+
promise.reject("requestNotificationPermission Error", throwable.getMessage());
|
|
1013
|
+
return null;
|
|
1014
|
+
});
|
|
1015
|
+
} catch (Exception e) {
|
|
1016
|
+
promise.reject("Reteno Android SDK requestNotificationPermission Error", e);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
@ReactMethod
|
|
1021
|
+
public void getNotificationPermissionStatus(Promise promise) {
|
|
1022
|
+
try {
|
|
1023
|
+
CompletableFuture<NotificationStatus> future = RetenoNotifications.INSTANCE.getNotificationPermissionStatusFuture();
|
|
1024
|
+
future.thenAccept(status -> promise.resolve(status.name()))
|
|
1025
|
+
.exceptionally(throwable -> {
|
|
1026
|
+
promise.reject("getNotificationPermissionStatus Error", throwable.getMessage());
|
|
1027
|
+
return null;
|
|
1028
|
+
});
|
|
1029
|
+
} catch (Exception e) {
|
|
1030
|
+
promise.reject("Reteno Android SDK getNotificationPermissionStatus Error", e);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
@ReactMethod
|
|
1035
|
+
public void pausePushInAppMessages(Boolean isPaused, Promise promise) {
|
|
1036
|
+
try {
|
|
1037
|
+
Activity currentActivity = getCurrentActivity();
|
|
1038
|
+
if (currentActivity == null) {
|
|
1039
|
+
promise.reject("ActivityUnavailable", "Current activity is not available");
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
((RetenoApplication) currentActivity.getApplication())
|
|
1043
|
+
.getRetenoInstance()
|
|
1044
|
+
.pausePushInAppMessages(isPaused);
|
|
1045
|
+
promise.resolve(true);
|
|
1046
|
+
} catch (Exception e) {
|
|
1047
|
+
promise.reject("Reteno Android SDK pausePushInAppMessages Error", e);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
@ReactMethod
|
|
1052
|
+
public void setPushInAppMessagesPauseBehaviour(String behaviour, Promise promise) {
|
|
1053
|
+
if (behaviour == null || behaviour.trim().isEmpty()) {
|
|
1054
|
+
promise.reject("InvalidArgument", "Missing argument: behaviour ('SKIP_IN_APPS' or 'POSTPONE_IN_APPS')");
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
String normalized = behaviour.trim().toUpperCase();
|
|
1059
|
+
InAppPauseBehaviour parsedBehaviour;
|
|
1060
|
+
|
|
1061
|
+
if ("SKIP_IN_APPS".equals(normalized)) {
|
|
1062
|
+
parsedBehaviour = InAppPauseBehaviour.SKIP_IN_APPS;
|
|
1063
|
+
} else if ("POSTPONE_IN_APPS".equals(normalized)) {
|
|
1064
|
+
parsedBehaviour = InAppPauseBehaviour.POSTPONE_IN_APPS;
|
|
1065
|
+
} else {
|
|
1066
|
+
promise.reject("InvalidArgument", "Invalid argument: behaviour must be 'SKIP_IN_APPS' or 'POSTPONE_IN_APPS'");
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
try {
|
|
1071
|
+
Activity currentActivity = getCurrentActivity();
|
|
1072
|
+
if (currentActivity == null) {
|
|
1073
|
+
promise.reject("ActivityUnavailable", "Current activity is not available");
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
((RetenoApplication) currentActivity.getApplication())
|
|
1077
|
+
.getRetenoInstance()
|
|
1078
|
+
.setPushInAppMessagesPauseBehaviour(parsedBehaviour);
|
|
1079
|
+
promise.resolve(true);
|
|
1080
|
+
} catch (Exception e) {
|
|
1081
|
+
promise.reject("Reteno Android SDK setPushInAppMessagesPauseBehaviour Error", e);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
827
1084
|
}
|
|
@@ -179,25 +179,21 @@ class RetenoEcomEvent: NSObject {
|
|
|
179
179
|
|
|
180
180
|
private static func buildOrderFromPayload(_ payload: [String: Any]?) -> Ecommerce.Order? {
|
|
181
181
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
case .delivered:
|
|
195
|
-
return Ecommerce.Order.Status(rawValue: "DELIVERED")!
|
|
196
|
-
case .cancelled:
|
|
197
|
-
return Ecommerce.Order.Status(rawValue: "CANCELLED")!
|
|
198
|
-
}
|
|
182
|
+
enum LocalStatus: Int {
|
|
183
|
+
case initialized = 0
|
|
184
|
+
case inprogress = 1
|
|
185
|
+
case delivered = 2
|
|
186
|
+
case cancelled = 3
|
|
187
|
+
|
|
188
|
+
var toOrderStatus: Ecommerce.Order.Status {
|
|
189
|
+
switch self {
|
|
190
|
+
case .initialized: return .INITIALIZED
|
|
191
|
+
case .inprogress: return .IN_PROGRESS
|
|
192
|
+
case .delivered: return .DELIVERED
|
|
193
|
+
case .cancelled: return .CANCELLED
|
|
199
194
|
}
|
|
200
195
|
}
|
|
196
|
+
}
|
|
201
197
|
|
|
202
198
|
|
|
203
199
|
guard let payload = payload else { return nil }
|
|
@@ -205,15 +201,10 @@ class RetenoEcomEvent: NSObject {
|
|
|
205
201
|
|
|
206
202
|
let externalCustomerId = payload["externalCustomerId"] as? String
|
|
207
203
|
guard let totalCost = payload["totalCost"] as? Float else { return nil }
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
guard let statusRaw = payload["status"] as? Int,
|
|
212
|
-
let localStatus = LocalStatus(rawValue: statusRaw) else { return nil }
|
|
213
|
-
|
|
214
|
-
let orderStatus = localStatus.toOrderStatus
|
|
204
|
+
guard let statusRaw = payload["status"] as? Int,
|
|
205
|
+
let localStatus = LocalStatus(rawValue: statusRaw) else { return nil }
|
|
206
|
+
let orderStatus = localStatus.toOrderStatus
|
|
215
207
|
|
|
216
|
-
|
|
217
208
|
let cartId = payload["cartId"] as? String
|
|
218
209
|
let email = payload["email"] as? String
|
|
219
210
|
let phone = payload["phone"] as? String
|
package/ios/RetenoSdk.m
CHANGED
|
@@ -28,6 +28,14 @@ RCT_EXTERN_METHOD(pauseInAppMessages:(BOOL)isPaused
|
|
|
28
28
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
29
29
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
30
30
|
|
|
31
|
+
RCT_EXTERN_METHOD(setInAppMessagesPauseBehaviour:(NSString*)behaviour
|
|
32
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
33
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
34
|
+
|
|
35
|
+
RCT_EXTERN_METHOD(setMultiAccountUserAttributes:(NSDictionary*)payload
|
|
36
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
37
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
38
|
+
|
|
31
39
|
RCT_EXTERN_METHOD(setInAppLifecycleCallback)
|
|
32
40
|
|
|
33
41
|
RCT_EXTERN_METHOD(getRecommendations:(NSDictionary*)payload
|
|
@@ -42,7 +50,14 @@ RCT_EXTERN_METHOD(getAppInboxMessages:(NSDictionary*)payload
|
|
|
42
50
|
withResolver:(RCTPromiseResolveBlock)resolve
|
|
43
51
|
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
44
52
|
|
|
45
|
-
RCT_EXTERN_METHOD(onUnreadMessagesCountChanged)
|
|
53
|
+
RCT_EXTERN_METHOD(onUnreadMessagesCountChanged:(RCTPromiseResolveBlock)resolve
|
|
54
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
55
|
+
|
|
56
|
+
RCT_EXTERN_METHOD(unsubscribeMessagesCountChanged:(RCTPromiseResolveBlock)resolve
|
|
57
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
58
|
+
|
|
59
|
+
RCT_EXTERN_METHOD(unsubscribeAllMessagesCountChanged:(RCTPromiseResolveBlock)resolve
|
|
60
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
46
61
|
|
|
47
62
|
RCT_EXTERN_METHOD(markAsOpened:(NSArray<NSString *> *)messageIds
|
|
48
63
|
withResolver:(RCTPromiseResolveBlock)resolve
|