reactnative-plugin-appice 1.7.18 → 1.7.20
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 +37 -0
- package/android/src/main/java/com/reactlibrary/AppIceReactPluginModule.java +29 -1
- package/android/src/main/java/com/reactlibrary/EnumConstants.java +24 -1
- package/campaign.js +26 -0
- package/example/App.js +43 -6
- package/example/package.json +1 -1
- package/index.js +62 -1
- package/ios/AppIceReactPlugin.h +6 -0
- package/ios/AppIceReactPlugin.m +42 -2
- package/package.json +2 -1
package/android/build.gradle
CHANGED
|
@@ -113,7 +113,7 @@ dependencies {
|
|
|
113
113
|
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.3.1"
|
|
114
114
|
|
|
115
115
|
//appice
|
|
116
|
-
implementation 'appice.io.android:sdk:2.5.
|
|
116
|
+
implementation 'appice.io.android:sdk:2.5.85'
|
|
117
117
|
|
|
118
118
|
//glide
|
|
119
119
|
implementation "com.github.bumptech.glide:glide:4.11.0"
|
|
@@ -22,6 +22,8 @@ import org.json.JSONObject;
|
|
|
22
22
|
import semusi.context.ui.appInbox.AppICEInboxMessage;
|
|
23
23
|
import semusi.activitysdk.User;
|
|
24
24
|
|
|
25
|
+
import semusi.nativedisplay.Campaign;
|
|
26
|
+
|
|
25
27
|
public class AppICEUtils {
|
|
26
28
|
private static final String TAG = "AppICEUtils";
|
|
27
29
|
|
|
@@ -45,6 +47,38 @@ public class AppICEUtils {
|
|
|
45
47
|
return inboxObject;
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
/**
|
|
51
|
+
* This method accept object of native Campaign class (semusi.nativedisplay.Campaign)
|
|
52
|
+
* and convert to WritableMap for hybrid side
|
|
53
|
+
*
|
|
54
|
+
* @param campaign object of native Campaign class
|
|
55
|
+
* @return WritableMap
|
|
56
|
+
*/
|
|
57
|
+
public static WritableMap convertClassToWritableMap(Campaign campaign) {
|
|
58
|
+
WritableMap campaignMap = Arguments.createMap();
|
|
59
|
+
try {
|
|
60
|
+
if (campaign != null) {
|
|
61
|
+
campaignMap.putString(EnumConstants.CAMP_ID.getValue(), campaign.getCampId());
|
|
62
|
+
campaignMap.putString(EnumConstants.ACTION_URL.getValue(), campaign.getActionUrl());
|
|
63
|
+
campaignMap.putString(EnumConstants.ACTION_TYPE.getValue(), campaign.getActionType());
|
|
64
|
+
|
|
65
|
+
JSONObject cdata = campaign.getcustomData();
|
|
66
|
+
Map<String, Object> customDataMap = new HashMap<>();
|
|
67
|
+
Iterator<String> keys = cdata.keys();
|
|
68
|
+
|
|
69
|
+
while (keys.hasNext()) {
|
|
70
|
+
String key = keys.next();
|
|
71
|
+
customDataMap.put(key, cdata.getString(key));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
campaignMap.putMap(EnumConstants.CUSTOMDATA.getValue(), toWritableMap(customDataMap));
|
|
75
|
+
}
|
|
76
|
+
} catch (Throwable e) {
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
return campaignMap;
|
|
80
|
+
}
|
|
81
|
+
|
|
48
82
|
/**
|
|
49
83
|
* This method accept object of native User class (semusi.activitysdk.User)
|
|
50
84
|
* and convert to WritableMap for hybrid side
|
|
@@ -75,6 +109,8 @@ public class AppICEUtils {
|
|
|
75
109
|
return userObject;
|
|
76
110
|
}
|
|
77
111
|
|
|
112
|
+
|
|
113
|
+
|
|
78
114
|
public static WritableMap toWritableMap(Map<String, Object> map) {
|
|
79
115
|
WritableMap writableMap = Arguments.createMap();
|
|
80
116
|
Iterator iterator = map.entrySet().iterator();
|
|
@@ -239,4 +275,5 @@ public class AppICEUtils {
|
|
|
239
275
|
public static void printLog(String TAG, String message) {
|
|
240
276
|
System.out.println(TAG + ", " + message);
|
|
241
277
|
}
|
|
278
|
+
|
|
242
279
|
}
|
|
@@ -42,6 +42,8 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
|
42
42
|
import org.json.JSONException;
|
|
43
43
|
import org.json.JSONObject;
|
|
44
44
|
|
|
45
|
+
import semusi.nativedisplay.Campaign;
|
|
46
|
+
|
|
45
47
|
public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
46
48
|
private static ReactApplicationContext context = null;
|
|
47
49
|
private static final String TAG = "AppIceReactPlugin";
|
|
@@ -171,7 +173,6 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
171
173
|
}
|
|
172
174
|
}
|
|
173
175
|
|
|
174
|
-
|
|
175
176
|
@ReactMethod
|
|
176
177
|
public void setCustomVariable(String eventName, String value) {
|
|
177
178
|
Context context = getReactApplicationContext();
|
|
@@ -672,6 +673,10 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
672
673
|
constants.put(EnumConstants.AVERAGE_TRANSACTION_AMOUNT.getConstants(), EnumConstants.AVERAGE_TRANSACTION_AMOUNT.getValue());
|
|
673
674
|
constants.put(EnumConstants.FREQUENCY_OF_TRANSACTION.getConstants(), EnumConstants.FREQUENCY_OF_TRANSACTION.getValue());
|
|
674
675
|
constants.put(EnumConstants.TYPE_OF_TRANSACTION.getConstants(), EnumConstants.TYPE_OF_TRANSACTION.getValue());
|
|
676
|
+
constants.put(EnumConstants.CAMP_ID.getConstants(), EnumConstants.CAMP_ID.getValue());
|
|
677
|
+
constants.put(EnumConstants.ACTION_URL.getConstants(), EnumConstants.ACTION_URL.getValue());
|
|
678
|
+
constants.put(EnumConstants.ACTION_TYPE.getConstants(), EnumConstants.ACTION_TYPE.getValue());
|
|
679
|
+
constants.put(EnumConstants.CUSTOMDATA.getConstants(), EnumConstants.CUSTOMDATA.getValue());
|
|
675
680
|
|
|
676
681
|
return constants;
|
|
677
682
|
}
|
|
@@ -744,6 +749,29 @@ public class AppIceReactPluginModule extends ReactContextBaseJavaModule {
|
|
|
744
749
|
}else {
|
|
745
750
|
callback.invoke(null, StringConstants.INVALID_INBOX_FORMAT);
|
|
746
751
|
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
@ReactMethod
|
|
755
|
+
public void getCampaigns(String type, Callback callback) {
|
|
756
|
+
Context context = getReactApplicationContext();
|
|
757
|
+
WritableArray writableArray = Arguments.createArray();
|
|
758
|
+
try{
|
|
759
|
+
List<Campaign> campaigns = ContextSdk.getCampaigns(type, context);
|
|
760
|
+
for (int i = 0; i < campaigns.size(); i++) {
|
|
761
|
+
Campaign campaign = campaigns.get(i);
|
|
762
|
+
writableArray.pushMap(AppICEUtils.convertClassToWritableMap(campaign));
|
|
763
|
+
}
|
|
764
|
+
callback.invoke(writableArray);
|
|
765
|
+
}
|
|
766
|
+
catch(Throwable e){
|
|
767
|
+
callback.invoke(e.getMessage());
|
|
768
|
+
}
|
|
769
|
+
}
|
|
747
770
|
|
|
771
|
+
@ReactMethod
|
|
772
|
+
public void getCampaignById(String cmpId,Callback callback) {
|
|
773
|
+
Context context = getReactApplicationContext();
|
|
774
|
+
Campaign campaign = ContextSdk.getCampaignById(cmpId, context);
|
|
775
|
+
callback.invoke(AppICEUtils.convertClassToWritableMap(campaign));
|
|
748
776
|
}
|
|
749
777
|
}
|
|
@@ -4,6 +4,7 @@ import semusi.context.utility.AppICEConstants;
|
|
|
4
4
|
import semusi.activitysdk.CustomUserPropertyConstants;
|
|
5
5
|
import semusi.activitysdk.Ecommerce;
|
|
6
6
|
import semusi.activitysdk.FinancialServices;
|
|
7
|
+
import semusi.nativedisplay.Campaign;
|
|
7
8
|
//Common place for constant and SDK constants
|
|
8
9
|
public enum EnumConstants {
|
|
9
10
|
|
|
@@ -76,8 +77,17 @@ public enum EnumConstants {
|
|
|
76
77
|
CHECKING_BALANCE("CHECKING_BALANCE"),
|
|
77
78
|
AVERAGE_TRANSACTION_AMOUNT("AVERAGE_TRANSACTION_AMOUNT"),
|
|
78
79
|
FREQUENCY_OF_TRANSACTION("FREQUENCY_OF_TRANSACTION"),
|
|
79
|
-
TYPE_OF_TRANSACTION("TYPE_OF_TRANSACTION")
|
|
80
|
+
TYPE_OF_TRANSACTION("TYPE_OF_TRANSACTION"),
|
|
80
81
|
|
|
82
|
+
|
|
83
|
+
//====================
|
|
84
|
+
// CampaignData
|
|
85
|
+
//====================
|
|
86
|
+
CAMP_ID("CAMP_ID"),
|
|
87
|
+
ACTION_URL("ACTION_URL"),
|
|
88
|
+
ACTION_TYPE("ACTION_TYPE"),
|
|
89
|
+
CUSTOMDATA("CUSTOMDATA");
|
|
90
|
+
|
|
81
91
|
private String constants;
|
|
82
92
|
|
|
83
93
|
EnumConstants(String constants) {
|
|
@@ -249,6 +259,19 @@ public enum EnumConstants {
|
|
|
249
259
|
case "TYPE_OF_TRANSACTION":{
|
|
250
260
|
return FinancialServices.TYPE_OF_TRANSACTION;
|
|
251
261
|
}
|
|
262
|
+
|
|
263
|
+
case "CAMP_ID":{
|
|
264
|
+
return Campaign.CAMP_ID;
|
|
265
|
+
}
|
|
266
|
+
case "ACTION_URL":{
|
|
267
|
+
return Campaign.ACTION_URL;
|
|
268
|
+
}
|
|
269
|
+
case "ACTION_TYPE":{
|
|
270
|
+
return Campaign.ACTION_TYPE;
|
|
271
|
+
}
|
|
272
|
+
case "CUSTOMDATA":{
|
|
273
|
+
return Campaign.CUSTOMDATA;
|
|
274
|
+
}
|
|
252
275
|
default:
|
|
253
276
|
return "";
|
|
254
277
|
}
|
package/campaign.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
export default class Campaign {
|
|
3
|
+
constructor(campId, actionUrl, actionType, customData) {
|
|
4
|
+
this._campId = campId;
|
|
5
|
+
this._actionUrl = actionUrl;
|
|
6
|
+
this._actionType = actionType;
|
|
7
|
+
this._customData = customData;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Getter methods for campaign properties
|
|
11
|
+
getCampaignId() {
|
|
12
|
+
return this._campId;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getActionUrl() {
|
|
16
|
+
return this._actionUrl;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getActionType() {
|
|
20
|
+
return this._actionType;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getCustomData() {
|
|
24
|
+
return this._customData;
|
|
25
|
+
}
|
|
26
|
+
}
|
package/example/App.js
CHANGED
|
@@ -30,13 +30,13 @@ const HelloWorldApp = () => {
|
|
|
30
30
|
AppICE.preInitialise();
|
|
31
31
|
console.log('preInitialize completed');
|
|
32
32
|
|
|
33
|
-
AppICE.startContext(
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
33
|
+
AppICE.startContext( //keys here
|
|
34
|
+
"",
|
|
35
|
+
"",
|
|
36
|
+
"",
|
|
37
|
+
"",
|
|
38
|
+
"",
|
|
37
39
|
"",
|
|
38
|
-
"US",
|
|
39
|
-
"https://a.appice.io",
|
|
40
40
|
certs
|
|
41
41
|
);
|
|
42
42
|
|
|
@@ -78,6 +78,8 @@ const HelloWorldApp = () => {
|
|
|
78
78
|
<Button onPress={synchronizeInbox} title="synchronizeInbox" color="#841584" />
|
|
79
79
|
<Button onPress={getUserDetails} title="getUserDetails" color="#841584" />
|
|
80
80
|
<Button onPress={getUserData} title="getUserData" color="#841584" />
|
|
81
|
+
<Button onPress={getCampaignById} title="getCampaignById" color="#841584" />
|
|
82
|
+
<Button onPress={getCampaigns} title="getCampaigns" color="#841584" />
|
|
81
83
|
|
|
82
84
|
</View>
|
|
83
85
|
);
|
|
@@ -115,6 +117,8 @@ function addAppICEAPIListeners() {
|
|
|
115
117
|
},
|
|
116
118
|
);
|
|
117
119
|
}
|
|
120
|
+
|
|
121
|
+
|
|
118
122
|
const sendEvent = () => {
|
|
119
123
|
console.log('inside sendEvent');
|
|
120
124
|
var dataObj = {
|
|
@@ -291,5 +295,38 @@ const getUserData = () => {
|
|
|
291
295
|
AppICE.tagEvent(event, segment, flush)
|
|
292
296
|
}
|
|
293
297
|
|
|
298
|
+
// getCampaigns
|
|
299
|
+
|
|
300
|
+
const getCampaigns = () => {
|
|
301
|
+
|
|
302
|
+
const type = AppICE.CampaignType.NATIVE;
|
|
303
|
+
|
|
304
|
+
AppICE.getCampaigns(type, (campaigns: any[]) => {
|
|
305
|
+
console.log('Campaigns:', campaigns);
|
|
306
|
+
|
|
307
|
+
campaigns.forEach((campaign) => {
|
|
308
|
+
|
|
309
|
+
console.log('getCampaigns of Campaign ID:', campaign.getCampaignId());
|
|
310
|
+
console.log('Action URL is :', campaign.getActionUrl());
|
|
311
|
+
console.log('Action Type is :', campaign.getActionType());
|
|
312
|
+
console.log('Custom Data is :', campaign.getCustomData());
|
|
313
|
+
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
const getCampaignById = () => {
|
|
319
|
+
|
|
320
|
+
const cmpId = '1234';
|
|
321
|
+
AppICE.getCampaignById(cmpId, (campaign: any) => {
|
|
322
|
+
|
|
323
|
+
console.log('getCampaignById of Campaign ID:', campaign.getCampaignId());
|
|
324
|
+
console.log('Action URL is :', campaign.getActionUrl());
|
|
325
|
+
console.log('Action Type is :', campaign.getActionType());
|
|
326
|
+
console.log('Custom Data is :', campaign.getCustomData());
|
|
327
|
+
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
|
|
294
331
|
|
|
295
332
|
export default HelloWorldApp;
|
package/example/package.json
CHANGED
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { DeviceEventEmitter, NativeEventEmitter, NativeModules } from 'react-nat
|
|
|
2
2
|
import { Platform, Component } from 'react-native';
|
|
3
3
|
// import { MMKV } from 'react-native-mmkv'
|
|
4
4
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
5
|
+
import Campaign from './campaign';
|
|
5
6
|
|
|
6
7
|
const AppIceReactPlugin = NativeModules.AppIceReactPlugin;
|
|
7
8
|
var eventEmitter;
|
|
@@ -19,6 +20,17 @@ else {
|
|
|
19
20
|
const EVENT_KEY = "lastEvent"
|
|
20
21
|
const LAST_EVENT_KEY = "event_"
|
|
21
22
|
|
|
23
|
+
export const CAMP_ID = AppIceReactPlugin.CAMP_ID;
|
|
24
|
+
export const ACTION_URL = AppIceReactPlugin.ACTION_URL;
|
|
25
|
+
export const ACTION_TYPE = AppIceReactPlugin.ACTION_TYPE;
|
|
26
|
+
export const CUSTOMDATA = AppIceReactPlugin.CUSTOMDATA;
|
|
27
|
+
|
|
28
|
+
const CampaignType = {
|
|
29
|
+
NATIVE: 'NATIVE',
|
|
30
|
+
INAPP: 'INAPP',
|
|
31
|
+
PUSH: 'PUSH',
|
|
32
|
+
};
|
|
33
|
+
|
|
22
34
|
|
|
23
35
|
var AppICEReact = {
|
|
24
36
|
|
|
@@ -89,6 +101,7 @@ var AppICEReact = {
|
|
|
89
101
|
AVERAGE_TRANSACTION_AMOUNT: AppIceReactPlugin.AVERAGE_TRANSACTION_AMOUNT,
|
|
90
102
|
FREQUENCY_OF_TRANSACTION: AppIceReactPlugin.FREQUENCY_OF_TRANSACTION,
|
|
91
103
|
TYPE_OF_TRANSACTION: AppIceReactPlugin.TYPE_OF_TRANSACTION,
|
|
104
|
+
|
|
92
105
|
|
|
93
106
|
//======================
|
|
94
107
|
// LISTENER
|
|
@@ -224,7 +237,6 @@ var AppICEReact = {
|
|
|
224
237
|
AppIceReactPlugin.setCustomVariable(eventName, props);
|
|
225
238
|
},
|
|
226
239
|
|
|
227
|
-
|
|
228
240
|
//===========================
|
|
229
241
|
// CAMPAIGN SETTING
|
|
230
242
|
//===========================
|
|
@@ -428,7 +440,56 @@ var AppICEReact = {
|
|
|
428
440
|
getUserForIds: function (userIds, callback) {
|
|
429
441
|
callWithCallback('getUserForIds', [userIds], callback);
|
|
430
442
|
},
|
|
443
|
+
|
|
444
|
+
/*===================
|
|
445
|
+
GetCampaign
|
|
446
|
+
=====================*/
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* getCampaigns
|
|
450
|
+
* @param campType - string
|
|
451
|
+
* @callback - Return array of Campaign objects
|
|
452
|
+
*/
|
|
453
|
+
|
|
454
|
+
getCampaigns: function (campType, callback) {
|
|
455
|
+
AppIceReactPlugin.getCampaigns(campType, (campaignArray) => {
|
|
456
|
+
const campaigns = campaignArray.map(
|
|
457
|
+
(campaignData) =>
|
|
458
|
+
new Campaign(
|
|
459
|
+
campaignData[CAMP_ID],
|
|
460
|
+
campaignData[ACTION_URL],
|
|
461
|
+
campaignData[ACTION_TYPE],
|
|
462
|
+
campaignData[CUSTOMDATA]
|
|
463
|
+
)
|
|
464
|
+
);
|
|
465
|
+
callback(campaigns);
|
|
466
|
+
});
|
|
467
|
+
},
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* getCampaignById
|
|
473
|
+
* @param campId - string
|
|
474
|
+
* @callback -Return a single Campaign object
|
|
475
|
+
*/
|
|
476
|
+
|
|
477
|
+
getCampaignById: function (campId, callback) {
|
|
478
|
+
AppIceReactPlugin.getCampaignById(campId, (campaignData) => {
|
|
479
|
+
const getCampaign = new Campaign(
|
|
480
|
+
campaignData[CAMP_ID],
|
|
481
|
+
campaignData[ACTION_URL],
|
|
482
|
+
campaignData[ACTION_TYPE],
|
|
483
|
+
campaignData[CUSTOMDATA]
|
|
484
|
+
);
|
|
485
|
+
callback(getCampaign);
|
|
486
|
+
});
|
|
487
|
+
},
|
|
488
|
+
|
|
489
|
+
//campaign enum
|
|
490
|
+
CampaignType,
|
|
431
491
|
};
|
|
492
|
+
|
|
432
493
|
|
|
433
494
|
|
|
434
495
|
//================================
|
package/ios/AppIceReactPlugin.h
CHANGED
|
@@ -29,6 +29,12 @@ static NSString *const INBOX_MESSAGE_ICON = @"INBOX_MESSAGE_ICON";
|
|
|
29
29
|
static NSString *const INBOX_CUSTOM_DATA = @"INBOX_CUSTOM_DATA";
|
|
30
30
|
static NSString *const INBOX_MESSAGE_EXPANDED_IMAGE = @"INBOX_MESSAGE_EXPANDED_IMAGE";
|
|
31
31
|
|
|
32
|
+
//CAMPAIGN
|
|
33
|
+
static NSString *const CAMP_ID = @"CAMP_ID";
|
|
34
|
+
static NSString *const ACTION_URL = @"ACTION_URL";
|
|
35
|
+
static NSString *const ACTION_TYPE = @"ACTION_TYPE";
|
|
36
|
+
static NSString *const CUSTOMDATA = @"CUSTOMDATA";
|
|
37
|
+
|
|
32
38
|
// Custom data
|
|
33
39
|
static NSString *const DEMOGRAPHIC_INFO = @"DEMOGRAPHIC_INFO";
|
|
34
40
|
static NSString *TOP_N_PRODUCTS_VIEWED;
|
package/ios/AppIceReactPlugin.m
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#import "appICEUserDetails.h"
|
|
6
6
|
#import "AppICEInboxMessage.h"
|
|
7
7
|
#import <UserNotifications/UserNotifications.h>
|
|
8
|
+
#import "Campaign.h"
|
|
8
9
|
@implementation AppIceReactPlugin
|
|
9
10
|
|
|
10
11
|
static BOOL isAppInitialized = NO;
|
|
@@ -74,7 +75,11 @@ RCT_EXPORT_MODULE()
|
|
|
74
75
|
@"CHECKING_BALANCE" : CHECKING_BALANCE,
|
|
75
76
|
@"AVERAGE_TRANSACTION_AMOUNT" : AVERAGE_TRANSACTION_AMOUNT,
|
|
76
77
|
@"FREQUENCY_OF_TRANSACTION": FREQUENCY_OF_TRANSACTION,
|
|
77
|
-
@"TYPE_OF_TRANSACTION" : TYPE_OF_TRANSACTION
|
|
78
|
+
@"TYPE_OF_TRANSACTION" : TYPE_OF_TRANSACTION,
|
|
79
|
+
CAMP_ID : @"campId",
|
|
80
|
+
ACTION_URL : @"actionUrl",
|
|
81
|
+
ACTION_TYPE: @"actionType",
|
|
82
|
+
CUSTOMDATA : @"customData"
|
|
78
83
|
};
|
|
79
84
|
}
|
|
80
85
|
- (dispatch_queue_t)methodQueue {
|
|
@@ -607,7 +612,7 @@ RCT_EXPORT_METHOD(synchronizeData:(int)timeout callback:(RCTResponseSenderBlock)
|
|
|
607
612
|
/*--------------------------------------------
|
|
608
613
|
* getUserForIds with UserId
|
|
609
614
|
* userIds - NSArray
|
|
610
|
-
* @callback will have the
|
|
615
|
+
* @callback will have the NSMutableArray
|
|
611
616
|
---------------------------------------------*/
|
|
612
617
|
|
|
613
618
|
RCT_EXPORT_METHOD(getUserForIds:(NSArray*)userIds callback:(RCTResponseSenderBlock)callback)
|
|
@@ -625,6 +630,41 @@ RCT_EXPORT_METHOD(getUserForIds:(NSArray*)userIds callback:(RCTResponseSenderBlo
|
|
|
625
630
|
|
|
626
631
|
}
|
|
627
632
|
|
|
633
|
+
/*--------------------------------------------
|
|
634
|
+
* getCampaigns with CampignType
|
|
635
|
+
* type - NSString
|
|
636
|
+
* @callback will have the Array
|
|
637
|
+
---------------------------------------------*/
|
|
638
|
+
|
|
639
|
+
RCT_EXPORT_METHOD(getCampaigns:(NSString *)type callback:(RCTResponseSenderBlock)callback)
|
|
640
|
+
{
|
|
641
|
+
NSMutableArray<Campaign *> *campaigns = [[appICE sharedInstance] getCampaigns:type];
|
|
642
|
+
|
|
643
|
+
NSMutableArray *formattedCampaigns = [NSMutableArray array];
|
|
644
|
+
|
|
645
|
+
for (Campaign *campaign in campaigns) {
|
|
646
|
+
NSDictionary *formatedCampaign = [Campaign formatcampaign:campaign];
|
|
647
|
+
NSLog(@"Campaign: Formatted getCampaigns: %@", formatedCampaign);
|
|
648
|
+
[formattedCampaigns addObject:formatedCampaign];
|
|
649
|
+
}
|
|
650
|
+
[self returnResult:formattedCampaigns withCallback:callback andError:nil];
|
|
651
|
+
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/*--------------------------------------------
|
|
655
|
+
* getCampaignById with campID
|
|
656
|
+
* campID - NSString
|
|
657
|
+
* @callback will have the Dictionary
|
|
658
|
+
---------------------------------------------*/
|
|
659
|
+
|
|
660
|
+
RCT_EXPORT_METHOD(getCampaignById:(NSString *)campID callback:(RCTResponseSenderBlock)callback)
|
|
661
|
+
{
|
|
662
|
+
|
|
663
|
+
Campaign *campaign = [[appICE sharedInstance] getCampaignById:campID];
|
|
664
|
+
|
|
665
|
+
NSDictionary *formatedCampaign = [Campaign formatcampaign:campaign];
|
|
666
|
+
[self returnResult:formatedCampaign withCallback:callback andError:nil];
|
|
667
|
+
}
|
|
628
668
|
|
|
629
669
|
|
|
630
670
|
- (void)returnResult:(id)result withCallback:(RCTResponseSenderBlock)callback andError:(NSString *)error {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reactnative-plugin-appice",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.20",
|
|
4
4
|
"description": "appICE React Native SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"example",
|
|
9
9
|
"android",
|
|
10
10
|
"index.js",
|
|
11
|
+
"campaign.js",
|
|
11
12
|
"ios",
|
|
12
13
|
"reactnative-plugin-appice.podspec"
|
|
13
14
|
],
|