react-native-netmera 1.3.4 → 1.3.5
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 +475 -17
- package/android/.gradle/4.10.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/4.10.1/fileHashes/fileHashes.lock +0 -0
- package/android/.idea/gradle.xml +1 -0
- package/android/build/.transforms/07da1e78aa5e2a23e865850e1fa31195/classes/classes.dex +0 -0
- package/android/build/.transforms/07da1e78aa5e2a23e865850e1fa31195.bin +1 -0
- package/android/build/.transforms/61070ab087fd3e8aaad4987d1cd9aeb2/classes/classes.dex +0 -0
- package/android/build/.transforms/61070ab087fd3e8aaad4987d1cd9aeb2.bin +1 -0
- package/android/build/.transforms/ae3b3ad311ea4fe5b0c3652f1d5b8a07/classes/classes.dex +0 -0
- package/android/build/.transforms/cc45f1af54894b49e3ec8f6b5a05a8d7/classes/classes.dex +0 -0
- package/android/build/.transforms/f58e3ec11746c18253c1a7a566c2609f/classes/classes.dex +0 -0
- package/android/build/.transforms/f58e3ec11746c18253c1a7a566c2609f.bin +1 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +1 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +13 -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$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraConfiguration$Builder.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$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.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/RNNetmeraUtil$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraUtil.class +0 -0
- package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +1 -1
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +1 -1
- 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 +13 -0
- package/android/build.gradle +4 -6
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmera.java +4 -8
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraCategoryObject.java +56 -0
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraConfiguration.java +128 -0
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraModule.java +146 -17
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraPushBroadcastReceiver.java +16 -38
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraUtil.java +68 -68
- package/index.js +116 -42
- package/ios/RNNetmera.h +6 -0
- package/ios/RNNetmera.m +212 -101
- package/ios/RNNetmeraCategoryObject.h +16 -0
- package/ios/RNNetmeraCategoryObject.m +59 -0
- package/ios/RNNetmeraRCTEventEmitter.h +4 -3
- package/ios/RNNetmeraRCTEventEmitter.m +9 -5
- package/ios/RNNetmeraUtils.m +45 -14
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
7 <uses-sdk
|
|
8
8
|
8 android:minSdkVersion="16"
|
|
9
9
|
8-->/Users/ensarbayhan/Projects/react-native/netmera-sdk-react-native/android/src/main/AndroidManifest.xml
|
|
10
|
-
9 android:targetSdkVersion="
|
|
10
|
+
9 android:targetSdkVersion="29" />
|
|
11
11
|
9-->/Users/ensarbayhan/Projects/react-native/netmera-sdk-react-native/android/src/main/AndroidManifest.xml
|
|
12
12
|
10
|
|
13
13
|
11 <application>
|
|
Binary file
|
|
@@ -740,6 +740,7 @@ color emui_color_gray_10
|
|
|
740
740
|
color emui_color_gray_7
|
|
741
741
|
color error_color_material_dark
|
|
742
742
|
color error_color_material_light
|
|
743
|
+
color fcm_test_color
|
|
743
744
|
color foreground_material_dark
|
|
744
745
|
color foreground_material_light
|
|
745
746
|
color highlighted_text_material_dark
|
|
@@ -1016,6 +1017,9 @@ drawable abc_textfield_search_activated_mtrl_alpha
|
|
|
1016
1017
|
drawable abc_textfield_search_default_mtrl_alpha
|
|
1017
1018
|
drawable abc_textfield_search_material
|
|
1018
1019
|
drawable abc_vector_test
|
|
1020
|
+
drawable adaptive_icon
|
|
1021
|
+
drawable adaptive_icon_background
|
|
1022
|
+
drawable adaptive_icon_foreground
|
|
1019
1023
|
drawable btn_checkbox_checked_mtrl
|
|
1020
1024
|
drawable btn_checkbox_checked_to_unchecked_mtrl_animation
|
|
1021
1025
|
drawable btn_checkbox_unchecked_mtrl
|
|
@@ -1043,11 +1047,14 @@ drawable common_google_signin_btn_text_light
|
|
|
1043
1047
|
drawable common_google_signin_btn_text_light_focused
|
|
1044
1048
|
drawable common_google_signin_btn_text_light_normal
|
|
1045
1049
|
drawable common_google_signin_btn_text_light_normal_background
|
|
1050
|
+
drawable gcm_icon
|
|
1051
|
+
drawable gcm_icon2
|
|
1046
1052
|
drawable googleg_disabled_color_18
|
|
1047
1053
|
drawable googleg_standard_color_18
|
|
1048
1054
|
drawable ic_carousel_next_icon
|
|
1049
1055
|
drawable ic_carousel_prev_icon
|
|
1050
1056
|
drawable ic_umbrella_background
|
|
1057
|
+
drawable icon_with_gradient
|
|
1051
1058
|
drawable netmera_bg_in_app_message
|
|
1052
1059
|
drawable netmera_ic_action_cancel
|
|
1053
1060
|
drawable netmera_ic_action_transparent
|
|
@@ -1162,6 +1169,7 @@ id blocking
|
|
|
1162
1169
|
id bottom
|
|
1163
1170
|
id bounce
|
|
1164
1171
|
id buttonPanel
|
|
1172
|
+
id callMeasure
|
|
1165
1173
|
id cancel_action
|
|
1166
1174
|
id cancel_bg
|
|
1167
1175
|
id cancel_imageview
|
|
@@ -1515,6 +1523,8 @@ layout select_dialog_singlechoice_material
|
|
|
1515
1523
|
layout support_simple_spinner_dropdown_item
|
|
1516
1524
|
layout upsdk_app_dl_progress_dialog
|
|
1517
1525
|
layout upsdk_ota_update_view
|
|
1526
|
+
raw gcm_bip
|
|
1527
|
+
raw keep
|
|
1518
1528
|
string abc_action_bar_home_description
|
|
1519
1529
|
string abc_action_bar_up_description
|
|
1520
1530
|
string abc_action_menu_overflow_description
|
|
@@ -1606,7 +1616,9 @@ string common_google_play_services_wear_update_text
|
|
|
1606
1616
|
string common_open_on_phone
|
|
1607
1617
|
string common_signin_button_text
|
|
1608
1618
|
string common_signin_button_text_long
|
|
1619
|
+
string fcm_2_args
|
|
1609
1620
|
string fcm_fallback_notification_channel_label
|
|
1621
|
+
string fcm_no_args
|
|
1610
1622
|
string header_description
|
|
1611
1623
|
string hms_abort
|
|
1612
1624
|
string hms_abort_message
|
|
@@ -1863,6 +1875,7 @@ style NetmeraThemeAlertDialog
|
|
|
1863
1875
|
style Netmera_Theme_Transparent
|
|
1864
1876
|
style Netmera_Theme_Transparent_Dim
|
|
1865
1877
|
style Netmera_Theme_Transparent_Dim_Dialog
|
|
1878
|
+
style Netmera_Theme_Transparent_Webview
|
|
1866
1879
|
style Platform_AppCompat
|
|
1867
1880
|
style Platform_AppCompat_Light
|
|
1868
1881
|
style Platform_ThemeOverlay_AppCompat
|
package/android/build.gradle
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
android {
|
|
4
|
-
compileSdkVersion
|
|
5
|
-
buildToolsVersion "
|
|
4
|
+
compileSdkVersion 29
|
|
5
|
+
buildToolsVersion "29.0.2"
|
|
6
6
|
|
|
7
7
|
defaultConfig {
|
|
8
8
|
minSdkVersion 16
|
|
9
|
-
targetSdkVersion
|
|
9
|
+
targetSdkVersion 29
|
|
10
10
|
versionCode 1
|
|
11
11
|
versionName "1.0"
|
|
12
12
|
}
|
|
@@ -16,8 +16,6 @@ android {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
dependencies {
|
|
19
|
-
implementation
|
|
20
|
-
implementation 'com.google.firebase:firebase-messaging'
|
|
21
|
-
implementation 'com.netmera:netmera:3.8.14'
|
|
19
|
+
implementation 'com.netmera:netmera:3.8.21'
|
|
22
20
|
implementation 'com.facebook.react:react-native:+'
|
|
23
21
|
}
|
|
@@ -4,23 +4,19 @@ import android.content.ContentValues;
|
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
|
|
6
6
|
import com.netmera.Netmera;
|
|
7
|
+
import com.netmera.NetmeraConfiguration;
|
|
7
8
|
|
|
8
9
|
public class RNNetmera {
|
|
9
10
|
|
|
10
|
-
public static void initNetmera(
|
|
11
|
-
Netmera.init(
|
|
12
|
-
setNetmeraHeaders();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
public static void initForBothProviders(Context context, String firebaseSenderId, String hmsSenderId, String apiKey) {
|
|
16
|
-
Netmera.initForBothProviders(context, firebaseSenderId, hmsSenderId, apiKey);
|
|
11
|
+
public static void initNetmera(RNNetmeraConfiguration netmeraConfiguration) {
|
|
12
|
+
Netmera.init(netmeraConfiguration.getNetmeraConfiguration());
|
|
17
13
|
setNetmeraHeaders();
|
|
18
14
|
}
|
|
19
15
|
|
|
20
16
|
static void setNetmeraHeaders() {
|
|
21
17
|
ContentValues headerValues = new ContentValues();
|
|
22
18
|
headerValues.put("X-netmera-framework", "react");
|
|
23
|
-
headerValues.put("X-netmera-frameworkV", "1.3.
|
|
19
|
+
headerValues.put("X-netmera-frameworkV", "1.3.5");
|
|
24
20
|
Netmera.setNetmeraHeaders(headerValues);
|
|
25
21
|
}
|
|
26
22
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package com.netmera.reactnativesdk;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments;
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
5
|
+
import com.facebook.react.bridge.WritableArray;
|
|
6
|
+
import com.facebook.react.bridge.WritableMap;
|
|
7
|
+
import com.google.gson.Gson;
|
|
8
|
+
import com.google.gson.JsonObject;
|
|
9
|
+
import com.netmera.NetmeraCategory;
|
|
10
|
+
import com.netmera.NetmeraCategoryFilter;
|
|
11
|
+
|
|
12
|
+
import java.util.List;
|
|
13
|
+
|
|
14
|
+
public class RNNetmeraCategoryObject {
|
|
15
|
+
|
|
16
|
+
static WritableArray mapCategoryObjects(List<NetmeraCategory> categoryObjects) {
|
|
17
|
+
WritableArray writableArray = Arguments.createArray();
|
|
18
|
+
for (NetmeraCategory category : categoryObjects) {
|
|
19
|
+
writableArray.pushMap(getCategoryObjectMap(category));
|
|
20
|
+
}
|
|
21
|
+
return writableArray;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private static WritableMap getCategoryObjectMap(NetmeraCategory category) {
|
|
25
|
+
WritableMap map = Arguments.createMap();
|
|
26
|
+
map.putString("categoryName", category.getCategoryName());
|
|
27
|
+
map.putString("categoryStatus", new Gson().toJson(category.getStatus(), JsonObject.class));
|
|
28
|
+
map.putInt("readCount", category.getReadCount());
|
|
29
|
+
map.putInt("unreadCount", category.getUnReadCount());
|
|
30
|
+
map.putInt("deletedCount", category.getDeletedCount());
|
|
31
|
+
map.putMap("lastMessage", RNNetmeraUtil.mapPushObject(category.getLastMessage()));
|
|
32
|
+
|
|
33
|
+
return map;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static NetmeraCategoryFilter getInboxObject(ReadableMap map) {
|
|
37
|
+
NetmeraCategoryFilter.Builder builder = new NetmeraCategoryFilter.Builder();
|
|
38
|
+
|
|
39
|
+
if (map.hasKey("status")) {
|
|
40
|
+
int status = map.getInt("status");
|
|
41
|
+
builder.status(status);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (map.hasKey("pageSize")) {
|
|
45
|
+
int pageSize = map.getInt("pageSize");
|
|
46
|
+
builder.pageSize(pageSize);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (map.hasKey("includeExpiredObjects")) {
|
|
50
|
+
boolean includeExpiredObjects = map.getBoolean("includeExpiredObjects");
|
|
51
|
+
builder.includeExpiredObjects(includeExpiredObjects);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return builder.build();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
package com.netmera.reactnativesdk;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import com.google.firebase.FirebaseApp;
|
|
6
|
+
import com.netmera.NetmeraConfiguration;
|
|
7
|
+
import com.netmera.callbacks.NMInAppMessageActionCallbacks;
|
|
8
|
+
import com.netmera.callbacks.NMPushActionCallbacks;
|
|
9
|
+
|
|
10
|
+
public class RNNetmeraConfiguration {
|
|
11
|
+
|
|
12
|
+
NMInAppMessageActionCallbacks nmInAppMessageActionCallbacks;
|
|
13
|
+
NMPushActionCallbacks nmPushActionCallbacks;
|
|
14
|
+
Context context;
|
|
15
|
+
String baseUrl;
|
|
16
|
+
FirebaseApp firebaseApp;
|
|
17
|
+
String huaweiSenderId;
|
|
18
|
+
String apiKey;
|
|
19
|
+
String firebaseSenderId;
|
|
20
|
+
boolean logging;
|
|
21
|
+
|
|
22
|
+
private RNNetmeraConfiguration(Builder builder) {
|
|
23
|
+
this.nmInAppMessageActionCallbacks = builder.nmInAppMessageActionCallbacks;
|
|
24
|
+
this.nmPushActionCallbacks = builder.nmPushActionCallbacks;
|
|
25
|
+
this.context = builder.context;
|
|
26
|
+
this.baseUrl = builder.baseUrl;
|
|
27
|
+
this.firebaseApp = builder.firebaseApp;
|
|
28
|
+
this.huaweiSenderId = builder.huaweiSenderId;
|
|
29
|
+
this.apiKey = builder.apiKey;
|
|
30
|
+
this.firebaseSenderId = builder.firebaseSenderId;
|
|
31
|
+
this.logging = builder.logging;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
NetmeraConfiguration getNetmeraConfiguration() {
|
|
35
|
+
NMPushActionCallbacks nmPushActionCallbacks =
|
|
36
|
+
this.nmPushActionCallbacks != null ?
|
|
37
|
+
this.nmPushActionCallbacks :
|
|
38
|
+
new RNNetmeraPushBroadcastReceiver();
|
|
39
|
+
|
|
40
|
+
NetmeraConfiguration.Builder builder = new NetmeraConfiguration.Builder();
|
|
41
|
+
|
|
42
|
+
if (firebaseSenderId != null) {
|
|
43
|
+
builder.firebaseSenderId(firebaseSenderId);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (huaweiSenderId != null) {
|
|
47
|
+
builder.huaweiSenderId(huaweiSenderId);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (apiKey != null) {
|
|
51
|
+
builder.apiKey(apiKey);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (baseUrl != null) {
|
|
55
|
+
builder.baseUrl(baseUrl);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (firebaseApp != null) {
|
|
59
|
+
builder.firebaseApp(firebaseApp);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (nmInAppMessageActionCallbacks != null) {
|
|
63
|
+
builder.nmInAppMessageActionCallbacks(nmInAppMessageActionCallbacks);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return builder.logging(logging)
|
|
67
|
+
.disableSerializeRule(true)
|
|
68
|
+
.nmPushActionCallbacks(nmPushActionCallbacks)
|
|
69
|
+
.build(context);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public static class Builder {
|
|
73
|
+
private NMInAppMessageActionCallbacks nmInAppMessageActionCallbacks;
|
|
74
|
+
private NMPushActionCallbacks nmPushActionCallbacks;
|
|
75
|
+
private Context context;
|
|
76
|
+
private String baseUrl;
|
|
77
|
+
private FirebaseApp firebaseApp;
|
|
78
|
+
private String huaweiSenderId;
|
|
79
|
+
private String apiKey;
|
|
80
|
+
private String firebaseSenderId;
|
|
81
|
+
private boolean logging;
|
|
82
|
+
|
|
83
|
+
public Builder nmInAppMessageActionCallbacks(NMInAppMessageActionCallbacks nmInAppMessageActionCallbacks) {
|
|
84
|
+
this.nmInAppMessageActionCallbacks = nmInAppMessageActionCallbacks;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public Builder nmPushActionCallbacks(NMPushActionCallbacks nmPushActionCallbacks) {
|
|
89
|
+
this.nmPushActionCallbacks = nmPushActionCallbacks;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public Builder baseUrl(String baseUrl) {
|
|
94
|
+
this.baseUrl = baseUrl;
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public Builder firebaseApp(FirebaseApp firebaseApp) {
|
|
99
|
+
this.firebaseApp = firebaseApp;
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public Builder huaweiSenderId(String huaweiSenderId) {
|
|
104
|
+
this.huaweiSenderId = huaweiSenderId;
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public Builder apiKey(String apiKey) {
|
|
109
|
+
this.apiKey = apiKey;
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public Builder firebaseSenderId(String firebaseSenderId) {
|
|
114
|
+
this.firebaseSenderId = firebaseSenderId;
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public Builder logging(boolean logging) {
|
|
119
|
+
this.logging = logging;
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public RNNetmeraConfiguration build(Context context) {
|
|
124
|
+
this.context = context;
|
|
125
|
+
return new RNNetmeraConfiguration(this);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -14,11 +14,15 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
|
14
14
|
import com.facebook.react.bridge.ReactMethod;
|
|
15
15
|
import com.facebook.react.bridge.ReadableMap;
|
|
16
16
|
import com.netmera.Netmera;
|
|
17
|
+
import com.netmera.NetmeraCategory;
|
|
17
18
|
import com.netmera.NetmeraError;
|
|
18
19
|
import com.netmera.NetmeraInbox;
|
|
20
|
+
import com.netmera.NetmeraInboxCategory;
|
|
19
21
|
import com.netmera.NetmeraInboxFilter;
|
|
22
|
+
import com.netmera.NetmeraInteractiveAction;
|
|
20
23
|
import com.netmera.NetmeraPushObject;
|
|
21
24
|
|
|
25
|
+
import java.util.ArrayList;
|
|
22
26
|
import java.util.Collections;
|
|
23
27
|
import java.util.List;
|
|
24
28
|
import java.util.Map;
|
|
@@ -38,10 +42,14 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
38
42
|
private static final String ERROR_MESSAGE_NOT_NEXT_PAGE = "Not next page";
|
|
39
43
|
private static final String ERROR_CODE_UPDATE_STATUS = "2019";
|
|
40
44
|
private static final String ERROR_MESSAGE_UPDATE_STATUS = "There was a problem updating status";
|
|
41
|
-
|
|
45
|
+
private static final String ERROR_CODE_NULL_CATEGORY = "2020";
|
|
46
|
+
private static final String ERROR_MESSAGE_NULL_CATEGORY = "Must call fetchCategory method first";
|
|
47
|
+
private static final String ERROR_CODE_INVALID_PUSH_OBJECT = "2021";
|
|
48
|
+
private static final String ERROR_MESSAGE_INVALID_PUSH_OBJECT = "Received NetmeraPushObject was not valid.";
|
|
42
49
|
|
|
43
50
|
public static ReactApplicationContext reactContext;
|
|
44
51
|
private NetmeraInbox netmeraInbox;
|
|
52
|
+
private NetmeraInboxCategory netmeraInboxCategory;
|
|
45
53
|
|
|
46
54
|
public RNNetmeraModule(ReactApplicationContext reactContext) {
|
|
47
55
|
super(reactContext);
|
|
@@ -53,11 +61,6 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
53
61
|
return "RNNetmera";
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
@ReactMethod
|
|
57
|
-
public void initNetmera(final String gcmSenderId, final String apiKey) {
|
|
58
|
-
RNNetmera.initNetmera(reactContext, gcmSenderId, apiKey);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
64
|
@ReactMethod
|
|
62
65
|
public void currentExternalId(final Promise promise) {
|
|
63
66
|
promise.resolve(Netmera.getCurrentExternalId());
|
|
@@ -201,9 +204,34 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
201
204
|
}
|
|
202
205
|
}
|
|
203
206
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
+
@ReactMethod
|
|
208
|
+
public void fetchCategory(ReadableMap readableMap, final Promise promise) {
|
|
209
|
+
Netmera.fetchCategory(RNNetmeraCategoryObject.getInboxObject(readableMap), new NetmeraInboxCategory.NetmeraInboxCategoryCallback() {
|
|
210
|
+
@Override
|
|
211
|
+
public void onFetchCategory(NetmeraInboxCategory netmeraInboxCategory, NetmeraError netmeraError) {
|
|
212
|
+
setCategory(netmeraInboxCategory, netmeraError, promise);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@ReactMethod
|
|
218
|
+
public void fetchNextCategoryPage(final Promise promise) {
|
|
219
|
+
if (netmeraInboxCategory == null) {
|
|
220
|
+
promise.reject(ERROR_CODE_NULL_CATEGORY, ERROR_MESSAGE_NULL_CATEGORY);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (netmeraInboxCategory.hasNextPage()) {
|
|
225
|
+
netmeraInboxCategory.fetchNextPage(new NetmeraInboxCategory.NetmeraInboxCategoryCallback() {
|
|
226
|
+
@Override
|
|
227
|
+
public void onFetchCategory(NetmeraInboxCategory netmeraInboxCategory, NetmeraError netmeraError) {
|
|
228
|
+
setCategory(netmeraInboxCategory, netmeraError, promise);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
} else {
|
|
232
|
+
promise.reject(ERROR_CODE_NOT_NEXT_PAGE, ERROR_MESSAGE_NOT_NEXT_PAGE);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
207
235
|
|
|
208
236
|
@ReactMethod
|
|
209
237
|
public void sendEvent(ReadableMap readableMap) {
|
|
@@ -244,14 +272,106 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
244
272
|
Netmera.updateUser(netmeraUser);
|
|
245
273
|
}
|
|
246
274
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
275
|
+
@ReactMethod
|
|
276
|
+
public void handlePushObject(String pushId) {
|
|
277
|
+
if (netmeraInbox == null) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
for (NetmeraPushObject pushObject : netmeraInbox.pushObjects()) {
|
|
282
|
+
if (pushObject.getPushId().equals(pushId)) {
|
|
283
|
+
Netmera.handlePushObject(reactContext.getCurrentActivity(), pushObject);
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
@ReactMethod
|
|
290
|
+
public void handleInteractiveAction(String interactiveActionId) {
|
|
291
|
+
if (netmeraInbox == null) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
for (NetmeraPushObject pushObject : netmeraInbox.pushObjects()) {
|
|
296
|
+
if (pushObject.getInteractiveActions() != null) {
|
|
297
|
+
for (NetmeraInteractiveAction action : pushObject.getInteractiveActions()) {
|
|
298
|
+
if (action.getId().equals(interactiveActionId)) {
|
|
299
|
+
Netmera.handleInteractiveAction(reactContext, action);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
@ReactMethod
|
|
308
|
+
public void setApiKey(String apiKey) {
|
|
309
|
+
Netmera.setApiKey(apiKey);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
@ReactMethod
|
|
314
|
+
public void handleLastMessage(String categoryName, final Promise promise) {
|
|
315
|
+
if (netmeraInboxCategory == null) {
|
|
316
|
+
promise.reject(ERROR_CODE_NULL_CATEGORY, ERROR_MESSAGE_NULL_CATEGORY);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (categoryName == null || categoryName.isEmpty()) {
|
|
321
|
+
promise.reject(ERROR_CODE_INVALID_PUSH_OBJECT, ERROR_MESSAGE_INVALID_PUSH_OBJECT);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
for (NetmeraCategory category : netmeraInboxCategory.categories()) {
|
|
326
|
+
if (categoryName.equals(category.getCategoryName())) {
|
|
327
|
+
Netmera.handlePushObject(reactContext.getCurrentActivity(), category.getLastMessage());
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
@ReactMethod
|
|
334
|
+
public void updateStatusByCategories(final int fromIndex, final int toIndex, final int status, final Promise promise) {
|
|
335
|
+
if (netmeraInboxCategory == null) {
|
|
336
|
+
promise.reject(ERROR_CODE_NULL_CATEGORY, ERROR_MESSAGE_NULL_CATEGORY);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
try {
|
|
341
|
+
List<String> categoryNames = new ArrayList<>();
|
|
342
|
+
|
|
343
|
+
for (NetmeraCategory category : netmeraInboxCategory.categories().subList(fromIndex, toIndex)) {
|
|
344
|
+
categoryNames.add(category.getCategoryName());
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
Netmera.updateStatusByCategories(status, categoryNames, new NetmeraInbox.NetmeraInboxStatusCallback() {
|
|
348
|
+
@Override
|
|
349
|
+
public void onSetStatusInbox(NetmeraError netmeraError) {
|
|
350
|
+
if (netmeraError == null) {
|
|
351
|
+
promise.resolve(null);
|
|
352
|
+
} else {
|
|
353
|
+
promise.reject(ERROR_CODE_UPDATE_STATUS, ERROR_MESSAGE_UPDATE_STATUS);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
} catch (IndexOutOfBoundsException e) {
|
|
358
|
+
promise.reject("", e.getMessage());
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
@ReactMethod
|
|
363
|
+
public void updateAll(int inboxStatus, final Promise promise) {
|
|
364
|
+
Netmera.updateAll(inboxStatus, new NetmeraInbox.NetmeraInboxStatusCallback() {
|
|
365
|
+
@Override
|
|
366
|
+
public void onSetStatusInbox(NetmeraError netmeraError) {
|
|
367
|
+
if (netmeraError != null) {
|
|
368
|
+
promise.reject(ERROR_CODE_UPDATE_STATUS, ERROR_MESSAGE_UPDATE_STATUS);
|
|
369
|
+
} else {
|
|
370
|
+
promise.resolve(true);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
255
375
|
|
|
256
376
|
private void setInbox(NetmeraInbox inbox, NetmeraError netmeraError, Promise promise) {
|
|
257
377
|
netmeraInbox = inbox;
|
|
@@ -262,6 +382,15 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
262
382
|
promise.resolve(RNNetmeraUtil.mapPushObjects(inbox.pushObjects()));
|
|
263
383
|
}
|
|
264
384
|
|
|
385
|
+
private void setCategory(NetmeraInboxCategory nmInboxCategory, NetmeraError netmeraError, Promise promise) {
|
|
386
|
+
if (netmeraError != null) {
|
|
387
|
+
promise.reject(ERROR_CODE_NULL_INBOX, ERROR_MESSAGE_NULL_INBOX);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
netmeraInboxCategory = nmInboxCategory;
|
|
391
|
+
promise.resolve(RNNetmeraCategoryObject.mapCategoryObjects(netmeraInboxCategory.categories()));
|
|
392
|
+
}
|
|
393
|
+
|
|
265
394
|
private boolean hasKey(Map map, String key) {
|
|
266
395
|
return map.containsKey(key) && map.get(key) != null;
|
|
267
396
|
}
|
package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraPushBroadcastReceiver.java
CHANGED
|
@@ -19,16 +19,16 @@ import com.facebook.react.bridge.Arguments;
|
|
|
19
19
|
import com.facebook.react.bridge.ReactContext;
|
|
20
20
|
import com.facebook.react.bridge.WritableMap;
|
|
21
21
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
22
|
-
import com.netmera.NetmeraPushBroadcastReceiver;
|
|
23
22
|
import com.netmera.NetmeraPushObject;
|
|
23
|
+
import com.netmera.callbacks.NMPushActionCallbacks;
|
|
24
24
|
|
|
25
25
|
import static com.netmera.reactnativesdk.RNNetmeraPushHeadlessService.TASK_KEY;
|
|
26
26
|
import static com.netmera.reactnativesdk.RNNetmeraPushHeadlessService.TASK_MESSAGE;
|
|
27
27
|
|
|
28
|
-
public class RNNetmeraPushBroadcastReceiver
|
|
28
|
+
public class RNNetmeraPushBroadcastReceiver implements NMPushActionCallbacks {
|
|
29
29
|
|
|
30
30
|
@Override
|
|
31
|
-
|
|
31
|
+
public void onPushRegister(Context context, String gcmSenderId, String pushToken) {
|
|
32
32
|
Bundle bundle = new Bundle();
|
|
33
33
|
bundle.putString("gcmSenderId", gcmSenderId);
|
|
34
34
|
bundle.putString("pushToken", pushToken);
|
|
@@ -36,52 +36,26 @@ public class RNNetmeraPushBroadcastReceiver extends NetmeraPushBroadcastReceiver
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
@Override
|
|
39
|
-
|
|
39
|
+
public void onPushReceive(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject) {
|
|
40
40
|
sendEvent(context, "onPushReceive", mergeMap(bundle, netmeraPushObject));
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
@Override
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
sendBackgroundEvent(context, "onPushOpen", mergeMap(bundle, netmeraPushObject));
|
|
44
|
+
public void onPushOpen(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject) {
|
|
45
|
+
sendEvent(context, "onPushOpen", mergeMap(bundle, netmeraPushObject));
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
@Override
|
|
50
|
-
|
|
49
|
+
public void onPushDismiss(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject) {
|
|
51
50
|
sendEvent(context, "onPushDismiss", mergeMap(bundle, netmeraPushObject));
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
@Override
|
|
55
|
-
|
|
54
|
+
public void onPushButtonClicked(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject) {
|
|
56
55
|
sendEvent(context, "onPushButtonClicked", mergeMap(bundle, netmeraPushObject));
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
private void sendEvent(Context context, String eventName, WritableMap map) {
|
|
60
|
-
if (RNNetmeraUtil.isAppInForeground(context)) {
|
|
61
|
-
sendForegroundEvent(eventName, map);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
sendBackgroundEvent(context, eventName, map);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private WritableMap mergeMap(Bundle bundle, NetmeraPushObject netmeraPushObject) {
|
|
68
|
-
WritableMap mapPushObject = RNNetmeraUtil.mapPushObject(netmeraPushObject);
|
|
69
|
-
WritableMap mapBundle = bundle != null ? Arguments.fromBundle(bundle) : null;
|
|
70
|
-
mapPushObject.merge(mapBundle);
|
|
71
|
-
return mapPushObject;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
private void sendForegroundEvent(String eventName, WritableMap map) {
|
|
75
|
-
try {
|
|
76
|
-
ReactContext reactContext = RNNetmeraModule.reactContext;
|
|
77
|
-
reactContext
|
|
78
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
79
|
-
.emit(eventName, map);
|
|
80
|
-
} catch (Exception e) {
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
private void sendBackgroundEvent(Context context, String eventName, WritableMap map) {
|
|
85
59
|
try {
|
|
86
60
|
Intent backgroundIntent = new Intent(context, RNNetmeraPushHeadlessService.class);
|
|
87
61
|
backgroundIntent.putExtra(TASK_KEY, eventName);
|
|
@@ -91,10 +65,14 @@ public class RNNetmeraPushBroadcastReceiver extends NetmeraPushBroadcastReceiver
|
|
|
91
65
|
HeadlessJsTaskService.acquireWakeLockNow(context);
|
|
92
66
|
}
|
|
93
67
|
} catch (IllegalStateException ex) {
|
|
94
|
-
Log.d(
|
|
95
|
-
"RNNetmera Background",
|
|
96
|
-
"RNNetmera Background Event Exception"
|
|
97
|
-
);
|
|
68
|
+
Log.d("RNNetmera Background", "RNNetmera Background Event Exception");
|
|
98
69
|
}
|
|
99
70
|
}
|
|
71
|
+
|
|
72
|
+
private WritableMap mergeMap(Bundle bundle, NetmeraPushObject netmeraPushObject) {
|
|
73
|
+
WritableMap mapPushObject = RNNetmeraUtil.mapPushObject(netmeraPushObject);
|
|
74
|
+
WritableMap mapBundle = bundle != null ? Arguments.fromBundle(bundle) : null;
|
|
75
|
+
mapPushObject.merge(mapBundle);
|
|
76
|
+
return mapPushObject;
|
|
77
|
+
}
|
|
100
78
|
}
|