reactnative-plugin-appice 1.6.3 → 1.6.4
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/android/build.gradle +1 -1
- package/android/src/main/java/com/reactlibrary/AppICEUtils.java +213 -0
- package/android/src/main/java/com/reactlibrary/AppIceReactPluginModule.java +185 -190
- package/android/src/main/java/com/reactlibrary/CampaignCampsReceiver.java +6 -11
- package/android/src/main/java/com/reactlibrary/Constants.java +42 -0
- package/example/App.js +76 -0
- package/example/package.json +1 -1
- package/index.js +98 -10
- package/ios/AppIceReactPlugin.h +11 -0
- package/ios/AppIceReactPlugin.m +147 -1
- package/ios/AppIceReactPlugin.xcodeproj/xcuserdata/artherajesh.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/AppIceReactPlugin.xcworkspace/xcuserdata/artherajesh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/artherajesh.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/package.json +1 -1
- package/android/src/main/java/com/reactlibrary/ClickCallback.java +0 -5
- package/android/src/main/java/com/reactlibrary/InAppWebView.java +0 -68
package/android/build.gradle
CHANGED
|
@@ -114,7 +114,7 @@ dependencies {
|
|
|
114
114
|
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.3.1"
|
|
115
115
|
|
|
116
116
|
//appice
|
|
117
|
-
implementation 'appice.io.android:sdk:2.5.
|
|
117
|
+
implementation 'appice.io.android:sdk:2.5.62'
|
|
118
118
|
|
|
119
119
|
//glide
|
|
120
120
|
implementation "com.github.bumptech.glide:glide:4.11.0"
|
|
@@ -3,13 +3,24 @@ package com.reactlibrary;
|
|
|
3
3
|
import android.util.Log;
|
|
4
4
|
|
|
5
5
|
import com.facebook.react.bridge.Arguments;
|
|
6
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
8
|
+
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
9
|
+
import com.facebook.react.bridge.ReadableType;
|
|
10
|
+
import com.facebook.react.bridge.WritableArray;
|
|
6
11
|
import com.facebook.react.bridge.WritableMap;
|
|
7
12
|
|
|
13
|
+
import org.json.JSONArray;
|
|
14
|
+
import org.json.JSONException;
|
|
8
15
|
import org.json.JSONObject;
|
|
9
16
|
|
|
17
|
+
import java.util.ArrayList;
|
|
18
|
+
import java.util.HashMap;
|
|
10
19
|
import java.util.Iterator;
|
|
11
20
|
import java.util.Map;
|
|
12
21
|
|
|
22
|
+
import semusi.context.ui.appInbox.AppICEInboxMessage;
|
|
23
|
+
|
|
13
24
|
public class AppICEUtils {
|
|
14
25
|
private static final String TAG = "AppICEUtils";
|
|
15
26
|
|
|
@@ -35,4 +46,206 @@ public class AppICEUtils {
|
|
|
35
46
|
return extrasParams;
|
|
36
47
|
}
|
|
37
48
|
|
|
49
|
+
public static WritableMap convertClassToWritableMap(AppICEInboxMessage inboxMessage){
|
|
50
|
+
WritableMap inboxObject = Arguments.createMap();
|
|
51
|
+
try {
|
|
52
|
+
if (inboxMessage != null) {
|
|
53
|
+
inboxObject.putString(Constants.INBOX_MESSAGE_ID, inboxMessage.getMessageId());
|
|
54
|
+
inboxObject.putString(Constants.INBOX_CAMPAIGN_ID, inboxMessage.getCampId());
|
|
55
|
+
inboxObject.putString(Constants.INBOX_CAMPAIGN_TYPE, inboxMessage.getMessageCampType());
|
|
56
|
+
inboxObject.putString(Constants.INBOX_MESSAGE_CATEGORY, inboxMessage.getCategory());
|
|
57
|
+
inboxObject.putString(Constants.INBOX_MESSAGE_STATUS, inboxMessage.getMessageStatus());
|
|
58
|
+
inboxObject.putString(Constants.INBOX_MESSAGE_LANGUAGE, inboxMessage.getMessageLanguage());
|
|
59
|
+
inboxObject.putString(Constants.INBOX_TITLE, inboxMessage.getMessageTitle());
|
|
60
|
+
inboxObject.putString(Constants.INBOX_MESSAGE, inboxMessage.getMessageBody());
|
|
61
|
+
inboxObject.putString(Constants.INBOX_MESSAGE_ICON, inboxMessage.getMessageIcon());
|
|
62
|
+
inboxObject.putMap(Constants.INBOX_CUSTOM_DATA, toWritableMap(inboxMessage.getCustomData()));
|
|
63
|
+
}
|
|
64
|
+
}catch (Throwable throwable){}
|
|
65
|
+
return inboxObject;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
public static WritableMap toWritableMap(Map<String, Object> map) {
|
|
70
|
+
WritableMap writableMap = Arguments.createMap();
|
|
71
|
+
Iterator iterator = map.entrySet().iterator();
|
|
72
|
+
|
|
73
|
+
while (iterator.hasNext()) {
|
|
74
|
+
Map.Entry pair = (Map.Entry) iterator.next();
|
|
75
|
+
writableMap.merge(addValue((String) pair.getKey(), pair.getValue()));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return writableMap;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public static WritableMap addValue(String key, Object value) {
|
|
82
|
+
WritableMap writableMap = Arguments.createMap();
|
|
83
|
+
if (value == null) {
|
|
84
|
+
writableMap.putNull(key);
|
|
85
|
+
} else if (value instanceof Boolean) {
|
|
86
|
+
writableMap.putBoolean(key, (Boolean) value);
|
|
87
|
+
} else if (value instanceof Double) {
|
|
88
|
+
writableMap.putDouble(key, (Double) value);
|
|
89
|
+
} else if (value instanceof Integer) {
|
|
90
|
+
writableMap.putInt(key, (Integer) value);
|
|
91
|
+
} else if (value instanceof String) {
|
|
92
|
+
writableMap.putString(key, (String) value);
|
|
93
|
+
} else if (value instanceof Map) {
|
|
94
|
+
writableMap.putMap(key, toWritableMap((Map<String, Object>) value));
|
|
95
|
+
} else if (value.getClass() != null && (value.getClass().isArray() || value instanceof ArrayList)) {
|
|
96
|
+
writableMap.putArray(key, toWritableArray((ArrayList) value));
|
|
97
|
+
}
|
|
98
|
+
return writableMap;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public static WritableArray toWritableArray(ArrayList arrayList) {
|
|
102
|
+
WritableArray writableArray = Arguments.createArray();
|
|
103
|
+
|
|
104
|
+
for (int i = 0; i < arrayList.size(); i++) {
|
|
105
|
+
Object value = arrayList.get(i);
|
|
106
|
+
|
|
107
|
+
if (value == null) {
|
|
108
|
+
writableArray.pushNull();
|
|
109
|
+
}
|
|
110
|
+
if (value instanceof Boolean) {
|
|
111
|
+
writableArray.pushBoolean((Boolean) value);
|
|
112
|
+
}
|
|
113
|
+
if (value instanceof Double) {
|
|
114
|
+
writableArray.pushDouble((Double) value);
|
|
115
|
+
}
|
|
116
|
+
if (value instanceof Integer) {
|
|
117
|
+
writableArray.pushInt((Integer) value);
|
|
118
|
+
}
|
|
119
|
+
if (value instanceof String) {
|
|
120
|
+
writableArray.pushString((String) value);
|
|
121
|
+
}
|
|
122
|
+
if (value instanceof Map) {
|
|
123
|
+
writableArray.pushMap(toWritableMap((Map<String, Object>) value));
|
|
124
|
+
}
|
|
125
|
+
if (value.getClass().isArray()) {
|
|
126
|
+
writableArray.pushArray(toWritableArray((ArrayList) value));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return writableArray;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
public static ArrayList<String> arrayListStringFromReadableArray(ReadableArray readableArray) {
|
|
135
|
+
ArrayList<String> array = new ArrayList<>();
|
|
136
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
137
|
+
switch (readableArray.getType(i)) {
|
|
138
|
+
case Null:
|
|
139
|
+
break;
|
|
140
|
+
case Boolean:
|
|
141
|
+
array.add(String.valueOf(readableArray.getBoolean(i)));
|
|
142
|
+
break;
|
|
143
|
+
case Number:
|
|
144
|
+
array.add(String.valueOf(readableArray.getDouble(i)));
|
|
145
|
+
break;
|
|
146
|
+
case String:
|
|
147
|
+
array.add(readableArray.getString(i));
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return array;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public static JSONArray jsonArrayFromReadableArray(ReadableArray readableArray) throws JSONException {
|
|
155
|
+
JSONArray array = new JSONArray();
|
|
156
|
+
for (int i = 0; i < readableArray.size(); i++) {
|
|
157
|
+
switch (readableArray.getType(i)) {
|
|
158
|
+
case Null:
|
|
159
|
+
break;
|
|
160
|
+
case Boolean:
|
|
161
|
+
array.put(readableArray.getBoolean(i));
|
|
162
|
+
break;
|
|
163
|
+
case Number:
|
|
164
|
+
array.put(readableArray.getDouble(i));
|
|
165
|
+
break;
|
|
166
|
+
case String:
|
|
167
|
+
array.put(readableArray.getString(i));
|
|
168
|
+
break;
|
|
169
|
+
case Map:
|
|
170
|
+
array.put(jsonObjectFromReadableMap(readableArray.getMap(i)));
|
|
171
|
+
break;
|
|
172
|
+
case Array:
|
|
173
|
+
array.put(jsonArrayFromReadableArray(readableArray.getArray(i)));
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return array;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public static JSONObject jsonObjectFromReadableMap(ReadableMap readableMap) throws JSONException {
|
|
181
|
+
JSONObject object = new JSONObject();
|
|
182
|
+
ReadableMapKeySetIterator iterator = readableMap.keySetIterator();
|
|
183
|
+
while (iterator.hasNextKey()) {
|
|
184
|
+
String key = iterator.nextKey();
|
|
185
|
+
switch (readableMap.getType(key)) {
|
|
186
|
+
case Null:
|
|
187
|
+
object.put(key, JSONObject.NULL);
|
|
188
|
+
break;
|
|
189
|
+
case Boolean:
|
|
190
|
+
object.put(key, readableMap.getBoolean(key));
|
|
191
|
+
break;
|
|
192
|
+
case Number:
|
|
193
|
+
object.put(key, readableMap.getDouble(key));
|
|
194
|
+
break;
|
|
195
|
+
case String:
|
|
196
|
+
object.put(key, readableMap.getString(key));
|
|
197
|
+
break;
|
|
198
|
+
case Map:
|
|
199
|
+
object.put(key, jsonObjectFromReadableMap(readableMap.getMap(key)));
|
|
200
|
+
break;
|
|
201
|
+
case Array:
|
|
202
|
+
object.put(key, jsonArrayFromReadableArray(readableMap.getArray(key)));
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return object;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @param propsMap took data from js and iterate it and store in hashmap
|
|
211
|
+
* @return map of the props data
|
|
212
|
+
*/
|
|
213
|
+
public static HashMap<String, Object> eventPropsFromReadableMap(ReadableMap propsMap) {
|
|
214
|
+
if (propsMap == null) return null;
|
|
215
|
+
|
|
216
|
+
HashMap<String, Object> props = new HashMap<>();
|
|
217
|
+
ReadableMapKeySetIterator iterator = propsMap.keySetIterator();
|
|
218
|
+
|
|
219
|
+
while (iterator.hasNextKey()) {
|
|
220
|
+
try {
|
|
221
|
+
String key = iterator.nextKey();
|
|
222
|
+
ReadableType readableType = propsMap.getType(key);
|
|
223
|
+
|
|
224
|
+
if (readableType == ReadableType.String) {
|
|
225
|
+
props.put(key, propsMap.getString(key));
|
|
226
|
+
} else if (readableType == ReadableType.Boolean) {
|
|
227
|
+
props.put(key, propsMap.getBoolean(key));
|
|
228
|
+
} else if (readableType == ReadableType.Number) {
|
|
229
|
+
try {
|
|
230
|
+
props.put(key, propsMap.getDouble(key));
|
|
231
|
+
} catch (Throwable t) {
|
|
232
|
+
try {
|
|
233
|
+
props.put(key, propsMap.getInt(key));
|
|
234
|
+
} catch (Throwable t1) {
|
|
235
|
+
Log.d(TAG, "Unhandled ReadableType.Number from ReadableMap");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
} else {
|
|
239
|
+
Log.d(TAG, "Unhandled event property ReadableType");
|
|
240
|
+
}
|
|
241
|
+
} catch (Throwable t) {
|
|
242
|
+
Log.d(TAG, t.getLocalizedMessage());
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return props;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
public static void printLog(String TAG, String message){
|
|
249
|
+
System.out.println(TAG+", "+message);
|
|
250
|
+
}
|
|
38
251
|
}
|