react-native-netmera 1.3.4 → 1.3.8
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 +473 -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/00a1a2a97b81c133eb73f4c946b323aa/classes/classes.dex +0 -0
- package/android/build/.transforms/{1cc655d17744898d5287444bc3b54ccd.bin → 00a1a2a97b81c133eb73f4c946b323aa.bin} +0 -0
- package/android/build/.transforms/8b103fc7545c9799a16ff009dc2ead52/classes/classes.dex +0 -0
- package/android/build/.transforms/{1d7e2a596c5a01e1599ed8d99d8fed25.bin → 8b103fc7545c9799a16ff009dc2ead52.bin} +0 -0
- package/android/build/.transforms/9e086edd0cadc1c3e325107cef1d09ca/classes/classes.dex +0 -0
- package/android/build/.transforms/{6bd284ae922673d08694a1221c01809c.bin → 9e086edd0cadc1c3e325107cef1d09ca.bin} +0 -0
- package/android/build/.transforms/b0d220ccd1945e73ed321c4b96bb37de/classes/classes.dex +0 -0
- package/android/build/.transforms/{a8f21d984467d686c5d11cdc3f508ab2.bin → b0d220ccd1945e73ed321c4b96bb37de.bin} +0 -0
- package/android/build/.transforms/f70db9a523a6c7b9af14929671f6c09b/classes/classes.dex +0 -0
- package/android/build/.transforms/{ae3b3ad311ea4fe5b0c3652f1d5b8a07.bin → f70db9a523a6c7b9af14929671f6c09b.bin} +0 -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 +3626 -383
- package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +1 -1
- 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 +2726 -11
- package/android/build.gradle +6 -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 +116 -0
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraModule.java +146 -17
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraPushBroadcastReceiver.java +21 -37
- 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/RNNetmeraEvent.m +5 -1
- package/ios/RNNetmeraRCTEventEmitter.h +4 -3
- package/ios/RNNetmeraRCTEventEmitter.m +9 -5
- package/ios/RNNetmeraUtils.m +45 -14
- package/package.json +1 -1
- package/android/build/.transforms/1cc655d17744898d5287444bc3b54ccd/classes/classes.dex +0 -0
- package/android/build/.transforms/1d7e2a596c5a01e1599ed8d99d8fed25/classes/classes.dex +0 -0
- package/android/build/.transforms/6bd284ae922673d08694a1221c01809c/classes/classes.dex +0 -0
- package/android/build/.transforms/a8f21d984467d686c5d11cdc3f508ab2/classes/classes.dex +0 -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/cc45f1af54894b49e3ec8f6b5a05a8d7.bin +0 -1
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 32
|
|
5
|
+
buildToolsVersion "29.0.2"
|
|
6
6
|
|
|
7
7
|
defaultConfig {
|
|
8
8
|
minSdkVersion 16
|
|
9
|
-
targetSdkVersion
|
|
9
|
+
targetSdkVersion 32
|
|
10
10
|
versionCode 1
|
|
11
11
|
versionName "1.0"
|
|
12
12
|
}
|
|
@@ -16,8 +16,8 @@ android {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
dependencies {
|
|
19
|
-
implementation
|
|
20
|
-
implementation 'com.
|
|
21
|
-
implementation 'com.netmera:
|
|
19
|
+
implementation 'com.netmera:nmcore:3.9.1'
|
|
20
|
+
implementation 'com.netmera:nmfcm:3.9.0'
|
|
21
|
+
implementation 'com.netmera:nmhms:3.9.1'
|
|
22
22
|
implementation 'com.facebook.react:react-native:+'
|
|
23
23
|
}
|
|
@@ -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.8");
|
|
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,116 @@
|
|
|
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
|
+
String huaweiSenderId;
|
|
17
|
+
String apiKey;
|
|
18
|
+
String firebaseSenderId;
|
|
19
|
+
boolean logging;
|
|
20
|
+
|
|
21
|
+
private RNNetmeraConfiguration(Builder builder) {
|
|
22
|
+
this.nmInAppMessageActionCallbacks = builder.nmInAppMessageActionCallbacks;
|
|
23
|
+
this.nmPushActionCallbacks = builder.nmPushActionCallbacks;
|
|
24
|
+
this.context = builder.context;
|
|
25
|
+
this.baseUrl = builder.baseUrl;
|
|
26
|
+
this.huaweiSenderId = builder.huaweiSenderId;
|
|
27
|
+
this.apiKey = builder.apiKey;
|
|
28
|
+
this.firebaseSenderId = builder.firebaseSenderId;
|
|
29
|
+
this.logging = builder.logging;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
NetmeraConfiguration getNetmeraConfiguration() {
|
|
33
|
+
NMPushActionCallbacks nmPushActionCallbacks =
|
|
34
|
+
this.nmPushActionCallbacks != null ?
|
|
35
|
+
this.nmPushActionCallbacks :
|
|
36
|
+
new RNNetmeraPushBroadcastReceiver();
|
|
37
|
+
|
|
38
|
+
NetmeraConfiguration.Builder builder = new NetmeraConfiguration.Builder();
|
|
39
|
+
|
|
40
|
+
if (firebaseSenderId != null) {
|
|
41
|
+
builder.firebaseSenderId(firebaseSenderId);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (huaweiSenderId != null) {
|
|
45
|
+
builder.huaweiSenderId(huaweiSenderId);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (apiKey != null) {
|
|
49
|
+
builder.apiKey(apiKey);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (baseUrl != null) {
|
|
53
|
+
builder.baseUrl(baseUrl);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (nmInAppMessageActionCallbacks != null) {
|
|
57
|
+
builder.nmInAppMessageActionCallbacks(nmInAppMessageActionCallbacks);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return builder.logging(logging)
|
|
61
|
+
.disableSerializeRule(true)
|
|
62
|
+
.nmPushActionCallbacks(nmPushActionCallbacks)
|
|
63
|
+
.build(context);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public static class Builder {
|
|
67
|
+
private NMInAppMessageActionCallbacks nmInAppMessageActionCallbacks;
|
|
68
|
+
private NMPushActionCallbacks nmPushActionCallbacks;
|
|
69
|
+
private Context context;
|
|
70
|
+
private String baseUrl;
|
|
71
|
+
private String huaweiSenderId;
|
|
72
|
+
private String apiKey;
|
|
73
|
+
private String firebaseSenderId;
|
|
74
|
+
private boolean logging;
|
|
75
|
+
|
|
76
|
+
public Builder nmInAppMessageActionCallbacks(NMInAppMessageActionCallbacks nmInAppMessageActionCallbacks) {
|
|
77
|
+
this.nmInAppMessageActionCallbacks = nmInAppMessageActionCallbacks;
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public Builder nmPushActionCallbacks(NMPushActionCallbacks nmPushActionCallbacks) {
|
|
82
|
+
this.nmPushActionCallbacks = nmPushActionCallbacks;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public Builder baseUrl(String baseUrl) {
|
|
87
|
+
this.baseUrl = baseUrl;
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public Builder huaweiSenderId(String huaweiSenderId) {
|
|
92
|
+
this.huaweiSenderId = huaweiSenderId;
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public Builder apiKey(String apiKey) {
|
|
97
|
+
this.apiKey = apiKey;
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public Builder firebaseSenderId(String firebaseSenderId) {
|
|
102
|
+
this.firebaseSenderId = firebaseSenderId;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public Builder logging(boolean logging) {
|
|
107
|
+
this.logging = logging;
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public RNNetmeraConfiguration build(Context context) {
|
|
112
|
+
this.context = context;
|
|
113
|
+
return new RNNetmeraConfiguration(this);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -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,17 @@ 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.
|
|
22
|
+
import com.netmera.NetmeraCarouselObject;
|
|
23
23
|
import com.netmera.NetmeraPushObject;
|
|
24
|
+
import com.netmera.callbacks.NMPushActionCallbacks;
|
|
24
25
|
|
|
25
26
|
import static com.netmera.reactnativesdk.RNNetmeraPushHeadlessService.TASK_KEY;
|
|
26
27
|
import static com.netmera.reactnativesdk.RNNetmeraPushHeadlessService.TASK_MESSAGE;
|
|
27
28
|
|
|
28
|
-
public class RNNetmeraPushBroadcastReceiver
|
|
29
|
+
public class RNNetmeraPushBroadcastReceiver implements NMPushActionCallbacks {
|
|
29
30
|
|
|
30
31
|
@Override
|
|
31
|
-
|
|
32
|
+
public void onPushRegister(Context context, String gcmSenderId, String pushToken) {
|
|
32
33
|
Bundle bundle = new Bundle();
|
|
33
34
|
bundle.putString("gcmSenderId", gcmSenderId);
|
|
34
35
|
bundle.putString("pushToken", pushToken);
|
|
@@ -36,52 +37,31 @@ public class RNNetmeraPushBroadcastReceiver extends NetmeraPushBroadcastReceiver
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
@Override
|
|
39
|
-
|
|
40
|
+
public void onPushReceive(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject) {
|
|
40
41
|
sendEvent(context, "onPushReceive", mergeMap(bundle, netmeraPushObject));
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
@Override
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
sendBackgroundEvent(context, "onPushOpen", mergeMap(bundle, netmeraPushObject));
|
|
45
|
+
public void onPushOpen(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject) {
|
|
46
|
+
sendEvent(context, "onPushOpen", mergeMap(bundle, netmeraPushObject));
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
@Override
|
|
50
|
-
|
|
50
|
+
public void onPushDismiss(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject) {
|
|
51
51
|
sendEvent(context, "onPushDismiss", mergeMap(bundle, netmeraPushObject));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
@Override
|
|
55
|
-
|
|
55
|
+
public void onPushButtonClicked(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject) {
|
|
56
56
|
sendEvent(context, "onPushButtonClicked", mergeMap(bundle, netmeraPushObject));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
}
|
|
59
|
+
@Override
|
|
60
|
+
public void onCarouselObjectSelected(Context context, Bundle bundle, NetmeraPushObject netmeraPushObject, int i, NetmeraCarouselObject netmeraCarouselObject) {
|
|
61
|
+
// TODO send event to RN side in here.
|
|
82
62
|
}
|
|
83
63
|
|
|
84
|
-
private void
|
|
64
|
+
private void sendEvent(Context context, String eventName, WritableMap map) {
|
|
85
65
|
try {
|
|
86
66
|
Intent backgroundIntent = new Intent(context, RNNetmeraPushHeadlessService.class);
|
|
87
67
|
backgroundIntent.putExtra(TASK_KEY, eventName);
|
|
@@ -91,10 +71,14 @@ public class RNNetmeraPushBroadcastReceiver extends NetmeraPushBroadcastReceiver
|
|
|
91
71
|
HeadlessJsTaskService.acquireWakeLockNow(context);
|
|
92
72
|
}
|
|
93
73
|
} catch (IllegalStateException ex) {
|
|
94
|
-
Log.d(
|
|
95
|
-
"RNNetmera Background",
|
|
96
|
-
"RNNetmera Background Event Exception"
|
|
97
|
-
);
|
|
74
|
+
Log.d("RNNetmera Background", "RNNetmera Background Event Exception");
|
|
98
75
|
}
|
|
99
76
|
}
|
|
77
|
+
|
|
78
|
+
private WritableMap mergeMap(Bundle bundle, NetmeraPushObject netmeraPushObject) {
|
|
79
|
+
WritableMap mapPushObject = RNNetmeraUtil.mapPushObject(netmeraPushObject);
|
|
80
|
+
WritableMap mapBundle = bundle != null ? Arguments.fromBundle(bundle) : null;
|
|
81
|
+
mapPushObject.merge(mapBundle);
|
|
82
|
+
return mapPushObject;
|
|
83
|
+
}
|
|
100
84
|
}
|