reactnative-plugin-appice 1.6.4 → 1.6.6
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 +3 -3
- package/android/src/main/AndroidManifest.xml +47 -127
- package/android/src/main/java/com/reactlibrary/AppICEUtils.java +15 -98
- package/android/src/main/java/com/reactlibrary/AppIceReactPluginModule.java +190 -118
- package/android/src/main/java/com/reactlibrary/CampaignCampsReceiver.java +4 -16
- package/android/src/main/java/com/reactlibrary/EnumConstants.java +251 -0
- package/android/src/main/java/com/reactlibrary/NotificationEventService.java +2 -4
- package/example/package.json +1 -1
- package/index.js +138 -86
- package/ios/AppIceReactPlugin.h +25 -0
- package/ios/AppIceReactPlugin.m +56 -1
- package/package.json +1 -1
- package/android/src/main/java/com/reactlibrary/Constants.java +0 -42
|
@@ -14,10 +14,8 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
|
|
14
14
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
15
15
|
import com.facebook.react.bridge.ReactMethod;
|
|
16
16
|
import com.facebook.react.bridge.ReadableMap;
|
|
17
|
-
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
18
|
-
import com.facebook.react.bridge.ReadableType;
|
|
19
17
|
|
|
20
|
-
import android.
|
|
18
|
+
import android.os.Handler;
|
|
21
19
|
|
|
22
20
|
import java.util.HashMap;
|
|
23
21
|
import java.util.List;
|
|
@@ -31,7 +29,6 @@ import semusi.context.ui.appInbox.IAppICESuccessCallback;
|
|
|
31
29
|
|
|
32
30
|
import java.util.*;
|
|
33
31
|
|
|
34
|
-
//import semusi.context.utility.Utility;
|
|
35
32
|
import androidx.annotation.NonNull;
|
|
36
33
|
import androidx.annotation.Nullable;
|
|
37
34
|
|
|
@@ -40,14 +37,10 @@ import com.facebook.react.bridge.WritableArray;
|
|
|
40
37
|
import com.facebook.react.bridge.WritableMap;
|
|
41
38
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
42
39
|
|
|
43
|
-
import org.json.JSONArray;
|
|
44
|
-
import org.json.JSONException;
|
|
45
|
-
import org.json.JSONObject;
|
|
46
|
-
|
|
47
40
|
public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
48
41
|
private static ReactApplicationContext context = null;
|
|
49
42
|
private static final String TAG = "AppIceReactPlugin";
|
|
50
|
-
|
|
43
|
+
|
|
51
44
|
public AppIceReactPluginModule(ReactApplicationContext reactContext) {
|
|
52
45
|
super(reactContext);
|
|
53
46
|
context = reactContext;
|
|
@@ -59,6 +52,11 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
59
52
|
return "AppIceReactPlugin";
|
|
60
53
|
}
|
|
61
54
|
|
|
55
|
+
|
|
56
|
+
//=========================
|
|
57
|
+
// SDK CONFIG
|
|
58
|
+
//========================
|
|
59
|
+
|
|
62
60
|
/**
|
|
63
61
|
* @param appID
|
|
64
62
|
* @param appKey
|
|
@@ -77,8 +75,6 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
77
75
|
try {
|
|
78
76
|
SdkConfig config = new SdkConfig();
|
|
79
77
|
config.setAnalyticsTrackingAllowedState(true);
|
|
80
|
-
|
|
81
|
-
System.out.println(certs.toString());
|
|
82
78
|
//readaableArray can not read by java so converting it to list type array
|
|
83
79
|
List<String> certList = new ArrayList<String>(certs.size());
|
|
84
80
|
|
|
@@ -86,9 +82,6 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
86
82
|
|
|
87
83
|
certList.add(certs.getString(i));
|
|
88
84
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
//as per new upgradation 27 jul 21r
|
|
92
85
|
Api.initSdk(appID, appKey, apiKey, region, baseUrl
|
|
93
86
|
, certList
|
|
94
87
|
, context);
|
|
@@ -100,35 +93,6 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
100
93
|
}
|
|
101
94
|
}
|
|
102
95
|
|
|
103
|
-
/**
|
|
104
|
-
* @param eventName
|
|
105
|
-
*/
|
|
106
|
-
@ReactMethod
|
|
107
|
-
public void tagEvent(String eventName, ReadableMap props) {
|
|
108
|
-
Context context = getReactApplicationContext();
|
|
109
|
-
try {
|
|
110
|
-
HashMap<String, Object> mapData = eventPropsFromReadableMap(props);
|
|
111
|
-
if (eventName != null && eventName.length() > 0) {
|
|
112
|
-
ContextSdk.tagEventObj(eventName, mapData, context);
|
|
113
|
-
}
|
|
114
|
-
} catch (Exception e) {
|
|
115
|
-
AppICEUtils.printLog(TAG, "Exception in tagEvent : " + e);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
@ReactMethod
|
|
121
|
-
public void setCustomVariable(String eventName, String value) {
|
|
122
|
-
Context context = getReactApplicationContext();
|
|
123
|
-
try {
|
|
124
|
-
if (value != null) {
|
|
125
|
-
ContextSdk.setCustomVariable(eventName, (String) value, context);
|
|
126
|
-
}
|
|
127
|
-
} catch (Exception e) {
|
|
128
|
-
AppICEUtils.printLog(TAG, "Exception in customVar : " + e);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
96
|
/**
|
|
133
97
|
* @return
|
|
134
98
|
*/
|
|
@@ -168,6 +132,56 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
168
132
|
}
|
|
169
133
|
}
|
|
170
134
|
|
|
135
|
+
@ReactMethod
|
|
136
|
+
public void registerLifeCycle() {
|
|
137
|
+
final Context context = getReactApplicationContext();
|
|
138
|
+
if (context != null) {
|
|
139
|
+
Handler handler = new Handler(context.getMainLooper());
|
|
140
|
+
handler.post(new Runnable() {
|
|
141
|
+
@Override
|
|
142
|
+
public void run() {
|
|
143
|
+
ContextSdk.registerLifeCycle(context);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
//===========================
|
|
150
|
+
// EVENTS AND VARIABLES
|
|
151
|
+
//===========================
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @param eventName
|
|
155
|
+
*/
|
|
156
|
+
@ReactMethod
|
|
157
|
+
public void tagEvent(String eventName, ReadableMap props) {
|
|
158
|
+
Context context = getReactApplicationContext();
|
|
159
|
+
try {
|
|
160
|
+
HashMap<String, Object> mapData = eventPropsFromReadableMap(props);
|
|
161
|
+
if (eventName != null && eventName.length() > 0) {
|
|
162
|
+
ContextSdk.tagEventObj(eventName, mapData, context);
|
|
163
|
+
}
|
|
164
|
+
} catch (Exception e) {
|
|
165
|
+
AppICEUtils.printLog(TAG, "Exception in tagEvent : " + e);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@ReactMethod
|
|
171
|
+
public void setCustomVariable(String eventName, String value) {
|
|
172
|
+
Context context = getReactApplicationContext();
|
|
173
|
+
try {
|
|
174
|
+
if (value != null) {
|
|
175
|
+
ContextSdk.setCustomVariable(eventName, (String) value, context);
|
|
176
|
+
}
|
|
177
|
+
} catch (Exception e) {
|
|
178
|
+
AppICEUtils.printLog(TAG, "Exception in customVar : " + e);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
//====================================
|
|
183
|
+
// user profile
|
|
184
|
+
//=====================================
|
|
171
185
|
@ReactMethod
|
|
172
186
|
public void setUser(ReadableMap userDetails) {
|
|
173
187
|
Context context = getReactApplicationContext();
|
|
@@ -179,114 +193,114 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
179
193
|
try {
|
|
180
194
|
User user = new User();
|
|
181
195
|
try {
|
|
182
|
-
if (map.containsKey(
|
|
183
|
-
Object name = map.get(
|
|
196
|
+
if (map.containsKey(EnumConstants.APPICE_USER_NAME.getValue())) {
|
|
197
|
+
Object name = map.get(EnumConstants.APPICE_USER_NAME.getValue());
|
|
184
198
|
if (name != null) {
|
|
185
199
|
user.setName(name.toString());
|
|
186
200
|
}
|
|
187
201
|
}
|
|
188
202
|
} catch (Exception e) {
|
|
189
|
-
AppICEUtils.printLog(TAG, "setUser: name issue "+e.getMessage());
|
|
203
|
+
AppICEUtils.printLog(TAG, "setUser: name issue " + e.getMessage());
|
|
190
204
|
}
|
|
191
205
|
|
|
192
206
|
try {
|
|
193
|
-
if (map.containsKey(
|
|
194
|
-
Object phone = map.get(
|
|
207
|
+
if (map.containsKey(EnumConstants.APPICE_USER_PHONE.getValue())) {
|
|
208
|
+
Object phone = map.get(EnumConstants.APPICE_USER_PHONE.getValue());
|
|
195
209
|
if (phone != null) {
|
|
196
210
|
user.setPhone(phone.toString());
|
|
197
211
|
}
|
|
198
212
|
}
|
|
199
213
|
} catch (Exception e) {
|
|
200
|
-
AppICEUtils.printLog(TAG, "setUser: phone issue "+e.getMessage());
|
|
214
|
+
AppICEUtils.printLog(TAG, "setUser: phone issue " + e.getMessage());
|
|
201
215
|
}
|
|
202
216
|
|
|
203
217
|
try {
|
|
204
|
-
if (map.containsKey(
|
|
205
|
-
Object email = map.get(
|
|
218
|
+
if (map.containsKey(EnumConstants.APPICE_USER_EMAIL.getValue())) {
|
|
219
|
+
Object email = map.get(EnumConstants.APPICE_USER_EMAIL.getValue());
|
|
206
220
|
if (email != null) {
|
|
207
221
|
user.setEmail(email.toString());
|
|
208
222
|
}
|
|
209
223
|
}
|
|
210
224
|
} catch (Exception e) {
|
|
211
|
-
AppICEUtils.printLog(TAG, "setUser: email issue "+e.getMessage());
|
|
225
|
+
AppICEUtils.printLog(TAG, "setUser: email issue " + e.getMessage());
|
|
212
226
|
}
|
|
213
227
|
|
|
214
228
|
try {
|
|
215
|
-
if (map.containsKey(
|
|
216
|
-
Object age = map.get(
|
|
229
|
+
if (map.containsKey(EnumConstants.APPICE_USER_AGE.getValue())) {
|
|
230
|
+
Object age = map.get(EnumConstants.APPICE_USER_AGE.getValue());
|
|
217
231
|
if (age != null) {
|
|
218
232
|
user.setAge((Integer) age);
|
|
219
233
|
}
|
|
220
234
|
}
|
|
221
235
|
} catch (Exception e) {
|
|
222
|
-
AppICEUtils.printLog(TAG, "setUser: age issue "+e.getMessage());
|
|
236
|
+
AppICEUtils.printLog(TAG, "setUser: age issue " + e.getMessage());
|
|
223
237
|
}
|
|
224
238
|
|
|
225
239
|
try {
|
|
226
|
-
if (map.containsKey(
|
|
227
|
-
Object age = map.get(
|
|
240
|
+
if (map.containsKey(EnumConstants.APPICE_DATE_OF_BIRTH.getValue())) {
|
|
241
|
+
Object age = map.get(EnumConstants.APPICE_DATE_OF_BIRTH.getValue());
|
|
228
242
|
if (age != null) {
|
|
229
243
|
user.setDob((Integer) age);
|
|
230
244
|
}
|
|
231
245
|
}
|
|
232
246
|
} catch (Exception e) {
|
|
233
|
-
AppICEUtils.printLog(TAG, "setUser: dob issue "+e.getMessage());
|
|
247
|
+
AppICEUtils.printLog(TAG, "setUser: dob issue " + e.getMessage());
|
|
234
248
|
}
|
|
235
249
|
|
|
236
250
|
try {
|
|
237
|
-
if (map.containsKey(
|
|
238
|
-
Object ed = map.get(
|
|
251
|
+
if (map.containsKey(EnumConstants.APPICE_USER_EDUCATION.getValue())) {
|
|
252
|
+
Object ed = map.get(EnumConstants.APPICE_USER_EDUCATION.getValue());
|
|
239
253
|
if (ed != null) {
|
|
240
254
|
user.setEducationType(ed.toString());
|
|
241
255
|
}
|
|
242
256
|
}
|
|
243
257
|
} catch (Exception e) {
|
|
244
|
-
AppICEUtils.printLog(TAG, "setUser: ed issue "+e.getMessage());
|
|
258
|
+
AppICEUtils.printLog(TAG, "setUser: ed issue " + e.getMessage());
|
|
245
259
|
}
|
|
246
260
|
|
|
247
261
|
try {
|
|
248
|
-
if (map.containsKey(
|
|
249
|
-
Object g = map.get(
|
|
262
|
+
if (map.containsKey(EnumConstants.APPICE_USER_GENDER.getValue())) {
|
|
263
|
+
Object g = map.get(EnumConstants.APPICE_USER_GENDER.getValue());
|
|
250
264
|
if (g != null) {
|
|
251
265
|
user.setGender(g.toString());
|
|
252
266
|
}
|
|
253
267
|
}
|
|
254
268
|
} catch (Exception e) {
|
|
255
|
-
AppICEUtils.printLog(TAG, "setUser: gender issue "+e.getMessage());
|
|
269
|
+
AppICEUtils.printLog(TAG, "setUser: gender issue " + e.getMessage());
|
|
256
270
|
}
|
|
257
271
|
|
|
258
272
|
|
|
259
273
|
try {
|
|
260
|
-
if (map.containsKey(
|
|
261
|
-
Object is_emp = map.get(
|
|
274
|
+
if (map.containsKey(EnumConstants.APPICE_USER_IS_EMPLOYED.getValue())) {
|
|
275
|
+
Object is_emp = map.get(EnumConstants.APPICE_USER_IS_EMPLOYED.getValue());
|
|
262
276
|
if (is_emp != null) {
|
|
263
277
|
user.setEmployed((Boolean) is_emp);
|
|
264
278
|
}
|
|
265
279
|
}
|
|
266
280
|
} catch (Exception e) {
|
|
267
|
-
AppICEUtils.printLog(TAG, "setUser: setEmployed issue "+e.getMessage());
|
|
281
|
+
AppICEUtils.printLog(TAG, "setUser: setEmployed issue " + e.getMessage());
|
|
268
282
|
}
|
|
269
283
|
|
|
270
284
|
try {
|
|
271
|
-
if (map.containsKey(
|
|
272
|
-
Object et = map.get(
|
|
285
|
+
if (map.containsKey(EnumConstants.APPICE_USER_EMPLOYMENT_TYPE.getValue())) {
|
|
286
|
+
Object et = map.get(EnumConstants.APPICE_USER_EMPLOYMENT_TYPE.getValue());
|
|
273
287
|
if (et != null) {
|
|
274
288
|
user.setEmploymentType(et.toString());
|
|
275
289
|
}
|
|
276
290
|
}
|
|
277
291
|
} catch (Exception e) {
|
|
278
|
-
AppICEUtils.printLog(TAG, "setUser: et issue "+e.getMessage());
|
|
292
|
+
AppICEUtils.printLog(TAG, "setUser: et issue " + e.getMessage());
|
|
279
293
|
}
|
|
280
294
|
|
|
281
295
|
try {
|
|
282
|
-
if (map.containsKey(
|
|
283
|
-
Object m = map.get(
|
|
296
|
+
if (map.containsKey(EnumConstants.APPICE_USER_MARRIED.getValue())) {
|
|
297
|
+
Object m = map.get(EnumConstants.APPICE_USER_MARRIED.getValue());
|
|
284
298
|
if (m != null) {
|
|
285
299
|
user.setMarried((Boolean) m);
|
|
286
300
|
}
|
|
287
301
|
}
|
|
288
302
|
} catch (Exception e) {
|
|
289
|
-
AppICEUtils.printLog(TAG, "setUser: married issue "+e.getMessage());
|
|
303
|
+
AppICEUtils.printLog(TAG, "setUser: married issue " + e.getMessage());
|
|
290
304
|
}
|
|
291
305
|
ContextSdk.setUser(user, context);
|
|
292
306
|
} catch (Exception e) {
|
|
@@ -294,6 +308,34 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
294
308
|
}
|
|
295
309
|
}
|
|
296
310
|
|
|
311
|
+
@ReactMethod
|
|
312
|
+
public void getUser(Callback callback) {
|
|
313
|
+
WritableMap userObject = Arguments.createMap();
|
|
314
|
+
Context context = getReactApplicationContext();
|
|
315
|
+
try {
|
|
316
|
+
User user = ContextSdk.getUser(context);
|
|
317
|
+
if (user != null) {
|
|
318
|
+
userObject.putString(EnumConstants.APPICE_USER_NAME.getValue(), user.getName());
|
|
319
|
+
userObject.putString(EnumConstants.APPICE_USER_EMAIL.getValue(), user.getEmail());
|
|
320
|
+
userObject.putInt(EnumConstants.APPICE_USER_AGE.getValue(), user.getAge());
|
|
321
|
+
userObject.putDouble(EnumConstants.APPICE_DATE_OF_BIRTH.getValue(), user.getDob());
|
|
322
|
+
userObject.putString(EnumConstants.APPICE_USER_EDUCATION.getValue(), user.getEducationType());
|
|
323
|
+
userObject.putString(EnumConstants.APPICE_USER_EMPLOYMENT_TYPE.getValue(), user.getEmploymentType());
|
|
324
|
+
userObject.putString(EnumConstants.APPICE_USER_GENDER.getValue(), user.getGender());
|
|
325
|
+
userObject.putString(EnumConstants.APPICE_USER_PHONE.getValue(), user.getPhone());
|
|
326
|
+
if (user.getCustomProperties() != null && user.getCustomProperties().length() > 0) {
|
|
327
|
+
userObject.putString(EnumConstants.DEMOGRAPHIC_INFO.getValue(), user.getCustomProperties().toString());
|
|
328
|
+
}
|
|
329
|
+
callback.invoke(userObject);
|
|
330
|
+
}
|
|
331
|
+
} catch (Throwable t) {
|
|
332
|
+
callback.invoke(t);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
//===============================================
|
|
337
|
+
// User id setting
|
|
338
|
+
//===============================================
|
|
297
339
|
@ReactMethod
|
|
298
340
|
public void setUserId(ReadableArray userIds) {
|
|
299
341
|
Context context = getReactApplicationContext();
|
|
@@ -307,24 +349,20 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
307
349
|
}
|
|
308
350
|
}
|
|
309
351
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
constants.put(Constants.APPICE_USER_EDUCATION, Constants.APPICE_USER_EDUCATION);
|
|
320
|
-
constants.put(Constants.APPICE_USER_EMPLOYMENT_TYPE, Constants.APPICE_USER_EMPLOYMENT_TYPE);
|
|
321
|
-
constants.put(Constants.APPICE_USER_AGE, Constants.APPICE_USER_AGE);
|
|
322
|
-
constants.put(Constants.APPICE_USER_GENDER, Constants.APPICE_USER_GENDER);
|
|
323
|
-
constants.put(Constants.APPICE_PUSH_NOTIFICATION_CLICKED, Constants.APPICE_PUSH_NOTIFICATION_CLICKED);
|
|
324
|
-
constants.put(Constants.APPICE_INAPP_NOTIFICATION_CLICKED, Constants.APPICE_INAPP_NOTIFICATION_CLICKED);
|
|
325
|
-
return constants;
|
|
352
|
+
/**
|
|
353
|
+
* To get the user_id from sdk.
|
|
354
|
+
*
|
|
355
|
+
* @callback will have the string
|
|
356
|
+
*/
|
|
357
|
+
@ReactMethod
|
|
358
|
+
public void getUserId(Callback callback) {
|
|
359
|
+
Context context = getReactApplicationContext();
|
|
360
|
+
callback.invoke(ContextSdk.getUserId(context));
|
|
326
361
|
}
|
|
327
362
|
|
|
363
|
+
//======================
|
|
364
|
+
// LISTENER
|
|
365
|
+
//======================
|
|
328
366
|
@ReactMethod
|
|
329
367
|
public void addListener(String eventName) {
|
|
330
368
|
// Set up any upstream listeners or background tasks as necessary
|
|
@@ -351,17 +389,17 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
351
389
|
/**
|
|
352
390
|
* Get inbox messages list.
|
|
353
391
|
*
|
|
354
|
-
* @param type
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
392
|
+
* @param type the message type
|
|
393
|
+
* 1 = ALL
|
|
394
|
+
* 2 = UNREAD
|
|
395
|
+
* 3 = READ
|
|
396
|
+
* 4 = VIEWED
|
|
397
|
+
* 5 = DELETED
|
|
398
|
+
* @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
|
|
361
399
|
* @callback will have the string json array
|
|
362
400
|
*/
|
|
363
401
|
@ReactMethod
|
|
364
|
-
public void getInboxMessages(int type, ReadableArray userIds, Callback callback
|
|
402
|
+
public void getInboxMessages(int type, ReadableArray userIds, Callback callback) {
|
|
365
403
|
Context context = getReactApplicationContext();
|
|
366
404
|
WritableArray writableArray = Arguments.createArray();
|
|
367
405
|
try {
|
|
@@ -383,17 +421,17 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
383
421
|
/**
|
|
384
422
|
* Get inbox messages count.
|
|
385
423
|
*
|
|
386
|
-
* @param type
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
424
|
+
* @param type the message type
|
|
425
|
+
* 1 = ALL
|
|
426
|
+
* 2 = UNREAD
|
|
427
|
+
* 3 = READ
|
|
428
|
+
* 4 = VIEWED
|
|
429
|
+
* 5 = DELETED
|
|
430
|
+
* @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
|
|
393
431
|
* @callback will have the integer
|
|
394
432
|
*/
|
|
395
433
|
@ReactMethod
|
|
396
|
-
public void getMessageCount(int type, ReadableArray userIds, Callback callback
|
|
434
|
+
public void getMessageCount(int type, ReadableArray userIds, Callback callback) {
|
|
397
435
|
Context context = getReactApplicationContext();
|
|
398
436
|
int count = 0;
|
|
399
437
|
try {
|
|
@@ -412,11 +450,11 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
412
450
|
* Get messages payload based on message id.
|
|
413
451
|
*
|
|
414
452
|
* @param messageId - message id of the notification
|
|
415
|
-
* @param userId
|
|
453
|
+
* @param userId - single userid in string ie. "useridA"
|
|
416
454
|
* @callback will have the json object
|
|
417
455
|
*/
|
|
418
456
|
@ReactMethod
|
|
419
|
-
public void getInboxMessageForId(String messageId, String userId, Callback callback
|
|
457
|
+
public void getInboxMessageForId(String messageId, String userId, Callback callback) {
|
|
420
458
|
Context context = getReactApplicationContext();
|
|
421
459
|
try {
|
|
422
460
|
AppICEInboxMessage inboxMessage = ContextSdk.getInboxMessageForId(messageId, userId, context);
|
|
@@ -430,12 +468,12 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
430
468
|
* update message status ex. UNREAD to READ.
|
|
431
469
|
*
|
|
432
470
|
* @param messageId - message id of the notification
|
|
433
|
-
* @param type
|
|
434
|
-
* @param userId
|
|
471
|
+
* @param type - integer value for status
|
|
472
|
+
* @param userId - single userid in string
|
|
435
473
|
* @callback will have the boolean
|
|
436
474
|
*/
|
|
437
475
|
@ReactMethod
|
|
438
|
-
public void updateInboxMessage(String messageId, int type, String userId, Callback callback
|
|
476
|
+
public void updateInboxMessage(String messageId, int type, String userId, Callback callback) {
|
|
439
477
|
Context context = getReactApplicationContext();
|
|
440
478
|
try {
|
|
441
479
|
boolean isUpdated = ContextSdk.updatedInboxMessage(messageId, type, userId, context);
|
|
@@ -453,7 +491,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
453
491
|
* @callback will have the boolean
|
|
454
492
|
*/
|
|
455
493
|
@ReactMethod
|
|
456
|
-
public void synchronizeInbox(int timeout,
|
|
494
|
+
public void synchronizeInbox(int timeout, final Callback callback) {
|
|
457
495
|
Context context = getReactApplicationContext();
|
|
458
496
|
try {
|
|
459
497
|
ContextSdk.synchronizeInbox(new IAppICESuccessCallback() {
|
|
@@ -475,7 +513,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
475
513
|
* To set the custom device_id.
|
|
476
514
|
*/
|
|
477
515
|
@ReactMethod
|
|
478
|
-
public void setInternalId(String deviceId){
|
|
516
|
+
public void setInternalId(String deviceId) {
|
|
479
517
|
//TODO{ we can not call setDevice Id here because it
|
|
480
518
|
// will directly call start context with new device id
|
|
481
519
|
// but here we want to store the data only
|
|
@@ -489,19 +527,53 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
489
527
|
* @callback will have the string
|
|
490
528
|
*/
|
|
491
529
|
@ReactMethod
|
|
492
|
-
public void getDeviceId(Callback callback){
|
|
530
|
+
public void getDeviceId(Callback callback) {
|
|
493
531
|
Context context = getReactApplicationContext();
|
|
494
532
|
callback.invoke(ContextSdk.getInternalId(context));
|
|
495
533
|
}
|
|
496
534
|
|
|
535
|
+
@Nullable
|
|
536
|
+
@Override
|
|
537
|
+
public Map<String, Object> getConstants() {
|
|
538
|
+
final Map<String, Object> constants = new HashMap<>();
|
|
539
|
+
constants.put(EnumConstants.APPICE_USER_NAME.getConstants(), EnumConstants.APPICE_USER_NAME.getValue());
|
|
540
|
+
constants.put(EnumConstants.APPICE_USER_PHONE.getConstants(), EnumConstants.APPICE_USER_PHONE.getValue());
|
|
541
|
+
constants.put(EnumConstants.APPICE_USER_EMAIL.getConstants(), EnumConstants.APPICE_USER_EMAIL.getValue());
|
|
542
|
+
constants.put(EnumConstants.APPICE_USER_IS_EMPLOYED.getConstants(), EnumConstants.APPICE_USER_IS_EMPLOYED.getValue());
|
|
543
|
+
constants.put(EnumConstants.APPICE_USER_MARRIED.getConstants(), EnumConstants.APPICE_USER_MARRIED.getValue());
|
|
544
|
+
constants.put(EnumConstants.APPICE_USER_EDUCATION.getConstants(), EnumConstants.APPICE_USER_EDUCATION.getValue());
|
|
545
|
+
constants.put(EnumConstants.APPICE_USER_EMPLOYMENT_TYPE.getConstants(), EnumConstants.APPICE_USER_EMPLOYMENT_TYPE.getValue());
|
|
546
|
+
constants.put(EnumConstants.APPICE_USER_AGE.getConstants(), EnumConstants.APPICE_USER_AGE.getValue());
|
|
547
|
+
constants.put(EnumConstants.APPICE_USER_GENDER.getConstants(), EnumConstants.APPICE_USER_GENDER.getValue());
|
|
548
|
+
constants.put(EnumConstants.APPICE_PUSH_NOTIFICATION_CLICKED.getConstants(), EnumConstants.APPICE_PUSH_NOTIFICATION_CLICKED.getValue());
|
|
549
|
+
constants.put(EnumConstants.APPICE_INAPP_NOTIFICATION_CLICKED.getConstants(), EnumConstants.APPICE_INAPP_NOTIFICATION_CLICKED.getValue());
|
|
550
|
+
constants.put(EnumConstants.FIRST_SEEN.getConstants(), EnumConstants.FIRST_SEEN.getValue());
|
|
551
|
+
constants.put(EnumConstants.LAST_SEEN.getConstants(), EnumConstants.LAST_SEEN.getValue());
|
|
552
|
+
constants.put(EnumConstants.TOP_N_PRODUCTS_VIEWED.getConstants(), EnumConstants.TOP_N_PRODUCTS_VIEWED.getValue());
|
|
553
|
+
constants.put(EnumConstants.N_COMPLAINTS_RAISED.getConstants(), EnumConstants.N_COMPLAINTS_RAISED.getValue());
|
|
554
|
+
constants.put(EnumConstants.PREF_LOGIN_DEVICE.getConstants(), EnumConstants.PREF_LOGIN_DEVICE.getValue());
|
|
555
|
+
constants.put(EnumConstants.REFERRAL_CAMPAIGN.getConstants(), EnumConstants.REFERRAL_CAMPAIGN.getValue());
|
|
556
|
+
constants.put(EnumConstants.DEMOGRAPHIC_INFO.getConstants(), EnumConstants.DEMOGRAPHIC_INFO.getValue());
|
|
557
|
+
constants.put(EnumConstants.TOTAL_ORDER_VALUE.getConstants(), EnumConstants.TOTAL_ORDER_VALUE.getValue());
|
|
558
|
+
constants.put(EnumConstants.ADD_TO_CART_N_DAYS.getConstants(), EnumConstants.ADD_TO_CART_N_DAYS.getValue());
|
|
559
|
+
constants.put(EnumConstants.FINANCIAL_SERVICES.getConstants(), EnumConstants.FINANCIAL_SERVICES.getValue());
|
|
560
|
+
constants.put(EnumConstants.CREDIT_SCORE.getConstants(), EnumConstants.CREDIT_SCORE.getValue());
|
|
561
|
+
constants.put(EnumConstants.DEBT_TO_INCOME_RATIO.getConstants(), EnumConstants.DEBT_TO_INCOME_RATIO.getValue());
|
|
562
|
+
constants.put(EnumConstants.SAVINGS_BALANCE.getConstants(), EnumConstants.SAVINGS_BALANCE.getValue());
|
|
563
|
+
constants.put(EnumConstants.CHECKING_BALANCE.getConstants(), EnumConstants.CHECKING_BALANCE.getValue());
|
|
564
|
+
constants.put(EnumConstants.AVERAGE_TRANSACTION_AMOUNT.getConstants(), EnumConstants.AVERAGE_TRANSACTION_AMOUNT.getValue());
|
|
565
|
+
constants.put(EnumConstants.FREQUENCY_OF_TRANSACTION.getConstants(), EnumConstants.FREQUENCY_OF_TRANSACTION.getValue());
|
|
566
|
+
constants.put(EnumConstants.TYPE_OF_TRANSACTION.getConstants(), EnumConstants.TYPE_OF_TRANSACTION.getValue());
|
|
567
|
+
|
|
568
|
+
return constants;
|
|
569
|
+
}
|
|
570
|
+
|
|
497
571
|
//=====================================
|
|
498
572
|
public static void sendEvent(String eventName, @Nullable WritableMap params) {
|
|
499
573
|
try {
|
|
500
|
-
context.
|
|
501
|
-
getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
502
|
-
.emit(eventName, params);
|
|
574
|
+
context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
|
|
503
575
|
} catch (RuntimeException e) {
|
|
504
|
-
|
|
576
|
+
AppICEUtils.printLog(TAG, "java.lang.RuntimeException: Trying to invoke JS before CatalystInstance has been set!" + e);
|
|
505
577
|
}
|
|
506
578
|
}
|
|
507
|
-
}
|
|
579
|
+
}
|
|
@@ -3,25 +3,13 @@ package com.reactlibrary;
|
|
|
3
3
|
import android.content.BroadcastReceiver;
|
|
4
4
|
import android.content.Context;
|
|
5
5
|
import android.content.Intent;
|
|
6
|
-
import android.net.Uri;
|
|
7
6
|
import android.os.Bundle;
|
|
8
|
-
import android.util.Log;
|
|
9
7
|
|
|
10
8
|
import com.facebook.react.bridge.Arguments;
|
|
11
9
|
import com.facebook.react.bridge.WritableMap;
|
|
12
10
|
|
|
13
|
-
import org.json.JSONException;
|
|
14
11
|
import org.json.JSONObject;
|
|
15
12
|
|
|
16
|
-
import java.net.URLDecoder;
|
|
17
|
-
import java.util.HashMap;
|
|
18
|
-
import java.util.Iterator;
|
|
19
|
-
import java.util.Map;
|
|
20
|
-
import java.util.Set;
|
|
21
|
-
|
|
22
|
-
import semusi.activitysdk.ContextSdk;
|
|
23
|
-
|
|
24
|
-
|
|
25
13
|
public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
26
14
|
private static final String TAG = "CampaignCampsReceiver";
|
|
27
15
|
public CampaignCampsReceiver(){
|
|
@@ -46,8 +34,8 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
|
46
34
|
if (category) {
|
|
47
35
|
if (cdata != null && cdata.length() > 0) {
|
|
48
36
|
WritableMap params = Arguments.createMap();
|
|
49
|
-
params.putString(
|
|
50
|
-
AppIceReactPluginModule.sendEvent(
|
|
37
|
+
params.putString(EnumConstants.APPICE_INAPP_NOTIFICATION_CLICKED.getValue(), cdata);
|
|
38
|
+
AppIceReactPluginModule.sendEvent(EnumConstants.APPICE_INAPP_NOTIFICATION_CLICKED.getValue(), params);
|
|
51
39
|
}
|
|
52
40
|
}
|
|
53
41
|
|
|
@@ -56,8 +44,8 @@ public class CampaignCampsReceiver extends BroadcastReceiver {
|
|
|
56
44
|
if (pushContent != null){
|
|
57
45
|
WritableMap params = Arguments.createMap();
|
|
58
46
|
if (pushContent != null){
|
|
59
|
-
params.putString(
|
|
60
|
-
AppIceReactPluginModule.sendEvent(
|
|
47
|
+
params.putString(EnumConstants.APPICE_PUSH_NOTIFICATION_CLICKED.getValue(), pushContent.toString());
|
|
48
|
+
AppIceReactPluginModule.sendEvent(EnumConstants.APPICE_PUSH_NOTIFICATION_CLICKED.getValue(), params);
|
|
61
49
|
}
|
|
62
50
|
}
|
|
63
51
|
}
|