reactnative-plugin-appice 1.6.7 → 1.6.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/android/build.gradle +1 -1
- package/android/src/main/java/com/reactlibrary/AppICEUtils.java +28 -3
- package/android/src/main/java/com/reactlibrary/AppIceReactPluginModule.java +127 -7
- package/android/src/main/java/com/reactlibrary/EnumConstants.java +9 -9
- package/android/src/main/java/com/reactlibrary/StringConstants.java +5 -0
- package/example/App.js +55 -2
- package/example/package.json +1 -1
- package/index.js +69 -2
- package/ios/AppIceReactPlugin.h +1 -0
- package/ios/AppIceReactPlugin.m +212 -10
- package/ios/AppIceReactPlugin.xcworkspace/xcuserdata/artherajesh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/package.json +1 -1
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.71'
|
|
118
118
|
//implementation files('libs/libsdk-release.aar')
|
|
119
119
|
|
|
120
120
|
//glide
|
|
@@ -12,6 +12,8 @@ import java.util.ArrayList;
|
|
|
12
12
|
import java.util.HashMap;
|
|
13
13
|
import java.util.Iterator;
|
|
14
14
|
import java.util.Map;
|
|
15
|
+
import org.json.JSONException;
|
|
16
|
+
import org.json.JSONObject;
|
|
15
17
|
|
|
16
18
|
import semusi.context.ui.appInbox.AppICEInboxMessage;
|
|
17
19
|
|
|
@@ -32,12 +34,35 @@ public class AppICEUtils {
|
|
|
32
34
|
inboxObject.putString(EnumConstants.INBOX_MESSAGE.getValue(), inboxMessage.getMessageBody());
|
|
33
35
|
inboxObject.putString(EnumConstants.INBOX_MESSAGE_ICON.getValue(), inboxMessage.getMessageIcon());
|
|
34
36
|
inboxObject.putMap(EnumConstants.INBOX_CUSTOM_DATA.getValue(), toWritableMap(inboxMessage.getCustomData()));
|
|
35
|
-
|
|
37
|
+
}
|
|
36
38
|
}catch (Throwable throwable){}
|
|
37
39
|
return inboxObject;
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
/**
|
|
42
|
+
* This method accept object of native User class (semusi.activitysdk.User)
|
|
43
|
+
* and convert to WritableMap for hybrid side
|
|
44
|
+
* @param user object of native User class
|
|
45
|
+
* @return WritableMap
|
|
46
|
+
*/
|
|
47
|
+
public static WritableMap convertUserClassToWritableMap(User user){
|
|
48
|
+
WritableMap userObject = Arguments.createMap();
|
|
49
|
+
try {
|
|
50
|
+
if (user != null) {
|
|
51
|
+
userObject.putString(EnumConstants.APPICE_USER_NAME.getValue(), user.getName());
|
|
52
|
+
userObject.putString(EnumConstants.APPICE_USER_PHONE.getValue(), user.getPhone());
|
|
53
|
+
userObject.putString(EnumConstants.APPICE_USER_EMAIL.getValue(), user.getEmail());
|
|
54
|
+
userObject.putDouble(EnumConstants.APPICE_DATE_OF_BIRTH.getValue(), user.getDob());
|
|
55
|
+
userObject.putInt(EnumConstants.APPICE_USER_AGE.getValue(), user.getAge());
|
|
56
|
+
userObject.putString(EnumConstants.APPICE_USER_EDUCATION.getValue(), user.getEducationType());
|
|
57
|
+
userObject.putString(EnumConstants.APPICE_USER_GENDER.getValue(), user.getGender());
|
|
58
|
+
userObject.putBoolean(EnumConstants.APPICE_USER_IS_EMPLOYED.getValue(), user.isEmployed());
|
|
59
|
+
userObject.putString(EnumConstants.APPICE_USER_EMPLOYMENT_TYPE.getValue(), user.getEmploymentType());
|
|
60
|
+
userObject.putBoolean(EnumConstants.APPICE_USER_MARRIED.getValue(), user.isMarried());
|
|
61
|
+
}
|
|
62
|
+
} catch (Throwable e) {
|
|
63
|
+
}
|
|
64
|
+
return userObject;
|
|
65
|
+
}
|
|
41
66
|
public static WritableMap toWritableMap(Map<String, Object> map) {
|
|
42
67
|
WritableMap writableMap = Arguments.createMap();
|
|
43
68
|
Iterator iterator = map.entrySet().iterator();
|
|
@@ -16,17 +16,12 @@ import com.facebook.react.bridge.ReactMethod;
|
|
|
16
16
|
import com.facebook.react.bridge.ReadableMap;
|
|
17
17
|
|
|
18
18
|
import android.os.Handler;
|
|
19
|
-
|
|
20
|
-
import java.util.HashMap;
|
|
21
|
-
import java.util.List;
|
|
22
|
-
|
|
23
19
|
import semusi.activitysdk.Api;
|
|
24
20
|
import semusi.activitysdk.ContextSdk;
|
|
25
21
|
import semusi.activitysdk.SdkConfig;
|
|
26
22
|
import semusi.activitysdk.User;
|
|
27
23
|
import semusi.context.ui.appInbox.AppICEInboxMessage;
|
|
28
24
|
import semusi.context.ui.appInbox.IAppICESuccessCallback;
|
|
29
|
-
|
|
30
25
|
import java.util.*;
|
|
31
26
|
|
|
32
27
|
import androidx.annotation.NonNull;
|
|
@@ -40,7 +35,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
|
40
35
|
public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
41
36
|
private static ReactApplicationContext context = null;
|
|
42
37
|
private static final String TAG = "AppIceReactPlugin";
|
|
43
|
-
|
|
38
|
+
|
|
44
39
|
public AppIceReactPluginModule(ReactApplicationContext reactContext) {
|
|
45
40
|
super(reactContext);
|
|
46
41
|
context = reactContext;
|
|
@@ -359,6 +354,83 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
359
354
|
Context context = getReactApplicationContext();
|
|
360
355
|
callback.invoke(ContextSdk.getUserId(context));
|
|
361
356
|
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Get appinbox cData through mediakey
|
|
360
|
+
* mediakey is a kind of key just like in json we find key value
|
|
361
|
+
* @param {inboxMessage} ReadableMap
|
|
362
|
+
* @param {String} mediakey : will get this key from cData json
|
|
363
|
+
* @Callback will recive Map<String, Object> object
|
|
364
|
+
*/
|
|
365
|
+
@ReactMethod
|
|
366
|
+
public void getMediaData(ReadableMap inboxMessage,String mediayKey,Callback callback) {
|
|
367
|
+
|
|
368
|
+
Context context = getReactApplicationContext();
|
|
369
|
+
AppICEInboxMessage inboxMessageInstance = AppICEInboxMessage.getAppICEInboxMessage(inboxMessage.toString(),context);
|
|
370
|
+
if (inboxMessageInstance != null) {
|
|
371
|
+
Map<String, Object> map = inboxMessageInstance.getMediaData(mediayKey);
|
|
372
|
+
if (map != null) {
|
|
373
|
+
callback.invoke(AppICEUtils.toWritableMap(map), null);
|
|
374
|
+
} else {
|
|
375
|
+
callback.invoke(null, StringConstants.FAILED_RETRIVE_MEDIA_DATA);
|
|
376
|
+
}
|
|
377
|
+
} else {
|
|
378
|
+
callback.invoke(null, StringConstants.INVALID_INBOX_FORMAT);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* To get Media URL from getMediaData
|
|
384
|
+
* inboxMessage {AppICEInboxMessage as a ReadableMap}
|
|
385
|
+
* mediaData customData
|
|
386
|
+
* @callback callback will receive mediaUrl{string}
|
|
387
|
+
*/
|
|
388
|
+
@ReactMethod
|
|
389
|
+
public void getMediaUrl(ReadableMap inboxMessage,ReadableMap mediaData,Callback callback) {
|
|
390
|
+
Context context = getReactApplicationContext();
|
|
391
|
+
AppICEInboxMessage inboxMessageInstance = AppICEInboxMessage.getAppICEInboxMessage(inboxMessage.toString(),context);
|
|
392
|
+
if(inboxMessageInstance != null){
|
|
393
|
+
String mediaUrl = inboxMessageInstance.getMediaUrl(AppICEUtils.eventPropsFromReadableMap(mediaData));
|
|
394
|
+
callback.invoke(mediaUrl, null);
|
|
395
|
+
} else{
|
|
396
|
+
callback.invoke(null, StringConstants.INVALID_INBOX_FORMAT);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* To get Media type from customdata
|
|
401
|
+
* inboxMessage {AppICEInboxMessage as a ReadableMap}
|
|
402
|
+
* mediaData customData : this we will recived from getmediadata callback
|
|
403
|
+
* @callback callback will receive mediaType{string}
|
|
404
|
+
*/
|
|
405
|
+
@ReactMethod
|
|
406
|
+
public void getMediaType(ReadableMap inboxMessage,ReadableMap mediaData,Callback callback) {
|
|
407
|
+
Context context = getReactApplicationContext();
|
|
408
|
+
AppICEInboxMessage inboxMessageInstance = AppICEInboxMessage.getAppICEInboxMessage(inboxMessage.toString(),context);
|
|
409
|
+
if(inboxMessageInstance != null){
|
|
410
|
+
String mediaType = inboxMessageInstance.getMediaType(AppICEUtils.eventPropsFromReadableMap(mediaData));
|
|
411
|
+
callback.invoke(mediaType, null);
|
|
412
|
+
} else{
|
|
413
|
+
callback.invoke(null, StringConstants.INVALID_INBOX_FORMAT);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* To get Media Thumbnail from customdata
|
|
418
|
+
* inboxMessage {AppICEInboxMessage as a ReadableMap}
|
|
419
|
+
* mediaData customData : this we will recived from getmediadata callback
|
|
420
|
+
* @callback callback will receive Thumbnail{string}
|
|
421
|
+
*/
|
|
422
|
+
@ReactMethod
|
|
423
|
+
public void getMediaThumbnail(ReadableMap inboxMessage,ReadableMap mediaData,Callback callback) {
|
|
424
|
+
Context context = getReactApplicationContext();
|
|
425
|
+
AppICEInboxMessage inboxMessageInstance = AppICEInboxMessage.getAppICEInboxMessage(inboxMessage.toString(),context);
|
|
426
|
+
if(inboxMessageInstance != null){
|
|
427
|
+
String mediaThumbnail = inboxMessageInstance.getMediaThumbnail(AppICEUtils.eventPropsFromReadableMap(mediaData));
|
|
428
|
+
callback.invoke(mediaThumbnail, null);
|
|
429
|
+
} else{
|
|
430
|
+
callback.invoke(null, StringConstants.INVALID_INBOX_FORMAT);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
362
434
|
|
|
363
435
|
//======================
|
|
364
436
|
// LISTENER
|
|
@@ -417,7 +489,51 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
417
489
|
callback.invoke(e);
|
|
418
490
|
}
|
|
419
491
|
}
|
|
420
|
-
|
|
492
|
+
/**
|
|
493
|
+
* This method is to get user details from the given user id
|
|
494
|
+
* this method takes user id in form of Array and return User class objects and return them
|
|
495
|
+
* from callback
|
|
496
|
+
* @param userIds An array of user IDs
|
|
497
|
+
* @param callback will return instance of User class
|
|
498
|
+
*/
|
|
499
|
+
@ReactMethod
|
|
500
|
+
public void getUser(ReadableArray userIds, Callback callback) {
|
|
501
|
+
Context context = getReactApplicationContext();
|
|
502
|
+
WritableArray writableArray = Arguments.createArray();
|
|
503
|
+
try {
|
|
504
|
+
// convert ReadableArray (Hybrid) to ArrayList<String> (Native)
|
|
505
|
+
ArrayList<String> finalValues = arrayListStringFromReadableArray(userIds);
|
|
506
|
+
// get list of user class object from native sdk
|
|
507
|
+
List<User> users = ContextSdk.getUser(finalValues,context);
|
|
508
|
+
for (int i = 0; i < users.size(); i++) {
|
|
509
|
+
User user = users.get(i);
|
|
510
|
+
// conver native object to WritableMap
|
|
511
|
+
writableArray.pushMap(AppICEUtils.convertUserClassToWritableMap(user));
|
|
512
|
+
}
|
|
513
|
+
// return callback
|
|
514
|
+
callback.invoke(writableArray);
|
|
515
|
+
} catch (Throwable e) {
|
|
516
|
+
callback.invoke(e);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* To sync up data with server
|
|
521
|
+
* callback will have boolean true or false
|
|
522
|
+
*/
|
|
523
|
+
@ReactMethod
|
|
524
|
+
public void synchronizeData(int timeout, Callback callback) {
|
|
525
|
+
Context context = getReactApplicationContext();
|
|
526
|
+
try {
|
|
527
|
+
ContextSdk.synchronizeData(new IAppICESuccessCallback(){
|
|
528
|
+
@Override
|
|
529
|
+
public void callback(boolean isDataRefreshed) {
|
|
530
|
+
callback.invoke(isDataRefreshed);
|
|
531
|
+
}
|
|
532
|
+
}, timeout, context);
|
|
533
|
+
} catch (Throwable e) {
|
|
534
|
+
callback.invoke(e);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
421
537
|
/**
|
|
422
538
|
* Get inbox messages count.
|
|
423
539
|
*
|
|
@@ -531,6 +647,10 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
531
647
|
Context context = getReactApplicationContext();
|
|
532
648
|
callback.invoke(ContextSdk.getInternalId(context));
|
|
533
649
|
}
|
|
650
|
+
@ReactMethod
|
|
651
|
+
public void isDeviceReady(Boolean flag){
|
|
652
|
+
|
|
653
|
+
}
|
|
534
654
|
|
|
535
655
|
@Nullable
|
|
536
656
|
@Override
|
|
@@ -8,16 +8,16 @@ public enum EnumConstants {
|
|
|
8
8
|
//=========================
|
|
9
9
|
//USER-PROFILE
|
|
10
10
|
//=========================
|
|
11
|
-
APPICE_USER_NAME("
|
|
12
|
-
APPICE_USER_PHONE("
|
|
13
|
-
APPICE_USER_EMAIL("
|
|
11
|
+
APPICE_USER_NAME("APPICE_USER_NAME"),
|
|
12
|
+
APPICE_USER_PHONE("APPICE_USER_PHONE"),
|
|
13
|
+
APPICE_USER_EMAIL("APPICE_USER_EMAIL"),
|
|
14
14
|
APPICE_DATE_OF_BIRTH("APPICE_DATE_OF_BIRTH"),
|
|
15
|
-
APPICE_USER_AGE("
|
|
16
|
-
APPICE_USER_EDUCATION("
|
|
17
|
-
APPICE_USER_GENDER("
|
|
18
|
-
APPICE_USER_IS_EMPLOYED("
|
|
19
|
-
APPICE_USER_EMPLOYMENT_TYPE ("
|
|
20
|
-
APPICE_USER_MARRIED("
|
|
15
|
+
APPICE_USER_AGE("APPICE_USER_AGE"),
|
|
16
|
+
APPICE_USER_EDUCATION("APPICE_USER_EDUCATION"),
|
|
17
|
+
APPICE_USER_GENDER("APPICE_USER_GENDER"),
|
|
18
|
+
APPICE_USER_IS_EMPLOYED("APPICE_USER_IS_EMPLOYED"),
|
|
19
|
+
APPICE_USER_EMPLOYMENT_TYPE ("APPICE_USER_EMPLOYMENT_TYPE"),
|
|
20
|
+
APPICE_USER_MARRIED("APPICE_USER_MARRIED"),
|
|
21
21
|
|
|
22
22
|
//===========================
|
|
23
23
|
//PUSH
|
package/example/App.js
CHANGED
|
@@ -13,7 +13,8 @@ import { Alert,
|
|
|
13
13
|
Image,
|
|
14
14
|
Linking,
|
|
15
15
|
Button,
|
|
16
|
-
|
|
16
|
+
AppState,
|
|
17
|
+
View
|
|
17
18
|
} from 'react-native';
|
|
18
19
|
|
|
19
20
|
const AppICE = require('reactnative-plugin-appice');
|
|
@@ -37,6 +38,17 @@ const HelloWorldApp = () => {
|
|
|
37
38
|
|
|
38
39
|
certs);
|
|
39
40
|
}
|
|
41
|
+
|
|
42
|
+
AppState.addEventListener('change', (nextAppState) => {
|
|
43
|
+
if (nextAppState === 'active') {
|
|
44
|
+
AppICE.isDeviceReady(true);
|
|
45
|
+
}
|
|
46
|
+
else if (nextAppState === 'background'){
|
|
47
|
+
// this state handle both backgroung and kill state
|
|
48
|
+
AppICE.isDeviceReady(false);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
40
52
|
addAppICEAPIListeners();
|
|
41
53
|
return (
|
|
42
54
|
<View
|
|
@@ -189,7 +201,26 @@ const userIds = ['1232323' , 'kuOEN8bCqdrROmJPVCeKSg=='];
|
|
|
189
201
|
const getInboxMessage = () => {
|
|
190
202
|
AppICE.getInboxMessages(type, userIds, (inboxMessages: any[]) => {
|
|
191
203
|
console.log('Received Inbox Messages:', inboxMessages);
|
|
192
|
-
|
|
204
|
+
|
|
205
|
+
inboxMessages.forEach((message) => {
|
|
206
|
+
const mediaKey = 'imageUrl';
|
|
207
|
+
AppICE.getMediaData(message, mediaKey, (mediaData: any) => {
|
|
208
|
+
console.log('Media Data:', mediaData);
|
|
209
|
+
|
|
210
|
+
AppICE.getMediaUrl(mediaData,(mediaUrl:any) => {
|
|
211
|
+
console.log('getMediaUrl is :', mediaUrl);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
AppICE.getMediaType(mediaData,(mediaType:any) => {
|
|
215
|
+
console.log('getmediaType is:', mediaType);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
AppICE.getMediaThumbnail(mediaData,(mediaThumbnail:any) => {
|
|
219
|
+
console.log('getMediaThumbnail is:', mediaThumbnail);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
});
|
|
193
224
|
}
|
|
194
225
|
|
|
195
226
|
const getMessageCount = () => {
|
|
@@ -233,4 +264,26 @@ const getMessageCount = () => {
|
|
|
233
264
|
});
|
|
234
265
|
}
|
|
235
266
|
|
|
267
|
+
const getUserData = () => {
|
|
268
|
+
AppICE.synchronizeData(10, (success: boolean) => {
|
|
269
|
+
console.log('Profile synchronization success:', success);
|
|
270
|
+
Alert.alert(`synchronizeData: \n ${success}`);
|
|
271
|
+
const userIds = ['160840156'];
|
|
272
|
+
AppICE.getUser(userIds, (res:any[]) => {
|
|
273
|
+
|
|
274
|
+
console.log('Receive getUser:', res);
|
|
275
|
+
for (var index = 0; index < res.length; index++) {
|
|
276
|
+
let userData = res[index];
|
|
277
|
+
console.log('Received getUser data:', userData);
|
|
278
|
+
const name = userData[AppICE.name];
|
|
279
|
+
const phone = userData[AppICE.phone];
|
|
280
|
+
console.log('GetUser Name:', name);
|
|
281
|
+
console.log('GetUser PHONE:', phone);
|
|
282
|
+
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
236
289
|
export default HelloWorldApp;
|
package/example/package.json
CHANGED
package/index.js
CHANGED
|
@@ -35,6 +35,8 @@ var AppICEReact = {
|
|
|
35
35
|
INBOX_CAMPAIGN_ID: AppIceReactPlugin.INBOX_CAMPAIGN_ID,
|
|
36
36
|
INBOX_MESSAGE_ICON: AppIceReactPlugin.INBOX_MESSAGE_ICON,
|
|
37
37
|
INBOX_CUSTOM_DATA: AppIceReactPlugin.INBOX_CUSTOM_DATA,
|
|
38
|
+
INBOX_MESSAGE_EXPANDED_IMAGE: AppIceReactPlugin.INBOX_MESSAGE_EXPANDED_IMAGE,
|
|
39
|
+
|
|
38
40
|
|
|
39
41
|
//=======================
|
|
40
42
|
// USER-PROFILE SETTING
|
|
@@ -304,10 +306,75 @@ var AppICEReact = {
|
|
|
304
306
|
|
|
305
307
|
synchronizeInbox: function (timeout, callback) {
|
|
306
308
|
callWithCallback('synchronizeInbox', [timeout], callback)
|
|
307
|
-
}
|
|
309
|
+
},
|
|
310
|
+
|
|
311
|
+
//===============================================
|
|
312
|
+
// Rich Push AppInbox
|
|
313
|
+
//===============================================
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* getMediaData
|
|
317
|
+
* @param instanceInboxMessage - instance Dictionary
|
|
318
|
+
* @param values - NSString
|
|
319
|
+
* @callback will have the Dictionary
|
|
320
|
+
*/
|
|
308
321
|
|
|
309
|
-
|
|
322
|
+
getMediaData: function (instanceInboxMessage, mediaKey, callback) {
|
|
323
|
+
callWithCallback('getMediaData', [instanceInboxMessage, mediaKey], callback);
|
|
324
|
+
},
|
|
310
325
|
|
|
326
|
+
/**
|
|
327
|
+
* getMediaUrl
|
|
328
|
+
* @param instanceInboxMessage - instance Dictionary
|
|
329
|
+
* @param values - Dictionary
|
|
330
|
+
* @callback will have the string
|
|
331
|
+
*/
|
|
332
|
+
getMediaUrl: function (instanceInboxMessage, values, callback) {
|
|
333
|
+
callWithCallback('getMediaUrl', [instanceInboxMessage, values], callback);
|
|
334
|
+
},
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* getMediaType
|
|
338
|
+
* @param instanceInboxMessage - instance Dictionary
|
|
339
|
+
* @param values - Dictionary
|
|
340
|
+
* @callback will have the string
|
|
341
|
+
*/
|
|
342
|
+
getMediaType: function (instanceInboxMessage, values, callback) {
|
|
343
|
+
callWithCallback('getMediaType', [instanceInboxMessage, values], callback);
|
|
344
|
+
},
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* getMediaThumbnail
|
|
348
|
+
* @param instanceInboxMessage - instance Dictionary
|
|
349
|
+
* @param values - Dictionary
|
|
350
|
+
* @callback will have the string
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
getMediaThumbnail: function (instanceInboxMessage, values, callback) {
|
|
354
|
+
callWithCallback('getMediaThumbnail', [instanceInboxMessage, values],callback);
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
/*==================
|
|
358
|
+
isDeviceReady
|
|
359
|
+
=====================*/
|
|
360
|
+
isDeviceReady: function(isActive) {
|
|
361
|
+
AppIceReactPlugin.isDeviceReady(isActive);
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
/*===============
|
|
365
|
+
synchronizeData
|
|
366
|
+
================*/
|
|
367
|
+
synchronizeData: function (timeout, callback) {
|
|
368
|
+
callWithCallback('synchronizeData',[timeout],callback)
|
|
369
|
+
},
|
|
370
|
+
|
|
371
|
+
/*===================
|
|
372
|
+
getUser with userIds
|
|
373
|
+
=====================*/
|
|
374
|
+
|
|
375
|
+
getUser: function (userIds, callback) {
|
|
376
|
+
callWithCallback('getUser', [userIds], callback);
|
|
377
|
+
},
|
|
311
378
|
};
|
|
312
379
|
//================================
|
|
313
380
|
// INTERNAL COMMON APIS
|
package/ios/AppIceReactPlugin.h
CHANGED
|
@@ -27,6 +27,7 @@ static NSString *const INBOX_CAMPAIGN_ID = @"INBOX_CAMPAIGN_ID";
|
|
|
27
27
|
static NSString *const INBOX_MESSAGE_CATEGORY = @"INBOX_MESSAGE_CATEGORY";
|
|
28
28
|
static NSString *const INBOX_MESSAGE_ICON = @"INBOX_MESSAGE_ICON";
|
|
29
29
|
static NSString *const INBOX_CUSTOM_DATA = @"INBOX_CUSTOM_DATA";
|
|
30
|
+
static NSString *const INBOX_MESSAGE_EXPANDED_IMAGE = @"INBOX_MESSAGE_EXPANDED_IMAGE";
|
|
30
31
|
|
|
31
32
|
// Custom data
|
|
32
33
|
static NSString *const DEMOGRAPHIC_INFO = @"DEMOGRAPHIC_INFO";
|
package/ios/AppIceReactPlugin.m
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
#import "React/RCTLog.h"
|
|
4
4
|
#import "appICE.h"
|
|
5
5
|
#import "appICEUserDetails.h"
|
|
6
|
+
#import "AppICEInboxMessage.h"
|
|
6
7
|
#import <UserNotifications/UserNotifications.h>
|
|
7
8
|
@implementation AppIceReactPlugin
|
|
8
9
|
|
|
10
|
+
static BOOL isAppInitialized = NO;
|
|
11
|
+
static NSDictionary *pendingDeeplink = nil;
|
|
12
|
+
|
|
9
13
|
RCT_EXPORT_MODULE()
|
|
10
14
|
+ (BOOL)requiresMainQueueSetup {
|
|
11
15
|
return NO;
|
|
@@ -50,6 +54,7 @@ RCT_EXPORT_MODULE()
|
|
|
50
54
|
INBOX_MESSAGE_CATEGORY : @"category",
|
|
51
55
|
INBOX_MESSAGE_ICON : @"icon",
|
|
52
56
|
INBOX_CUSTOM_DATA : @"cdata",
|
|
57
|
+
INBOX_MESSAGE_EXPANDED_IMAGE :@"eni",
|
|
53
58
|
|
|
54
59
|
DEMOGRAPHIC_INFO :@"customProperties",
|
|
55
60
|
@"TOP_N_PRODUCTS_VIEWED" : TOP_N_PRODUCTS_VIEWED,
|
|
@@ -226,9 +231,32 @@ RCT_EXPORT_METHOD(setUser:(NSDictionary*)userProfile)
|
|
|
226
231
|
|
|
227
232
|
}
|
|
228
233
|
|
|
234
|
+
/*===========================
|
|
235
|
+
PushNotificationClicked
|
|
236
|
+
* when Called ie. in Foreground and BG state isAppInitialized will be true and deeplink will be handled.
|
|
237
|
+
* when Called in killed state isAppInitialized will be false and deeplink is stored and will be handled after the App is initialized.
|
|
238
|
+
===========================*/
|
|
239
|
+
|
|
229
240
|
+ (void)pushNotificationClicked:(NSDictionary *)userInfo {
|
|
230
|
-
|
|
231
|
-
|
|
241
|
+
@try {
|
|
242
|
+
|
|
243
|
+
if (!isAppInitialized) {
|
|
244
|
+
RCTLog(@"Deeplink Push : not isAppInitialized" );
|
|
245
|
+
// App is not initialized, store the deeplink for later processing
|
|
246
|
+
[self storePendingDeeplink:userInfo];
|
|
247
|
+
} else {
|
|
248
|
+
// App is initialized, handle deeplinks in the click handler
|
|
249
|
+
RCTLog(@"Deeplink Push : pushNotificationClicked deeplink handled" );
|
|
250
|
+
[self storePendingDeeplink:userInfo];
|
|
251
|
+
[self processPendingDeeplink];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
NSDictionary *event = @{ kAppICEPushNotificationClicked : userInfo};
|
|
255
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:kAppICEPushNotificationClicked object:nil userInfo:event];
|
|
256
|
+
} @catch (NSException *exception) {
|
|
257
|
+
RCTLog(@"Deeplink Push : pushNotificationClicked exception %@",exception);
|
|
258
|
+
}
|
|
259
|
+
|
|
232
260
|
}
|
|
233
261
|
|
|
234
262
|
RCT_EXPORT_METHOD(inAppClicked:(NSDictionary*)userInfo)
|
|
@@ -236,6 +264,9 @@ RCT_EXPORT_METHOD(inAppClicked:(NSDictionary*)userInfo)
|
|
|
236
264
|
RCTLog(@"from inAppClicked method = %@",userInfo);
|
|
237
265
|
}
|
|
238
266
|
|
|
267
|
+
/*===========================
|
|
268
|
+
PushNotificationReceived
|
|
269
|
+
===========================*/
|
|
239
270
|
+ (void)pushNotificationReceived:(NSDictionary *)userInfo {
|
|
240
271
|
[[appICE sharedInstance]pushNotificationReceived:userInfo];
|
|
241
272
|
}
|
|
@@ -334,10 +365,10 @@ RCT_EXPORT_METHOD(getMessageCount:(int)type userId:(NSArray*)userId callback:(RC
|
|
|
334
365
|
* @param userId - single userid in string ie. "useridA"
|
|
335
366
|
* @callback will have the json object
|
|
336
367
|
*/
|
|
337
|
-
RCT_EXPORT_METHOD(getInboxMessageForId:(NSString*)messageId userId:(
|
|
368
|
+
RCT_EXPORT_METHOD(getInboxMessageForId:(NSString*)messageId userId:(NSString*)userId callback:(RCTResponseSenderBlock)callback)
|
|
338
369
|
{
|
|
339
370
|
|
|
340
|
-
AppICEInboxMessage *inboxMessageId = [[appICE sharedInstance] getInboxMessageForId:messageId
|
|
371
|
+
AppICEInboxMessage *inboxMessageId = [[appICE sharedInstance] getInboxMessageForId:messageId usrId:userId];
|
|
341
372
|
RCTLog(@"Inbox Messages id: %@", inboxMessageId);
|
|
342
373
|
NSDictionary *formattedMessageforId = [self formatInboxMessage:inboxMessageId];
|
|
343
374
|
RCTLog(@"Formatted Inbox Message id: %@", formattedMessageforId);
|
|
@@ -363,9 +394,7 @@ RCT_EXPORT_METHOD(updateInboxMessage:(NSString *)messageId type:(int)type userId
|
|
|
363
394
|
|
|
364
395
|
/**
|
|
365
396
|
* synchronizeInbox message Ttue or False.
|
|
366
|
-
* @param
|
|
367
|
-
* @param type - integer value for status
|
|
368
|
-
* @param userId - single userid in string
|
|
397
|
+
* @param timeout - integer value
|
|
369
398
|
* @callback will have the boolean
|
|
370
399
|
*/
|
|
371
400
|
RCT_EXPORT_METHOD(synchronizeInbox:(int)timeout callback:(RCTResponseSenderBlock)callback)
|
|
@@ -395,7 +424,8 @@ RCT_EXPORT_METHOD(synchronizeInbox:(int)timeout callback:(RCTResponseSenderBlock
|
|
|
395
424
|
@"campId": inboxMessage.messageCampid,
|
|
396
425
|
@"cdata": inboxMessage.customData,
|
|
397
426
|
@"messageExpiryTime": @(inboxMessage.messageExpiryTime),
|
|
398
|
-
@"campType": inboxMessage.campType
|
|
427
|
+
@"campType": inboxMessage.campType,
|
|
428
|
+
@"eni": inboxMessage.messageExpandedImage
|
|
399
429
|
};
|
|
400
430
|
} else {
|
|
401
431
|
return @{};
|
|
@@ -421,16 +451,188 @@ RCT_EXPORT_METHOD(registerLifeCycle) {
|
|
|
421
451
|
// implementation to register the lifecycle
|
|
422
452
|
}
|
|
423
453
|
|
|
454
|
+
# pragma RichPush AppInbox
|
|
455
|
+
/**
|
|
456
|
+
* getMediaData
|
|
457
|
+
* @param inboxMessageDict NSDictionary representing the inbox message data.
|
|
458
|
+
* @param mediaKey NSString representing the key to fetch media data from the inbox message.
|
|
459
|
+
* @param callback RCTResponseSenderBlock callback function to return the media data.
|
|
460
|
+
*/
|
|
461
|
+
|
|
462
|
+
RCT_EXPORT_METHOD(getMediaData:(NSDictionary *)inboxMessageDict mediaKey:(NSString *)mediaKey callback:(RCTResponseSenderBlock)callback)
|
|
463
|
+
{
|
|
464
|
+
AppICEInboxMessage *inboxMessageInstance = [AppICEInboxMessage instanceFromDictionary:inboxMessageDict];
|
|
465
|
+
if (!inboxMessageInstance) {
|
|
466
|
+
[self returnResult:@{} withCallback:callback andError:nil];
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
else{
|
|
470
|
+
NSDictionary *mediaData = [inboxMessageInstance mediaData:mediaKey];
|
|
471
|
+
if (mediaData) {
|
|
472
|
+
[self returnResult:mediaData withCallback:callback andError:nil];
|
|
473
|
+
} else {
|
|
474
|
+
[self returnResult:@{} withCallback:callback andError:nil];
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* getMediaUrl
|
|
481
|
+
* @param mediaData NSMutableDictionary get the mediaData Dictionary
|
|
482
|
+
* @param callback RCTResponseSenderBlock callback function to return the media data.
|
|
483
|
+
*/
|
|
484
|
+
RCT_EXPORT_METHOD(getMediaUrl:(NSDictionary *)inboxMessageDict mediaData:(NSDictionary*)mediaData callback:(RCTResponseSenderBlock)callback)
|
|
485
|
+
{
|
|
486
|
+
AppICEInboxMessage *inboxMessageInstance = [AppICEInboxMessage instanceFromDictionary:inboxMessageDict];
|
|
487
|
+
if (!inboxMessageInstance) {
|
|
488
|
+
[self returnResult:@{} withCallback:callback andError:nil];
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
NSString *mediaUrl = [inboxMessageInstance mediaUrl:mediaData];
|
|
492
|
+
[self returnResult:mediaUrl withCallback:callback andError:nil];
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* mediaType for AppInbox
|
|
497
|
+
* @param mediaData NSMutableDictionary get the mediaData Dictionary
|
|
498
|
+
* @callback mediaType as 'image' or 'animated' or 'video'
|
|
499
|
+
*/
|
|
500
|
+
RCT_EXPORT_METHOD(getMediaType:(NSDictionary *)inboxMessageDict mediaData:(NSDictionary*)mediaData callback:(RCTResponseSenderBlock)callback)
|
|
501
|
+
{
|
|
502
|
+
AppICEInboxMessage *inboxMessageInstance = [AppICEInboxMessage instanceFromDictionary:inboxMessageDict];
|
|
503
|
+
if (!inboxMessageInstance) {
|
|
504
|
+
[self returnResult:@{} withCallback:callback andError:nil];
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
NSString *mediaType = [inboxMessageInstance mediaType:mediaData];
|
|
508
|
+
[self returnResult:mediaType withCallback:callback andError:nil];
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* mediaThumbnail for AppInbox
|
|
513
|
+
* @param mediaData NSMutableDictionary get the mediaData Dictionary
|
|
514
|
+
* @callback mediaThumbnail as string
|
|
515
|
+
*/
|
|
516
|
+
RCT_EXPORT_METHOD(getMediaThumbnail:(NSDictionary *)inboxMessageDict mediaData:(NSDictionary*)mediaData callback:(RCTResponseSenderBlock)callback)
|
|
517
|
+
{
|
|
518
|
+
AppICEInboxMessage *inboxMessageInstance = [AppICEInboxMessage instanceFromDictionary:inboxMessageDict];
|
|
519
|
+
if (!inboxMessageInstance) {
|
|
520
|
+
[self returnResult:@{} withCallback:callback andError:nil];
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
NSString *mediaThumbnail = [inboxMessageInstance mediaThumbnail:mediaData];
|
|
524
|
+
[self returnResult:mediaThumbnail withCallback:callback andError:nil];
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
# pragma RichPush Push DeepLink Handling
|
|
528
|
+
|
|
529
|
+
/*----------------------------------------------------------------------------
|
|
530
|
+
storePendingDeeplink
|
|
531
|
+
* @param userInfo - NSDictionary
|
|
532
|
+
* Store the pending deeplink info in the static variable for later processing
|
|
533
|
+
-----------------------------------------------------------------------------*/
|
|
534
|
+
+ (void)storePendingDeeplink:(NSDictionary *)userInfo {
|
|
535
|
+
@try {
|
|
536
|
+
// Store the pending deeplink info in the static variable for later processing
|
|
537
|
+
pendingDeeplink = userInfo;
|
|
538
|
+
RCTLog(@"Deeplink Push : storePendingDeeplink called" );
|
|
539
|
+
} @catch (NSException *exception) {
|
|
540
|
+
RCTLog(@"Deeplink Push : storePendingDeeplink exception %@",exception);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/*----------------------------------------------------------------------------
|
|
545
|
+
processPendingDeeplink
|
|
546
|
+
* Process the pending deeplink if it exists and the app is initialized
|
|
547
|
+
* Clear the pending deeplink after processing
|
|
548
|
+
-----------------------------------------------------------------------------*/
|
|
549
|
+
+ (void)processPendingDeeplink {
|
|
550
|
+
@try {
|
|
551
|
+
|
|
552
|
+
RCTLog(@"Deeplink Push : processPendingDeeplink called isAppInitialized: %d , pendingDeeplink: %@",isAppInitialized,pendingDeeplink);
|
|
553
|
+
if (isAppInitialized && pendingDeeplink) {
|
|
554
|
+
RCTLog(@"Deeplink Push : handled in stored data");
|
|
555
|
+
[[appICE sharedInstance] handleClickOnPush:pendingDeeplink OpenDeepLink:YES];
|
|
556
|
+
pendingDeeplink = nil;
|
|
557
|
+
}
|
|
558
|
+
} @catch (NSException *exception) {
|
|
559
|
+
RCTLog(@"Deeplink Push : processPendingDeeplink exception %@",exception);
|
|
560
|
+
} @finally {
|
|
561
|
+
pendingDeeplink = nil;
|
|
562
|
+
RCTLog(@"Deeplink Push : finally processPendingDeeplink pendingDeeplink set as nil");
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/*------------------------------------------------------
|
|
568
|
+
isDeviceReady
|
|
569
|
+
* @param isDeviceReady - BOOL
|
|
570
|
+
* Set the flag to indicate that the app is initialized
|
|
571
|
+
* Process any pending deeplinks after initialization
|
|
572
|
+
------------------------------------------------------*/
|
|
573
|
+
RCT_EXPORT_METHOD(isDeviceReady: (BOOL)isActive)
|
|
574
|
+
{
|
|
575
|
+
|
|
576
|
+
RCTLog(@"Deeplink Push : isDeviceReady called state = %d",isActive );
|
|
577
|
+
if(isActive)
|
|
578
|
+
{
|
|
579
|
+
isAppInitialized = YES;
|
|
580
|
+
[AppIceReactPlugin processPendingDeeplink];
|
|
581
|
+
}
|
|
582
|
+
else
|
|
583
|
+
{
|
|
584
|
+
isAppInitialized = NO;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
#pragma GETUSER WITH ARRAY
|
|
589
|
+
|
|
590
|
+
/*--------------------------------------------
|
|
591
|
+
* synchronizeData message True or False.
|
|
592
|
+
* @param timeout as int
|
|
593
|
+
* @callback will have the boolean
|
|
594
|
+
---------------------------------------------*/
|
|
595
|
+
RCT_EXPORT_METHOD(synchronizeData:(int)timeout callback:(RCTResponseSenderBlock)callback)
|
|
596
|
+
{
|
|
597
|
+
// Save the callback for later use
|
|
598
|
+
RCTLog(@"GETUSER: synchronizeData");
|
|
599
|
+
[[appICE sharedInstance] synchronizeData:^(BOOL success) {
|
|
600
|
+
[self returnResult:@(success) withCallback:callback andError:nil];
|
|
601
|
+
}timeoutinSec:timeout];
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/*--------------------------------------------
|
|
605
|
+
* getUser with UserId
|
|
606
|
+
* userIds - NSArray
|
|
607
|
+
* @callback will have the boolean
|
|
608
|
+
---------------------------------------------*/
|
|
609
|
+
|
|
610
|
+
RCT_EXPORT_METHOD(getUser:(NSArray*)userIds callback:(RCTResponseSenderBlock)callback)
|
|
611
|
+
{
|
|
612
|
+
NSMutableArray *getUserArray =[[appICEUserDetails sharedUserDetails] getUser:userIds];
|
|
613
|
+
// Convert appICEUserDetails objects to dictionaries
|
|
614
|
+
|
|
615
|
+
NSMutableArray *formattedGetUser = [NSMutableArray array];
|
|
616
|
+
for (appICEUserDetails *getUserData in getUserArray) {
|
|
617
|
+
NSDictionary *formattedMessage = [getUserData toDictionary];
|
|
618
|
+
[formattedGetUser addObject:formattedMessage];
|
|
619
|
+
}
|
|
620
|
+
RCTLog(@"GETUSER: Formatted getUser Messages: %@", formattedGetUser);
|
|
621
|
+
[self returnResult:formattedGetUser withCallback:callback andError:nil];
|
|
622
|
+
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
|
|
424
626
|
|
|
425
627
|
- (void)returnResult:(id)result withCallback:(RCTResponseSenderBlock)callback andError:(NSString *)error {
|
|
426
628
|
|
|
427
629
|
if (callback == nil) {
|
|
428
|
-
RCTLog(@"callback was nil");
|
|
630
|
+
RCTLog(@"AppICE:callback was nil");
|
|
429
631
|
return;
|
|
430
632
|
}
|
|
431
633
|
// id e = error != nil ? error : [NSNull null];
|
|
432
634
|
id r = result != nil ? result : [NSNull null];
|
|
433
|
-
RCTLog(@"
|
|
635
|
+
RCTLog(@"AppICE: result: %@",r);
|
|
434
636
|
callback(@[r]);
|
|
435
637
|
}
|
|
436
638
|
|
|
Binary file
|