reactnative-plugin-appice 1.6.3 → 1.6.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/android/build.gradle +3 -3
- package/android/src/main/AndroidManifest.xml +47 -127
- package/android/src/main/java/com/reactlibrary/AppICEUtils.java +151 -21
- package/android/src/main/java/com/reactlibrary/AppIceReactPluginModule.java +307 -240
- package/android/src/main/java/com/reactlibrary/CampaignCampsReceiver.java +6 -23
- package/android/src/main/java/com/reactlibrary/EnumConstants.java +251 -0
- package/android/src/main/java/com/reactlibrary/NotificationEventService.java +2 -4
- package/example/App.js +76 -0
- package/example/package.json +1 -1
- package/index.js +201 -61
- package/ios/AppIceReactPlugin.h +36 -0
- package/ios/AppIceReactPlugin.m +202 -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
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
package com.reactlibrary;
|
|
2
2
|
|
|
3
|
+
import static com.reactlibrary.AppICEUtils.arrayListStringFromReadableArray;
|
|
4
|
+
import static com.reactlibrary.AppICEUtils.eventPropsFromReadableMap;
|
|
5
|
+
|
|
3
6
|
import android.content.Context;
|
|
4
7
|
import android.content.Intent;
|
|
5
8
|
import android.content.pm.PackageManager;
|
|
@@ -11,10 +14,8 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
|
|
11
14
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
12
15
|
import com.facebook.react.bridge.ReactMethod;
|
|
13
16
|
import com.facebook.react.bridge.ReadableMap;
|
|
14
|
-
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
15
|
-
import com.facebook.react.bridge.ReadableType;
|
|
16
17
|
|
|
17
|
-
import android.
|
|
18
|
+
import android.os.Handler;
|
|
18
19
|
|
|
19
20
|
import java.util.HashMap;
|
|
20
21
|
import java.util.List;
|
|
@@ -23,36 +24,22 @@ import semusi.activitysdk.Api;
|
|
|
23
24
|
import semusi.activitysdk.ContextSdk;
|
|
24
25
|
import semusi.activitysdk.SdkConfig;
|
|
25
26
|
import semusi.activitysdk.User;
|
|
27
|
+
import semusi.context.ui.appInbox.AppICEInboxMessage;
|
|
28
|
+
import semusi.context.ui.appInbox.IAppICESuccessCallback;
|
|
26
29
|
|
|
27
30
|
import java.util.*;
|
|
28
31
|
|
|
29
|
-
//import semusi.context.utility.Utility;
|
|
30
32
|
import androidx.annotation.NonNull;
|
|
31
33
|
import androidx.annotation.Nullable;
|
|
32
34
|
|
|
33
35
|
import com.facebook.react.bridge.ReadableArray;
|
|
36
|
+
import com.facebook.react.bridge.WritableArray;
|
|
34
37
|
import com.facebook.react.bridge.WritableMap;
|
|
35
38
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
36
39
|
|
|
37
|
-
import org.json.JSONArray;
|
|
38
|
-
import org.json.JSONException;
|
|
39
|
-
import org.json.JSONObject;
|
|
40
|
-
|
|
41
40
|
public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
42
41
|
private static ReactApplicationContext context = null;
|
|
43
|
-
private static final String TAG = "
|
|
44
|
-
private static final String APPICE_USER_NAME = "n";
|
|
45
|
-
private static final String APPICE_USER_PHONE = "ph";
|
|
46
|
-
private static final String APPICE_USER_EMAIL = "em";
|
|
47
|
-
private static final String dateOfBirth = "dob";
|
|
48
|
-
private static final String APPICE_USER_AGE = "a";
|
|
49
|
-
private static final String APPICE_USER_EDUCATION = "ed";
|
|
50
|
-
private static final String APPICE_USER_GENDER = "g";
|
|
51
|
-
private static final String APPICE_USER_IS_EMPLOYED = "is_emp";
|
|
52
|
-
private static final String APPICE_USER_EMPLOYMENT_TYPE = "et";
|
|
53
|
-
private static final String APPICE_USER_MARRIED = "m";
|
|
54
|
-
public static final String APPICE_PUSH_NOTIFICATION_CLICKED = "AppICEPushNotificationClicked";
|
|
55
|
-
public static final String APPICE_INAPP_NOTIFICATION_CLICKED = "AppICEInAppClicked";
|
|
42
|
+
private static final String TAG = "AppIceReactPlugin";
|
|
56
43
|
|
|
57
44
|
public AppIceReactPluginModule(ReactApplicationContext reactContext) {
|
|
58
45
|
super(reactContext);
|
|
@@ -65,6 +52,11 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
65
52
|
return "AppIceReactPlugin";
|
|
66
53
|
}
|
|
67
54
|
|
|
55
|
+
|
|
56
|
+
//=========================
|
|
57
|
+
// SDK CONFIG
|
|
58
|
+
//========================
|
|
59
|
+
|
|
68
60
|
/**
|
|
69
61
|
* @param appID
|
|
70
62
|
* @param appKey
|
|
@@ -79,12 +71,10 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
79
71
|
String region, String baseUrl, ReadableArray certs
|
|
80
72
|
) {
|
|
81
73
|
Context context = getReactApplicationContext();
|
|
82
|
-
|
|
74
|
+
AppICEUtils.printLog(TAG, "in startContext : appID : " + appID + ", appkey : " + appKey + ", apiKey : " + apiKey);
|
|
83
75
|
try {
|
|
84
76
|
SdkConfig config = new SdkConfig();
|
|
85
77
|
config.setAnalyticsTrackingAllowedState(true);
|
|
86
|
-
|
|
87
|
-
System.out.println(certs.toString());
|
|
88
78
|
//readaableArray can not read by java so converting it to list type array
|
|
89
79
|
List<String> certList = new ArrayList<String>(certs.size());
|
|
90
80
|
|
|
@@ -92,9 +82,6 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
92
82
|
|
|
93
83
|
certList.add(certs.getString(i));
|
|
94
84
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//as per new upgradation 27 jul 21r
|
|
98
85
|
Api.initSdk(appID, appKey, apiKey, region, baseUrl
|
|
99
86
|
, certList
|
|
100
87
|
, context);
|
|
@@ -102,36 +89,7 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
102
89
|
Api.startContext(context, config);
|
|
103
90
|
|
|
104
91
|
} catch (Exception e) {
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @param eventName
|
|
111
|
-
*/
|
|
112
|
-
@ReactMethod
|
|
113
|
-
public void tagEvent(String eventName, ReadableMap props) {
|
|
114
|
-
Context context = getReactApplicationContext();
|
|
115
|
-
try {
|
|
116
|
-
HashMap<String, Object> mapData = eventPropsFromReadableMap(props);
|
|
117
|
-
if (eventName != null && eventName.length() > 0) {
|
|
118
|
-
ContextSdk.tagEventObj(eventName, mapData, context);
|
|
119
|
-
}
|
|
120
|
-
} catch (Exception e) {
|
|
121
|
-
Log.d(TAG, "Exception in tagEvent : " + e);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
@ReactMethod
|
|
127
|
-
public void setCustomVariable(String eventName, String value) {
|
|
128
|
-
Context context = getReactApplicationContext();
|
|
129
|
-
try {
|
|
130
|
-
if (value != null) {
|
|
131
|
-
ContextSdk.setCustomVariable(eventName, (String) value, context);
|
|
132
|
-
}
|
|
133
|
-
} catch (Exception e) {
|
|
134
|
-
Log.d(TAG, "Exception in customVar : " + e);
|
|
92
|
+
AppICEUtils.printLog(TAG, "Exception in startContext : " + e);
|
|
135
93
|
}
|
|
136
94
|
}
|
|
137
95
|
|
|
@@ -148,151 +106,201 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
148
106
|
receiverIntent.setClass(ctx, CampaignCampsReceiver.class);
|
|
149
107
|
List<ResolveInfo> receivers = pm.queryBroadcastReceivers(receiverIntent, 0);
|
|
150
108
|
if (receivers == null || receivers.size() <= 0) {
|
|
151
|
-
|
|
109
|
+
AppICEUtils.printLog(TAG, "Missing Receiver entry in AndroidManifest : CampaignCampsReceiver");
|
|
152
110
|
}
|
|
153
111
|
Intent serviceIntent = new Intent();
|
|
154
112
|
serviceIntent.setClass(ctx, NotificationEventService.class);
|
|
155
113
|
ResolveInfo services = pm.resolveService(serviceIntent, 0);
|
|
156
114
|
if (services == null) {
|
|
157
|
-
|
|
115
|
+
AppICEUtils.printLog(TAG, "Missing Service entry in AndroidManifest : NotificationEventService");
|
|
158
116
|
}
|
|
159
117
|
|
|
160
118
|
ContextSdk sdk = new ContextSdk(ctx);
|
|
161
119
|
if (sdk.getAppId() == null || sdk.getAppId().length() <= 0 || sdk.getAppId().trim().length() <= 0) {
|
|
162
|
-
|
|
120
|
+
AppICEUtils.printLog(TAG, "Missing Meta-data entry : AppID");
|
|
163
121
|
}
|
|
164
122
|
|
|
165
123
|
if (sdk.getAppKey() == null || sdk.getAppKey().length() <= 0 || sdk.getAppKey().trim().length() <= 0) {
|
|
166
|
-
|
|
124
|
+
AppICEUtils.printLog(TAG, "Missing Meta-data entry : AppKey");
|
|
167
125
|
}
|
|
168
126
|
|
|
169
127
|
if (sdk.getApiKey() == null || sdk.getApiKey().length() <= 0 || sdk.getApiKey().trim().length() <= 0) {
|
|
170
|
-
|
|
128
|
+
AppICEUtils.printLog(TAG, "Missing Meta-data entry : ApiKey");
|
|
129
|
+
}
|
|
130
|
+
} catch (Exception e) {
|
|
131
|
+
AppICEUtils.printLog(TAG, "validateIntegration: " + e.getMessage());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
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);
|
|
171
163
|
}
|
|
172
164
|
} catch (Exception e) {
|
|
173
|
-
|
|
165
|
+
AppICEUtils.printLog(TAG, "Exception in tagEvent : " + e);
|
|
174
166
|
}
|
|
175
167
|
}
|
|
176
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
|
+
//=====================================
|
|
177
185
|
@ReactMethod
|
|
178
186
|
public void setUser(ReadableMap userDetails) {
|
|
179
187
|
Context context = getReactApplicationContext();
|
|
180
188
|
|
|
181
|
-
|
|
189
|
+
AppICEUtils.printLog(TAG, "setUser: " + userDetails);
|
|
182
190
|
HashMap<String, Object> map = eventPropsFromReadableMap(userDetails);
|
|
183
191
|
|
|
184
192
|
if (map != null) {
|
|
185
193
|
try {
|
|
186
194
|
User user = new User();
|
|
187
195
|
try {
|
|
188
|
-
if (map.containsKey(
|
|
189
|
-
Object name = map.get(
|
|
196
|
+
if (map.containsKey(EnumConstants.APPICE_USER_NAME.getValue())) {
|
|
197
|
+
Object name = map.get(EnumConstants.APPICE_USER_NAME.getValue());
|
|
190
198
|
if (name != null) {
|
|
191
199
|
user.setName(name.toString());
|
|
192
200
|
}
|
|
193
201
|
}
|
|
194
202
|
} catch (Exception e) {
|
|
195
|
-
|
|
203
|
+
AppICEUtils.printLog(TAG, "setUser: name issue " + e.getMessage());
|
|
196
204
|
}
|
|
197
205
|
|
|
198
206
|
try {
|
|
199
|
-
if (map.containsKey(
|
|
200
|
-
Object phone = map.get(
|
|
207
|
+
if (map.containsKey(EnumConstants.APPICE_USER_PHONE.getValue())) {
|
|
208
|
+
Object phone = map.get(EnumConstants.APPICE_USER_PHONE.getValue());
|
|
201
209
|
if (phone != null) {
|
|
202
210
|
user.setPhone(phone.toString());
|
|
203
211
|
}
|
|
204
212
|
}
|
|
205
213
|
} catch (Exception e) {
|
|
206
|
-
|
|
214
|
+
AppICEUtils.printLog(TAG, "setUser: phone issue " + e.getMessage());
|
|
207
215
|
}
|
|
208
216
|
|
|
209
217
|
try {
|
|
210
|
-
if (map.containsKey(
|
|
211
|
-
Object email = map.get(
|
|
218
|
+
if (map.containsKey(EnumConstants.APPICE_USER_EMAIL.getValue())) {
|
|
219
|
+
Object email = map.get(EnumConstants.APPICE_USER_EMAIL.getValue());
|
|
212
220
|
if (email != null) {
|
|
213
221
|
user.setEmail(email.toString());
|
|
214
222
|
}
|
|
215
223
|
}
|
|
216
224
|
} catch (Exception e) {
|
|
217
|
-
|
|
225
|
+
AppICEUtils.printLog(TAG, "setUser: email issue " + e.getMessage());
|
|
218
226
|
}
|
|
219
227
|
|
|
220
228
|
try {
|
|
221
|
-
if (map.containsKey(
|
|
222
|
-
Object age = map.get(
|
|
229
|
+
if (map.containsKey(EnumConstants.APPICE_USER_AGE.getValue())) {
|
|
230
|
+
Object age = map.get(EnumConstants.APPICE_USER_AGE.getValue());
|
|
223
231
|
if (age != null) {
|
|
224
232
|
user.setAge((Integer) age);
|
|
225
233
|
}
|
|
226
234
|
}
|
|
227
235
|
} catch (Exception e) {
|
|
228
|
-
|
|
236
|
+
AppICEUtils.printLog(TAG, "setUser: age issue " + e.getMessage());
|
|
229
237
|
}
|
|
230
238
|
|
|
231
239
|
try {
|
|
232
|
-
if (map.containsKey(
|
|
233
|
-
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());
|
|
234
242
|
if (age != null) {
|
|
235
243
|
user.setDob((Integer) age);
|
|
236
244
|
}
|
|
237
245
|
}
|
|
238
246
|
} catch (Exception e) {
|
|
239
|
-
|
|
247
|
+
AppICEUtils.printLog(TAG, "setUser: dob issue " + e.getMessage());
|
|
240
248
|
}
|
|
241
249
|
|
|
242
250
|
try {
|
|
243
|
-
if (map.containsKey(
|
|
244
|
-
Object ed = map.get(
|
|
251
|
+
if (map.containsKey(EnumConstants.APPICE_USER_EDUCATION.getValue())) {
|
|
252
|
+
Object ed = map.get(EnumConstants.APPICE_USER_EDUCATION.getValue());
|
|
245
253
|
if (ed != null) {
|
|
246
254
|
user.setEducationType(ed.toString());
|
|
247
255
|
}
|
|
248
256
|
}
|
|
249
257
|
} catch (Exception e) {
|
|
250
|
-
|
|
258
|
+
AppICEUtils.printLog(TAG, "setUser: ed issue " + e.getMessage());
|
|
251
259
|
}
|
|
252
260
|
|
|
253
261
|
try {
|
|
254
|
-
if (map.containsKey(
|
|
255
|
-
Object g = map.get(
|
|
262
|
+
if (map.containsKey(EnumConstants.APPICE_USER_GENDER.getValue())) {
|
|
263
|
+
Object g = map.get(EnumConstants.APPICE_USER_GENDER.getValue());
|
|
256
264
|
if (g != null) {
|
|
257
265
|
user.setGender(g.toString());
|
|
258
266
|
}
|
|
259
267
|
}
|
|
260
268
|
} catch (Exception e) {
|
|
261
|
-
|
|
269
|
+
AppICEUtils.printLog(TAG, "setUser: gender issue " + e.getMessage());
|
|
262
270
|
}
|
|
263
271
|
|
|
264
272
|
|
|
265
273
|
try {
|
|
266
|
-
if (map.containsKey(
|
|
267
|
-
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());
|
|
268
276
|
if (is_emp != null) {
|
|
269
277
|
user.setEmployed((Boolean) is_emp);
|
|
270
278
|
}
|
|
271
279
|
}
|
|
272
280
|
} catch (Exception e) {
|
|
273
|
-
|
|
281
|
+
AppICEUtils.printLog(TAG, "setUser: setEmployed issue " + e.getMessage());
|
|
274
282
|
}
|
|
275
283
|
|
|
276
284
|
try {
|
|
277
|
-
if (map.containsKey(
|
|
278
|
-
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());
|
|
279
287
|
if (et != null) {
|
|
280
288
|
user.setEmploymentType(et.toString());
|
|
281
289
|
}
|
|
282
290
|
}
|
|
283
291
|
} catch (Exception e) {
|
|
284
|
-
|
|
292
|
+
AppICEUtils.printLog(TAG, "setUser: et issue " + e.getMessage());
|
|
285
293
|
}
|
|
286
294
|
|
|
287
295
|
try {
|
|
288
|
-
if (map.containsKey(
|
|
289
|
-
Object m = map.get(
|
|
296
|
+
if (map.containsKey(EnumConstants.APPICE_USER_MARRIED.getValue())) {
|
|
297
|
+
Object m = map.get(EnumConstants.APPICE_USER_MARRIED.getValue());
|
|
290
298
|
if (m != null) {
|
|
291
299
|
user.setMarried((Boolean) m);
|
|
292
300
|
}
|
|
293
301
|
}
|
|
294
302
|
} catch (Exception e) {
|
|
295
|
-
|
|
303
|
+
AppICEUtils.printLog(TAG, "setUser: married issue " + e.getMessage());
|
|
296
304
|
}
|
|
297
305
|
ContextSdk.setUser(user, context);
|
|
298
306
|
} catch (Exception e) {
|
|
@@ -300,6 +308,34 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
300
308
|
}
|
|
301
309
|
}
|
|
302
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
|
+
//===============================================
|
|
303
339
|
@ReactMethod
|
|
304
340
|
public void setUserId(ReadableArray userIds) {
|
|
305
341
|
Context context = getReactApplicationContext();
|
|
@@ -313,24 +349,20 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
313
349
|
}
|
|
314
350
|
}
|
|
315
351
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
constants.put(APPICE_USER_EDUCATION, APPICE_USER_EDUCATION);
|
|
326
|
-
constants.put(APPICE_USER_EMPLOYMENT_TYPE, APPICE_USER_EMPLOYMENT_TYPE);
|
|
327
|
-
constants.put(APPICE_USER_AGE, APPICE_USER_AGE);
|
|
328
|
-
constants.put(APPICE_USER_GENDER, APPICE_USER_GENDER);
|
|
329
|
-
constants.put(APPICE_PUSH_NOTIFICATION_CLICKED, APPICE_PUSH_NOTIFICATION_CLICKED);
|
|
330
|
-
constants.put(APPICE_INAPP_NOTIFICATION_CLICKED, APPICE_INAPP_NOTIFICATION_CLICKED);
|
|
331
|
-
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));
|
|
332
361
|
}
|
|
333
362
|
|
|
363
|
+
//======================
|
|
364
|
+
// LISTENER
|
|
365
|
+
//======================
|
|
334
366
|
@ReactMethod
|
|
335
367
|
public void addListener(String eventName) {
|
|
336
368
|
// Set up any upstream listeners or background tasks as necessary
|
|
@@ -341,172 +373,207 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
341
373
|
// Remove upstream listeners, stop unnecessary background tasks
|
|
342
374
|
}
|
|
343
375
|
|
|
376
|
+
//==============================================
|
|
377
|
+
// notification
|
|
378
|
+
//==============================================
|
|
344
379
|
@ReactMethod
|
|
345
380
|
public void pushNotificationClicked(String payload) {
|
|
346
381
|
Context ctx = getReactApplicationContext();
|
|
347
382
|
ContextSdk.pushNotificationClicked(payload, ctx);
|
|
348
383
|
}
|
|
349
384
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
// Device Setting
|
|
354
|
-
//===========================================
|
|
385
|
+
//========================================
|
|
386
|
+
// AppInbox
|
|
387
|
+
//=========================================
|
|
355
388
|
|
|
356
389
|
/**
|
|
357
|
-
*
|
|
390
|
+
* Get inbox messages list.
|
|
391
|
+
*
|
|
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" ]
|
|
399
|
+
* @callback will have the string json array
|
|
358
400
|
*/
|
|
359
401
|
@ReactMethod
|
|
360
|
-
public void
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
402
|
+
public void getInboxMessages(int type, ReadableArray userIds, Callback callback) {
|
|
403
|
+
Context context = getReactApplicationContext();
|
|
404
|
+
WritableArray writableArray = Arguments.createArray();
|
|
405
|
+
try {
|
|
406
|
+
ArrayList<String> finalValues = arrayListStringFromReadableArray(userIds);
|
|
407
|
+
if (finalValues != null) {
|
|
408
|
+
String[] usersId = finalValues.toArray(new String[finalValues.size()]);
|
|
409
|
+
List<AppICEInboxMessage> appICEInboxMessage = ContextSdk.getInboxMessage(type, usersId, context);
|
|
410
|
+
for (int i = 0; i < appICEInboxMessage.size(); i++) {
|
|
411
|
+
AppICEInboxMessage inboxMessage = appICEInboxMessage.get(i);
|
|
412
|
+
writableArray.pushMap(AppICEUtils.convertClassToWritableMap(inboxMessage));
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
callback.invoke(writableArray);
|
|
416
|
+
} catch (Throwable e) {
|
|
417
|
+
callback.invoke(e);
|
|
418
|
+
}
|
|
366
419
|
}
|
|
367
420
|
|
|
368
421
|
/**
|
|
369
|
-
*
|
|
422
|
+
* Get inbox messages count.
|
|
370
423
|
*
|
|
371
|
-
* @
|
|
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" ]
|
|
431
|
+
* @callback will have the integer
|
|
372
432
|
*/
|
|
373
433
|
@ReactMethod
|
|
374
|
-
public void
|
|
434
|
+
public void getMessageCount(int type, ReadableArray userIds, Callback callback) {
|
|
375
435
|
Context context = getReactApplicationContext();
|
|
376
|
-
|
|
436
|
+
int count = 0;
|
|
437
|
+
try {
|
|
438
|
+
ArrayList<String> finalValues = arrayListStringFromReadableArray(userIds);
|
|
439
|
+
if (finalValues != null) {
|
|
440
|
+
String[] usersId = finalValues.toArray(new String[finalValues.size()]);
|
|
441
|
+
count = ContextSdk.getMessageCount(type, usersId, context);
|
|
442
|
+
}
|
|
443
|
+
callback.invoke(count);
|
|
444
|
+
} catch (Throwable e) {
|
|
445
|
+
callback.invoke(e);
|
|
446
|
+
}
|
|
377
447
|
}
|
|
378
|
-
|
|
379
|
-
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Get messages payload based on message id.
|
|
380
451
|
*
|
|
381
|
-
* @
|
|
452
|
+
* @param messageId - message id of the notification
|
|
453
|
+
* @param userId - single userid in string ie. "useridA"
|
|
454
|
+
* @callback will have the json object
|
|
382
455
|
*/
|
|
383
|
-
|
|
384
|
-
public void
|
|
456
|
+
@ReactMethod
|
|
457
|
+
public void getInboxMessageForId(String messageId, String userId, Callback callback) {
|
|
385
458
|
Context context = getReactApplicationContext();
|
|
386
|
-
callback.invoke(ContextSdk.getUserId(context));
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
public static void sendEvent(String eventName, @Nullable WritableMap params) {
|
|
390
459
|
try {
|
|
391
|
-
context
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
Log.e(TAG, "java.lang.RuntimeException: Trying to invoke JS before CatalystInstance has been set!", e);
|
|
460
|
+
AppICEInboxMessage inboxMessage = ContextSdk.getInboxMessageForId(messageId, userId, context);
|
|
461
|
+
callback.invoke(AppICEUtils.convertClassToWritableMap(inboxMessage));
|
|
462
|
+
} catch (Throwable e) {
|
|
463
|
+
callback.invoke(e);
|
|
396
464
|
}
|
|
397
465
|
}
|
|
398
466
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
467
|
+
/**
|
|
468
|
+
* update message status ex. UNREAD to READ.
|
|
469
|
+
*
|
|
470
|
+
* @param messageId - message id of the notification
|
|
471
|
+
* @param type - integer value for status
|
|
472
|
+
* @param userId - single userid in string
|
|
473
|
+
* @callback will have the boolean
|
|
474
|
+
*/
|
|
475
|
+
@ReactMethod
|
|
476
|
+
public void updateInboxMessage(String messageId, int type, String userId, Callback callback) {
|
|
477
|
+
Context context = getReactApplicationContext();
|
|
478
|
+
try {
|
|
479
|
+
boolean isUpdated = ContextSdk.updatedInboxMessage(messageId, type, userId, context);
|
|
480
|
+
callback.invoke(isUpdated);
|
|
481
|
+
} catch (Throwable e) {
|
|
482
|
+
callback.invoke(e);
|
|
415
483
|
}
|
|
416
|
-
return array;
|
|
417
484
|
}
|
|
418
485
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
array.put(jsonArrayFromReadableArray(readableArray.getArray(i)));
|
|
439
|
-
break;
|
|
440
|
-
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* To sync with server if server will have any new data to update.
|
|
489
|
+
*
|
|
490
|
+
* @param timeout - integer value for status
|
|
491
|
+
* @callback will have the boolean
|
|
492
|
+
*/
|
|
493
|
+
@ReactMethod
|
|
494
|
+
public void synchronizeInbox(int timeout, final Callback callback) {
|
|
495
|
+
Context context = getReactApplicationContext();
|
|
496
|
+
try {
|
|
497
|
+
ContextSdk.synchronizeInbox(new IAppICESuccessCallback() {
|
|
498
|
+
@Override
|
|
499
|
+
public void callback(boolean isAppInboxRefreshed) {
|
|
500
|
+
callback.invoke(isAppInboxRefreshed);
|
|
501
|
+
}
|
|
502
|
+
}, timeout, context);
|
|
503
|
+
} catch (Throwable e) {
|
|
504
|
+
callback.invoke(e);
|
|
441
505
|
}
|
|
442
|
-
return array;
|
|
443
506
|
}
|
|
444
507
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
break;
|
|
460
|
-
case String:
|
|
461
|
-
object.put(key, readableMap.getString(key));
|
|
462
|
-
break;
|
|
463
|
-
case Map:
|
|
464
|
-
object.put(key, jsonObjectFromReadableMap(readableMap.getMap(key)));
|
|
465
|
-
break;
|
|
466
|
-
case Array:
|
|
467
|
-
object.put(key, jsonArrayFromReadableArray(readableMap.getArray(key)));
|
|
468
|
-
break;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
return object;
|
|
508
|
+
//===========================================
|
|
509
|
+
// Device Setting
|
|
510
|
+
//===========================================
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* To set the custom device_id.
|
|
514
|
+
*/
|
|
515
|
+
@ReactMethod
|
|
516
|
+
public void setInternalId(String deviceId) {
|
|
517
|
+
//TODO{ we can not call setDevice Id here because it
|
|
518
|
+
// will directly call start context with new device id
|
|
519
|
+
// but here we want to store the data only
|
|
520
|
+
// }
|
|
521
|
+
//ContextSdk.setInternalId();
|
|
472
522
|
}
|
|
473
523
|
|
|
474
524
|
/**
|
|
475
|
-
*
|
|
476
|
-
*
|
|
525
|
+
* To get the ad_id from sdk.
|
|
526
|
+
*
|
|
527
|
+
* @callback will have the string
|
|
477
528
|
*/
|
|
478
|
-
|
|
479
|
-
|
|
529
|
+
@ReactMethod
|
|
530
|
+
public void getDeviceId(Callback callback) {
|
|
531
|
+
Context context = getReactApplicationContext();
|
|
532
|
+
callback.invoke(ContextSdk.getInternalId(context));
|
|
533
|
+
}
|
|
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());
|
|
480
567
|
|
|
481
|
-
|
|
482
|
-
|
|
568
|
+
return constants;
|
|
569
|
+
}
|
|
483
570
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
props.put(key, propsMap.getString(key));
|
|
491
|
-
} else if (readableType == ReadableType.Boolean) {
|
|
492
|
-
props.put(key, propsMap.getBoolean(key));
|
|
493
|
-
} else if (readableType == ReadableType.Number) {
|
|
494
|
-
try {
|
|
495
|
-
props.put(key, propsMap.getDouble(key));
|
|
496
|
-
} catch (Throwable t) {
|
|
497
|
-
try {
|
|
498
|
-
props.put(key, propsMap.getInt(key));
|
|
499
|
-
} catch (Throwable t1) {
|
|
500
|
-
Log.d(TAG, "Unhandled ReadableType.Number from ReadableMap");
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
} else {
|
|
504
|
-
Log.d(TAG, "Unhandled event property ReadableType");
|
|
505
|
-
}
|
|
506
|
-
} catch (Throwable t) {
|
|
507
|
-
Log.d(TAG, t.getLocalizedMessage());
|
|
508
|
-
}
|
|
571
|
+
//=====================================
|
|
572
|
+
public static void sendEvent(String eventName, @Nullable WritableMap params) {
|
|
573
|
+
try {
|
|
574
|
+
context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
|
|
575
|
+
} catch (RuntimeException e) {
|
|
576
|
+
AppICEUtils.printLog(TAG, "java.lang.RuntimeException: Trying to invoke JS before CatalystInstance has been set!" + e);
|
|
509
577
|
}
|
|
510
|
-
return props;
|
|
511
578
|
}
|
|
512
|
-
}
|
|
579
|
+
}
|