react-native-netmera 1.3.8 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +276 -185
- package/RNNetmera.podspec +8 -6
- package/android/build/.transforms/{00a1a2a97b81c133eb73f4c946b323aa.bin → 5e6250db45de369f8592b678730f6ff3/results.bin} +0 -0
- package/android/build/.transforms/5e6250db45de369f8592b678730f6ff3/transformed/classes/classes.dex +0 -0
- package/android/build/.transforms/{8b103fc7545c9799a16ff009dc2ead52.bin → f62dff1c96346bd5377ea8eccb1b7016/results.bin} +0 -0
- package/android/build/.transforms/f62dff1c96346bd5377ea8eccb1b7016/transformed/classes/classes.dex +0 -0
- package/android/build/generated/source/buildConfig/debug/com/netmera/reactnativesdk/BuildConfig.java +0 -2
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +16 -0
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +2 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/{compile_only_not_namespaced_r_class_jar → compile_r_class_jar}/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +1 -4
- package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +1 -1
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmera.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraCategoryObject.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraConfiguration.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$10.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$3.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$4.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$5.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$6.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$7.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$8.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$9.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraPushBroadcastReceiver.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraPushHeadlessService.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraUtil$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraUtil.class +0 -0
- package/android/build/intermediates/packaged_manifests/debug/output-metadata.json +16 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +1 -4
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmera.java +2 -6
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraModule.java +116 -5
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraPushBroadcastReceiver.java +9 -7
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraUtil.java +52 -4
- package/index.js +19 -320
- package/ios/RNNetmera.h +2 -2
- package/ios/RNNetmera.m +64 -2
- package/ios/RNNetmeraUtils.h +4 -0
- package/ios/RNNetmeraUtils.m +38 -0
- package/package.json +1 -1
- package/src/Netmera.js +223 -0
- package/src/NetmeraInbox.js +95 -0
- package/src/NetmeraUser.js +92 -0
- package/android/build/.transforms/00a1a2a97b81c133eb73f4c946b323aa/classes/classes.dex +0 -0
- package/android/build/.transforms/8b103fc7545c9799a16ff009dc2ead52/classes/classes.dex +0 -0
- package/android/build/.transforms/9e086edd0cadc1c3e325107cef1d09ca/classes/classes.dex +0 -0
- package/android/build/.transforms/9e086edd0cadc1c3e325107cef1d09ca.bin +0 -1
- package/android/build/.transforms/b0d220ccd1945e73ed321c4b96bb37de/classes/classes.dex +0 -0
- package/android/build/.transforms/b0d220ccd1945e73ed321c4b96bb37de.bin +0 -1
- package/android/build/.transforms/f70db9a523a6c7b9af14929671f6c09b/classes/classes.dex +0 -0
- package/android/build/.transforms/f70db9a523a6c7b9af14929671f6c09b.bin +0 -1
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output.json +0 -27
- package/android/build/intermediates/incremental/debug-mergeNativeLibs/merge-state +0 -0
- package/android/build/intermediates/merged_manifests/debug/output.json +0 -27
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"artifactType": {
|
|
4
|
+
"type": "PACKAGED_MANIFESTS",
|
|
5
|
+
"kind": "Directory"
|
|
6
|
+
},
|
|
7
|
+
"applicationId": "com.netmera.reactnativesdk",
|
|
8
|
+
"variantName": "debug",
|
|
9
|
+
"elements": [
|
|
10
|
+
{
|
|
11
|
+
"type": "SINGLE",
|
|
12
|
+
"filters": [],
|
|
13
|
+
"outputFile": "../../library_manifest/debug/AndroidManifest.xml"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
Binary file
|
|
@@ -3414,7 +3414,6 @@ string abc_searchview_description_voice
|
|
|
3414
3414
|
string abc_shareactionprovider_share_with
|
|
3415
3415
|
string abc_shareactionprovider_share_with_application
|
|
3416
3416
|
string abc_toolbar_collapse_description
|
|
3417
|
-
string ag_sdk_cbg_root
|
|
3418
3417
|
string aimodule_exclude_domain
|
|
3419
3418
|
string alert_description
|
|
3420
3419
|
string androidx_startup
|
|
@@ -3487,11 +3486,10 @@ string header_description
|
|
|
3487
3486
|
string hide_bottom_view_on_scroll_behavior
|
|
3488
3487
|
string hms_abort
|
|
3489
3488
|
string hms_abort_message
|
|
3489
|
+
string hms_apk_not_installed_hints
|
|
3490
3490
|
string hms_bindfaildlg_message
|
|
3491
3491
|
string hms_bindfaildlg_title
|
|
3492
3492
|
string hms_cancel
|
|
3493
|
-
string hms_cancel_after_cancel
|
|
3494
|
-
string hms_cancel_install_message
|
|
3495
3493
|
string hms_check_failure
|
|
3496
3494
|
string hms_checking
|
|
3497
3495
|
string hms_confirm
|
|
@@ -3500,7 +3498,6 @@ string hms_download_no_space
|
|
|
3500
3498
|
string hms_download_retry
|
|
3501
3499
|
string hms_downloading_loading
|
|
3502
3500
|
string hms_install
|
|
3503
|
-
string hms_install_after_cancel
|
|
3504
3501
|
string hms_install_message
|
|
3505
3502
|
string hms_is_spoof
|
|
3506
3503
|
string hms_push_channel
|
package/android/build.gradle
CHANGED
|
@@ -16,8 +16,8 @@ android {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
dependencies {
|
|
19
|
-
implementation 'com.netmera:nmcore:3.9.
|
|
20
|
-
implementation 'com.netmera:nmfcm:3.9.
|
|
21
|
-
implementation 'com.netmera:nmhms:3.9.
|
|
19
|
+
implementation 'com.netmera:nmcore:3.9.3'
|
|
20
|
+
implementation 'com.netmera:nmfcm:3.9.2'
|
|
21
|
+
implementation 'com.netmera:nmhms:3.9.3'
|
|
22
22
|
implementation 'com.facebook.react:react-native:+'
|
|
23
23
|
}
|
|
@@ -16,11 +16,7 @@ public class RNNetmera {
|
|
|
16
16
|
static void setNetmeraHeaders() {
|
|
17
17
|
ContentValues headerValues = new ContentValues();
|
|
18
18
|
headerValues.put("X-netmera-framework", "react");
|
|
19
|
-
headerValues.put("X-netmera-frameworkV", "1.
|
|
19
|
+
headerValues.put("X-netmera-frameworkV", "1.4.1");
|
|
20
20
|
Netmera.setNetmeraHeaders(headerValues);
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
public static void logging(boolean enabled) {
|
|
24
|
-
Netmera.logging(enabled);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
22
|
+
}
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
package com.netmera.reactnativesdk;
|
|
10
10
|
|
|
11
|
+
import android.os.Bundle;
|
|
12
|
+
|
|
13
|
+
import androidx.annotation.NonNull;
|
|
14
|
+
import androidx.annotation.Nullable;
|
|
15
|
+
|
|
11
16
|
import com.facebook.react.bridge.Promise;
|
|
12
17
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
13
18
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
@@ -21,9 +26,16 @@ import com.netmera.NetmeraInboxCategory;
|
|
|
21
26
|
import com.netmera.NetmeraInboxFilter;
|
|
22
27
|
import com.netmera.NetmeraInteractiveAction;
|
|
23
28
|
import com.netmera.NetmeraPushObject;
|
|
29
|
+
import com.netmera.callbacks.NMCategoryPreferenceFetchCallback;
|
|
30
|
+
import com.netmera.callbacks.NMCategoryPreferenceSetCallback;
|
|
31
|
+
import com.netmera.callbacks.NMInboxCountResultListener;
|
|
32
|
+
import com.netmera.data.NMCategoryPreference;
|
|
33
|
+
import com.netmera.data.NMInboxStatusCount;
|
|
34
|
+
import com.netmera.data.NMInboxStatusCountFilter;
|
|
24
35
|
|
|
25
36
|
import java.util.ArrayList;
|
|
26
37
|
import java.util.Collections;
|
|
38
|
+
import java.util.HashMap;
|
|
27
39
|
import java.util.List;
|
|
28
40
|
import java.util.Map;
|
|
29
41
|
|
|
@@ -46,6 +58,14 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
46
58
|
private static final String ERROR_MESSAGE_NULL_CATEGORY = "Must call fetchCategory method first";
|
|
47
59
|
private static final String ERROR_CODE_INVALID_PUSH_OBJECT = "2021";
|
|
48
60
|
private static final String ERROR_MESSAGE_INVALID_PUSH_OBJECT = "Received NetmeraPushObject was not valid.";
|
|
61
|
+
private static final String ERROR_CODE_NULL_INBOX_STATUS = "2022";
|
|
62
|
+
private static final String ERROR_MESSAGE_NULL_INBOX_STATUS = "Inbox status can't be null.";
|
|
63
|
+
private static final String ERROR_CODE_INBOX_STATUS = "2023";
|
|
64
|
+
private static final String ERROR_MESSAGE_INBOX_STATUS = "Error occurred while fetching inbox count for status.";
|
|
65
|
+
private static final String ERROR_CODE_CATEGORY_PREFERENCE = "2024";
|
|
66
|
+
private static final String ERROR_MESSAGE_CATEGORY_PREFERENCE = "Error occurred while fetching user category preference list.";
|
|
67
|
+
private static final String ERROR_CODE_SET_CATEGORY_PREFERENCE = "2025";
|
|
68
|
+
private static final String ERROR_MESSAGE_SET_CATEGORY_PREFERENCE = "Error occurred while setting user category preference list.";
|
|
49
69
|
|
|
50
70
|
public static ReactApplicationContext reactContext;
|
|
51
71
|
private NetmeraInbox netmeraInbox;
|
|
@@ -56,6 +76,7 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
56
76
|
RNNetmeraModule.reactContext = reactContext;
|
|
57
77
|
}
|
|
58
78
|
|
|
79
|
+
@NonNull
|
|
59
80
|
@Override
|
|
60
81
|
public String getName() {
|
|
61
82
|
return "RNNetmera";
|
|
@@ -66,11 +87,6 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
66
87
|
promise.resolve(Netmera.getCurrentExternalId());
|
|
67
88
|
}
|
|
68
89
|
|
|
69
|
-
@ReactMethod
|
|
70
|
-
public void logging(final Boolean enabled) {
|
|
71
|
-
RNNetmera.logging(enabled);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
90
|
@ReactMethod
|
|
75
91
|
public void setBaseUrl(final String baseUrl) {
|
|
76
92
|
Netmera.setBaseUrl(baseUrl);
|
|
@@ -391,6 +407,101 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
391
407
|
promise.resolve(RNNetmeraCategoryObject.mapCategoryObjects(netmeraInboxCategory.categories()));
|
|
392
408
|
}
|
|
393
409
|
|
|
410
|
+
@ReactMethod
|
|
411
|
+
public void getInboxCountForStatus(ReadableMap readableMap, final Promise promise) {
|
|
412
|
+
NMInboxStatusCountFilter.Builder builder = new NMInboxStatusCountFilter.Builder();
|
|
413
|
+
|
|
414
|
+
if (hasKey(readableMap, CATEGORIES)) {
|
|
415
|
+
Object categories = readableMap.toHashMap().get(CATEGORIES);
|
|
416
|
+
List<Integer> categoryList = new ArrayList<>();
|
|
417
|
+
if (categories instanceof Integer) {
|
|
418
|
+
categoryList.add((Integer) categories);
|
|
419
|
+
} else if (categories instanceof List) {
|
|
420
|
+
categoryList = (List<Integer>) categories;
|
|
421
|
+
}
|
|
422
|
+
builder.setCategoryList(categoryList.toArray(new Integer[0]));
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (hasKey(readableMap, STATUS)) {
|
|
426
|
+
builder.setInboxStatus(RNNetmeraUtil.getInboxStatus(readableMap.getInt(STATUS)));
|
|
427
|
+
} else {
|
|
428
|
+
promise.reject(ERROR_CODE_NULL_INBOX_STATUS, ERROR_MESSAGE_NULL_INBOX_STATUS);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (hasKey(readableMap, INCLUDE_EXPIRED_OBJECTS)) {
|
|
433
|
+
builder.setIncludeExpired(readableMap.getBoolean(INCLUDE_EXPIRED_OBJECTS));
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
NMInboxStatusCountFilter filter = builder.build();
|
|
437
|
+
|
|
438
|
+
Netmera.getInboxCountForStatus(filter, new NMInboxCountResultListener() {
|
|
439
|
+
@Override
|
|
440
|
+
public void onSuccess(@NonNull NMInboxStatusCount nmInboxStatusCount) {
|
|
441
|
+
promise.resolve(RNNetmeraUtil.parseInboxCountForStatusToMap(nmInboxStatusCount));
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
@Override
|
|
445
|
+
public void onFailure(@Nullable String s) {
|
|
446
|
+
promise.reject(ERROR_CODE_INBOX_STATUS, ERROR_MESSAGE_INBOX_STATUS);
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
@ReactMethod
|
|
452
|
+
public void getUserCategoryPreferenceList(final Promise promise) {
|
|
453
|
+
Netmera.getUserCategoryPreferenceList(new NMCategoryPreferenceFetchCallback() {
|
|
454
|
+
@Override
|
|
455
|
+
public void onSuccess(List<NMCategoryPreference> list) {
|
|
456
|
+
promise.resolve(RNNetmeraUtil.parseUserCategoryPreferenceListToMap(list));
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
@Override
|
|
460
|
+
public void onFailure(@Nullable String s) {
|
|
461
|
+
promise.reject(ERROR_CODE_CATEGORY_PREFERENCE, ERROR_MESSAGE_CATEGORY_PREFERENCE);
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
@ReactMethod
|
|
467
|
+
public void setUserCategoryPreference(int categoryId, boolean categoryEnabled, final Promise promise) {
|
|
468
|
+
Netmera.setUserCategoryPreference(categoryId, categoryEnabled, new NMCategoryPreferenceSetCallback() {
|
|
469
|
+
@Override
|
|
470
|
+
public void onSuccess() {
|
|
471
|
+
promise.resolve(true);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
@Override
|
|
475
|
+
public void onFailure(@Nullable String s) {
|
|
476
|
+
promise.reject(ERROR_CODE_SET_CATEGORY_PREFERENCE, ERROR_MESSAGE_SET_CATEGORY_PREFERENCE);
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
@ReactMethod
|
|
482
|
+
public static void onNetmeraPushMessageReceived(ReadableMap map) {
|
|
483
|
+
Map<String, String> data = new HashMap<>();
|
|
484
|
+
|
|
485
|
+
Bundle bundle = new Bundle();
|
|
486
|
+
for (String key : map.toHashMap().keySet()) {
|
|
487
|
+
data.put(key, map.getString(key));
|
|
488
|
+
bundle.putString(key, map.getString(key));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
if (data.containsKey("google.c.sender.id")) {
|
|
492
|
+
Netmera.onNetmeraPushMessageReceived(new com.google.firebase.messaging.RemoteMessage(bundle));
|
|
493
|
+
} else {
|
|
494
|
+
com.huawei.hms.push.RemoteMessage.Builder builder = new com.huawei.hms.push.RemoteMessage.Builder("to");
|
|
495
|
+
builder.setData(data);
|
|
496
|
+
Netmera.onNetmeraPushMessageReceived(builder.build());
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
@ReactMethod
|
|
501
|
+
public static void onNetmeraNewToken(String pushToken) {
|
|
502
|
+
Netmera.onNetmeraNewToken(pushToken);
|
|
503
|
+
}
|
|
504
|
+
|
|
394
505
|
private boolean hasKey(Map map, String key) {
|
|
395
506
|
return map.containsKey(key) && map.get(key) != null;
|
|
396
507
|
}
|
package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraPushBroadcastReceiver.java
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
package com.netmera.reactnativesdk;
|
|
10
10
|
|
|
11
|
+
import static com.netmera.reactnativesdk.RNNetmeraPushHeadlessService.TASK_KEY;
|
|
12
|
+
import static com.netmera.reactnativesdk.RNNetmeraPushHeadlessService.TASK_MESSAGE;
|
|
13
|
+
|
|
11
14
|
import android.content.ComponentName;
|
|
12
15
|
import android.content.Context;
|
|
13
16
|
import android.content.Intent;
|
|
@@ -16,16 +19,11 @@ import android.util.Log;
|
|
|
16
19
|
|
|
17
20
|
import com.facebook.react.HeadlessJsTaskService;
|
|
18
21
|
import com.facebook.react.bridge.Arguments;
|
|
19
|
-
import com.facebook.react.bridge.ReactContext;
|
|
20
22
|
import com.facebook.react.bridge.WritableMap;
|
|
21
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
22
23
|
import com.netmera.NetmeraCarouselObject;
|
|
23
24
|
import com.netmera.NetmeraPushObject;
|
|
24
25
|
import com.netmera.callbacks.NMPushActionCallbacks;
|
|
25
26
|
|
|
26
|
-
import static com.netmera.reactnativesdk.RNNetmeraPushHeadlessService.TASK_KEY;
|
|
27
|
-
import static com.netmera.reactnativesdk.RNNetmeraPushHeadlessService.TASK_MESSAGE;
|
|
28
|
-
|
|
29
27
|
public class RNNetmeraPushBroadcastReceiver implements NMPushActionCallbacks {
|
|
30
28
|
|
|
31
29
|
@Override
|
|
@@ -57,8 +55,12 @@ public class RNNetmeraPushBroadcastReceiver implements NMPushActionCallbacks {
|
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
@Override
|
|
60
|
-
public void onCarouselObjectSelected(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject,
|
|
61
|
-
|
|
58
|
+
public void onCarouselObjectSelected(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject,
|
|
59
|
+
int selectedIndex, NetmeraCarouselObject netmeraCarouselObject) {
|
|
60
|
+
bundle.putInt("selectedIndex", selectedIndex);
|
|
61
|
+
WritableMap map = RNNetmeraUtil.mapCarouselObject(netmeraCarouselObject);
|
|
62
|
+
map.merge(mergeMap(bundle, netmeraPushObject));
|
|
63
|
+
sendEvent(context, "onCarouselObjectSelected", map);
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
private void sendEvent(Context context, String eventName, WritableMap map) {
|
|
@@ -8,14 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
package com.netmera.reactnativesdk;
|
|
10
10
|
|
|
11
|
-
import android.app.ActivityManager;
|
|
12
|
-
import android.content.Context;
|
|
13
11
|
import android.text.format.DateFormat;
|
|
14
12
|
|
|
15
13
|
import androidx.annotation.Nullable;
|
|
16
14
|
|
|
17
15
|
import com.facebook.react.bridge.Arguments;
|
|
18
|
-
import com.facebook.react.bridge.ReactContext;
|
|
19
16
|
import com.facebook.react.bridge.ReadableArray;
|
|
20
17
|
import com.facebook.react.bridge.ReadableMap;
|
|
21
18
|
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
@@ -24,9 +21,12 @@ import com.facebook.react.bridge.WritableArray;
|
|
|
24
21
|
import com.facebook.react.bridge.WritableMap;
|
|
25
22
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
26
23
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
27
|
-
import com.facebook.react.common.LifecycleState;
|
|
28
24
|
import com.google.gson.Gson;
|
|
25
|
+
import com.netmera.NetmeraCarouselObject;
|
|
29
26
|
import com.netmera.NetmeraPushObject;
|
|
27
|
+
import com.netmera.data.NMCategoryPreference;
|
|
28
|
+
import com.netmera.data.NMInboxStatus;
|
|
29
|
+
import com.netmera.data.NMInboxStatusCount;
|
|
30
30
|
|
|
31
31
|
import org.json.JSONArray;
|
|
32
32
|
import org.json.JSONException;
|
|
@@ -263,4 +263,52 @@ class RNNetmeraUtil {
|
|
|
263
263
|
|
|
264
264
|
return pushObjectMap;
|
|
265
265
|
}
|
|
266
|
+
|
|
267
|
+
public static WritableMap mapCarouselObject(NetmeraCarouselObject carouselObject) {
|
|
268
|
+
WritableMap pushObjectMap = Arguments.createMap();
|
|
269
|
+
pushObjectMap.putString("id", carouselObject.getId());
|
|
270
|
+
pushObjectMap.putString("action", new Gson().toJson(carouselObject.getAction()));
|
|
271
|
+
pushObjectMap.putString("picturePath", carouselObject.getPicturePath());
|
|
272
|
+
return pushObjectMap;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
public static NMInboxStatus getInboxStatus(int code) {
|
|
276
|
+
for (NMInboxStatus value : NMInboxStatus.values()) {
|
|
277
|
+
if (value.getCode() == code) {
|
|
278
|
+
return value;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return NMInboxStatus.STATUS_ALL;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
public static WritableMap parseInboxCountForStatusToMap(NMInboxStatusCount nmInboxStatusCount) {
|
|
285
|
+
Integer allCount = nmInboxStatusCount.getCountForStatus(NMInboxStatus.STATUS_ALL);
|
|
286
|
+
Integer deletedCount = nmInboxStatusCount.getCountForStatus(NMInboxStatus.STATUS_DELETED);
|
|
287
|
+
Integer readCount = nmInboxStatusCount.getCountForStatus(NMInboxStatus.STATUS_READ);
|
|
288
|
+
Integer unreadCount = nmInboxStatusCount.getCountForStatus(NMInboxStatus.STATUS_UNREAD);
|
|
289
|
+
|
|
290
|
+
if (allCount == null) allCount = 0;
|
|
291
|
+
if (deletedCount == null) deletedCount = 0;
|
|
292
|
+
if (readCount == null) readCount = 0;
|
|
293
|
+
if (unreadCount == null) unreadCount = 0;
|
|
294
|
+
|
|
295
|
+
WritableMap map = Arguments.createMap();
|
|
296
|
+
map.putInt(String.valueOf(NMInboxStatus.STATUS_ALL.getCode()), allCount);
|
|
297
|
+
map.putInt(String.valueOf(NMInboxStatus.STATUS_DELETED.getCode()), deletedCount);
|
|
298
|
+
map.putInt(String.valueOf(NMInboxStatus.STATUS_READ.getCode()), readCount);
|
|
299
|
+
map.putInt(String.valueOf(NMInboxStatus.STATUS_UNREAD.getCode()), unreadCount);
|
|
300
|
+
return map;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
public static WritableArray parseUserCategoryPreferenceListToMap(List<NMCategoryPreference> preferences) {
|
|
304
|
+
WritableArray pushObjectList = Arguments.createArray();
|
|
305
|
+
for (NMCategoryPreference preference : preferences) {
|
|
306
|
+
WritableMap preferenceMap = Arguments.createMap();
|
|
307
|
+
preferenceMap.putInt("categoryId", preference.getCategoryId());
|
|
308
|
+
preferenceMap.putString("categoryName", preference.getCategoryName());
|
|
309
|
+
preferenceMap.putBoolean("optInStatus", preference.getOptInStatus());
|
|
310
|
+
pushObjectList.pushMap(preferenceMap);
|
|
311
|
+
}
|
|
312
|
+
return pushObjectList;
|
|
313
|
+
}
|
|
266
314
|
}
|