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/index.js CHANGED
@@ -3,18 +3,42 @@ import { Platform, Component } from 'react-native';
3
3
 
4
4
  const AppIceReactPlugin = NativeModules.AppIceReactPlugin;
5
5
  var eventEmitter;
6
-
7
- if(Platform.OS === 'ios')
8
- {
6
+ if (Platform.OS === 'ios') {
9
7
  eventEmitter = NativeModules.AppICEReactEvent ? new NativeEventEmitter(NativeModules.AppICEReactEvent) : DeviceEventEmitter;
10
8
  }
11
- else
12
- {
13
- eventEmitter = new NativeEventEmitter(NativeModules.AppIceReactPlugin);
9
+ else {
10
+ eventEmitter = new NativeEventEmitter(NativeModules.AppIceReactPlugin);
14
11
  }
15
12
  var AppICEReact = {
13
+
14
+ validateIntegration: AppIceReactPlugin.validateIntegration,
15
+
16
+ //========================
17
+ // PUSH
18
+ //========================
16
19
  AppICEPushNotificationClicked: AppIceReactPlugin.AppICEPushNotificationClicked,
20
+
21
+ //==========================
22
+ // IN-APP
23
+ //==========================
17
24
  AppICEInAppClicked: AppIceReactPlugin.AppICEInAppClicked,
25
+
26
+ //========================
27
+ // APP-INBOX
28
+ //========================
29
+ INBOX_MESSAGE: AppIceReactPlugin.INBOX_MESSAGE,
30
+ INBOX_TITLE: AppIceReactPlugin.INBOX_TITLE,
31
+ INBOX_MESSAGE_STATUS: AppIceReactPlugin.INBOX_MESSAGE_STATUS,
32
+ INBOX_CAMPAIGN_TYPE: AppIceReactPlugin.INBOX_CAMPAIGN_TYPE,
33
+ INBOX_MESSAGE_LANGUAGE: AppIceReactPlugin.INBOX_MESSAGE_LANGUAGE,
34
+ INBOX_MESSAGE_ID: AppIceReactPlugin.INBOX_MESSAGE_ID,
35
+ INBOX_CAMPAIGN_ID: AppIceReactPlugin.INBOX_CAMPAIGN_ID,
36
+ INBOX_MESSAGE_ICON: AppIceReactPlugin.INBOX_MESSAGE_ICON,
37
+ INBOX_CUSTOM_DATA: AppIceReactPlugin.INBOX_CUSTOM_DATA,
38
+
39
+ //=======================
40
+ // USER-PROFILE SETTING
41
+ //=======================
18
42
  name: AppIceReactPlugin.n,
19
43
  email: AppIceReactPlugin.em,
20
44
  phone: AppIceReactPlugin.ph,
@@ -24,15 +48,43 @@ var AppICEReact = {
24
48
  employmentType: AppIceReactPlugin.et,
25
49
  married: AppIceReactPlugin.m,
26
50
  isEmployed: AppIceReactPlugin.is_emp,
27
- validateIntegration: AppIceReactPlugin.validateIntegration,
28
51
 
29
52
 
30
- /**
31
- * add all of the registered listeners for given eventName.
32
- *
33
- * @param {string} eventName - name of the event whose registered listeners to remove
34
- * @param {callback} handler - handler for events
35
- */
53
+ TOP_N_PRODUCTS_VIEWED: AppIceReactPlugin.TOP_N_PRODUCTS_VIEWED,
54
+ N_COMPLAINTS_RAISED: AppIceReactPlugin.N_COMPLAINTS_RAISED,
55
+ PREF_LOGIN_DEVICE: AppIceReactPlugin.PREF_LOGIN_DEVICE,
56
+ REFERRAL_CAMPAIGN: AppIceReactPlugin.REFERRAL_CAMPAIGN,
57
+ FIRST_SEEN: AppIceReactPlugin.FIRST_SEEN,
58
+ LAST_SEEN: AppIceReactPlugin.LAST_SEEN,
59
+ DEMOGRAPHIC_INFO: AppIceReactPlugin.DEMOGRAPHIC_INFO,
60
+
61
+ //================
62
+ // ECOMMERCE
63
+ //================
64
+ TOTAL_ORDER_VALUE: AppIceReactPlugin.TOTAL_ORDER_VALUE,
65
+ ADD_TO_CART_N_DAYS: AppIceReactPlugin.ADD_TO_CART_N_DAYS,
66
+
67
+ //====================
68
+ // FinancialServices
69
+ //====================
70
+ FINANCIAL_SERVICES: AppIceReactPlugin.FINANCIAL_SERVICES,
71
+ CREDIT_SCORE: AppIceReactPlugin.CREDIT_SCORE,
72
+ DEBT_TO_INCOME_RATIO: AppIceReactPlugin.DEBT_TO_INCOME_RATIO,
73
+ SAVINGS_BALANCE: AppIceReactPlugin.SAVINGS_BALANCE,
74
+ CHECKING_BALANCE: AppIceReactPlugin.CHECKING_BALANCE,
75
+ AVERAGE_TRANSACTION_AMOUNT: AppIceReactPlugin.AVERAGE_TRANSACTION_AMOUNT,
76
+ FREQUENCY_OF_TRANSACTION: AppIceReactPlugin.FREQUENCY_OF_TRANSACTION,
77
+ TYPE_OF_TRANSACTION: AppIceReactPlugin.TYPE_OF_TRANSACTION,
78
+
79
+ //======================
80
+ // LISTENER
81
+ //======================
82
+ /**
83
+ * add all of the registered listeners for given eventName.
84
+ *
85
+ * @param {string} eventName - name of the event whose registered listeners to remove
86
+ * @param {callback} handler - handler for events
87
+ */
36
88
  addListener: function (eventName, handler) {
37
89
  if (eventEmitter) {
38
90
  eventEmitter.addListener(eventName, handler);
@@ -50,7 +102,23 @@ var AppICEReact = {
50
102
  }
51
103
  },
52
104
 
53
- /**
105
+
106
+ //=========================
107
+ // SDK CONFIG
108
+ //========================
109
+
110
+ /**
111
+ * call this function before clearing old data from db/keychain
112
+ */
113
+ preInitialise: function () {
114
+ this.getDeviceId((res) => {
115
+ if (res) {
116
+ this.setInternalId(res);
117
+ }
118
+ });
119
+ },
120
+
121
+ /**
54
122
  * Meta data of the apps that is needed for sdk setting
55
123
  * @param {string} appID - meta key
56
124
  * @param {string} appKey - meta key
@@ -62,19 +130,26 @@ var AppICEReact = {
62
130
  * startContext executes after getDeviceId callback
63
131
  * if res exist assign the value of res else assign deviceID
64
132
  */
65
- startContext: function (appID, appKey, apiKey, deviceID, region, baseUrl, certs){
66
- this.getDeviceId(( res ) =>
67
- {
68
- if(res){
69
- console.log('Res variable'+res);
133
+ startContext: function (appID, appKey, apiKey, deviceID, region, baseUrl, certs) {
134
+ this.getDeviceId((res) => {
135
+ if (res) {
70
136
  AppIceReactPlugin.startContext(appID, appKey, apiKey, res, region, baseUrl, certs)
71
- }else{
72
- console.log('deviceID variable'+deviceID);
137
+ } else {
73
138
  AppIceReactPlugin.startContext(appID, appKey, apiKey, deviceID, region, baseUrl, certs)
74
139
  }
75
140
  });
76
141
  },
77
142
 
143
+ /**
144
+ * call this function to register the lifeCycle state of the app
145
+ */
146
+ registerLifeCycle: function () {
147
+ AppIceReactPlugin.registerLifeCycle();
148
+ },
149
+
150
+ //===========================
151
+ // EVENTS AND VARIABLES
152
+ //===========================
78
153
  /**
79
154
  * Record an event with optional event properties
80
155
  * @param {string} eventName - the name of the event
@@ -85,33 +160,56 @@ var AppICEReact = {
85
160
  AppIceReactPlugin.tagEvent(eventName, props);
86
161
  },
87
162
 
88
- /**
89
- * Record an click event
90
- * @param {string} eventName - the name of the event
163
+ /**
164
+ * to store custom varibles like fcm token..
165
+ * @param {string} eventName - the name of the event
166
+ * @param {string} props - the name of the event
91
167
  */
92
- pushNotificationClicked: function (payload) {
93
- AppIceReactPlugin.pushNotificationClicked(payload);
168
+ setCustomVariable: function (eventName, props) {
169
+ AppIceReactPlugin.setCustomVariable(eventName, props);
94
170
  },
95
171
 
172
+
173
+ //===========================
174
+ // CAMPAIGN SETTING
175
+ //===========================
96
176
  /**
97
- * to store custom varibles like fcm token..
177
+ * Record an click event
98
178
  * @param {string} eventName - the name of the event
99
- * @param {string} props - the name of the event
100
179
  */
101
- setCustomVariable: function (eventName, props) {
102
- AppIceReactPlugin.setCustomVariable(eventName, props);
180
+ pushNotificationClicked: function (payload) {
181
+ AppIceReactPlugin.pushNotificationClicked(payload);
103
182
  },
104
183
 
184
+ getCustomDataFromPayload: function (object) {
185
+ let userObj = JSON.parse(object, (key, value) => {
186
+ return value;
187
+ });
188
+
189
+ let map = new Map(Object.entries(userObj.cdata));
105
190
 
191
+ return map;
192
+ },
193
+
194
+ //=======================
195
+ // USER-PROFILE SETTING
196
+ //=======================
106
197
  /**
107
198
  * Set key-value properties on a user profile
108
199
  * @param {object} profile - key-value profile properties. keys are strings and values can be string, number or boolean.
109
200
  */
110
201
  setUser: function (profile) {
111
- console.log(profile);
112
202
  AppIceReactPlugin.setUser(profile);
113
203
  },
114
204
 
205
+ /**
206
+ * get the properties of a user profile
207
+ * return JSONObject
208
+ */
209
+ getUser: function (callback) {
210
+ callWithCallback('getUser', null, callback);
211
+ },
212
+
115
213
  //===============================================
116
214
  // User id setting
117
215
  //===============================================
@@ -128,52 +226,94 @@ var AppICEReact = {
128
226
  * Getuser id
129
227
  * @param {object} values - array of userids
130
228
  */
131
- getUserId: function(callback){
132
- callWithCallback ('getUserId', null, callback);
229
+ getUserId: function (callback) {
230
+ callWithCallback('getUserId', null, callback);
133
231
  },
134
232
 
135
- getCustomDataFromPayload: function (object) {
136
- let userObj = JSON.parse(object, (key, value) => {
137
- return value;
138
- });
139
-
140
- let map = new Map(Object.entries(userObj.cdata));
233
+ //===============================================
234
+ // Device id setting
235
+ //===============================================
141
236
 
142
- return map;
237
+ getDeviceId: function (callback) {
238
+ callWithCallback('getDeviceId', null, callback)
143
239
  },
144
240
 
145
- /**
146
- * call this function before clearing old data from db/keychain
147
- */
148
- preInitialise: function(){
149
-
150
- this.getDeviceId(( res ) =>
151
- {
152
-
153
- if(res){
154
- console.log('setInternalId');
155
- this.setInternalId(res);
156
- }
157
- });
241
+ setInternalId: function (deviceId) {
242
+ AppIceReactPlugin.setInternalId(deviceId);
158
243
  },
159
244
 
160
245
  //===============================================
161
- // Device id setting
246
+ // AppInbox
162
247
  //===============================================
163
248
 
164
- getDeviceId: function(callback){
165
- callWithCallback ('getDeviceId', null, callback)
249
+ /**
250
+ * Get inbox messages list.
251
+ *
252
+ * @param type the message type
253
+ * 1 = ALL
254
+ * 2 = UNREAD
255
+ * 3 = READ
256
+ * 4 = VIEWED
257
+ * 5 = DELETED
258
+ * @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
259
+ * @callback will have the string json array
260
+ */
261
+ getInboxMessages: function (type, userIds, callback) {
262
+ callWithCallback('getInboxMessages', [type, userIds], callback);
263
+ },
264
+
166
265
 
266
+ /**
267
+ * Get inbox messages count.
268
+ *
269
+ * @param type the message type is integer
270
+ * 1 = ALL
271
+ * 2 = UNREAD
272
+ * 3 = READ
273
+ * 4 = VIEWED
274
+ * 5 = DELETED
275
+ * @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
276
+ * @callback will have the integer
277
+ */
278
+ getMessageCount: function (type, userIds, callback) {
279
+ callWithCallback('getMessageCount', [type, userIds], callback);
167
280
  },
168
281
 
169
- setInternalId: function (deviceId){
170
- AppIceReactPlugin.setInternalId(deviceId);
282
+ /**
283
+ * Get messages payload based on message id.
284
+ *
285
+ * @param messageId - message id of the notification
286
+ * @param userId - single userid in string ie. "useridA"
287
+ * @callback will have the json object
288
+ */
289
+ getInboxMessageForId: function (messageId, userId, callback) {
290
+ callWithCallback('getMessageCount', [messageId, userId], callback);
171
291
  },
172
-
173
- };
174
292
 
293
+ /**
294
+ * update message status ex. UNREAD to READ.
295
+ *
296
+ * @param messageId - message id of the notification
297
+ * @param type - integer value for status
298
+ * @param userId - single userid in string
299
+ * @callback will have the boolean
300
+ */
301
+ updateInboxMessage: function (messageId, type, userId, callback) {
302
+ callWithCallback('updateInboxMessage', [messageId, type, userId], callback);
303
+ },
304
+
305
+ synchronizeInbox: function (timeout, callback) {
306
+ callWithCallback('synchronizeInbox', [timeout], callback)
307
+ }
308
+
309
+ //========================================
310
+
311
+ };
312
+ //================================
313
+ // INTERNAL COMMON APIS
314
+ //=================================
175
315
  // internal function for callback
176
- function callWithCallback(method, args, callback) {
316
+ function callWithCallback(method, args, callback) {
177
317
  if (typeof callback === 'undefined' || callback == null || typeof callback !== 'function') {
178
318
  callback = (err, res) => {
179
319
  defaultCallback(method, err, res);
@@ -13,6 +13,42 @@ static NSString *const ket = @"et";
13
13
  static NSString *const km = @"m";
14
14
  static NSString *const kis_emp = @"is_emp";
15
15
  static NSString *const kappICEToken = @"appICEToken";
16
+ static NSString *const kdob = @"d";
17
+
18
+
19
+
20
+ static NSString *const INBOX_MESSAGE = @"INBOX_MESSAGE";
21
+ static NSString *const INBOX_TITLE = @"INBOX_TITLE";
22
+ static NSString *const INBOX_MESSAGE_STATUS = @"INBOX_MESSAGE_STATUS";
23
+ static NSString *const INBOX_CAMPAIGN_TYPE = @"INBOX_CAMPAIGN_TYPE";
24
+ static NSString *const INBOX_MESSAGE_LANGUAGE = @"INBOX_MESSAGE_LANGUAGE";
25
+ static NSString *const INBOX_MESSAGE_ID = @"INBOX_MESSAGE_ID";
26
+ static NSString *const INBOX_CAMPAIGN_ID = @"INBOX_CAMPAIGN_ID";
27
+ static NSString *const INBOX_MESSAGE_CATEGORY = @"INBOX_MESSAGE_CATEGORY";
28
+ static NSString *const INBOX_MESSAGE_ICON = @"INBOX_MESSAGE_ICON";
29
+ static NSString *const INBOX_CUSTOM_DATA = @"INBOX_CUSTOM_DATA";
30
+
31
+ // Custom data
32
+ static NSString *const DEMOGRAPHIC_INFO = @"DEMOGRAPHIC_INFO";
33
+ static NSString *TOP_N_PRODUCTS_VIEWED;
34
+ static NSString *N_COMPLAINTS_RAISED;
35
+ static NSString *PREF_LOGIN_DEVICE;
36
+ static NSString *REFERRAL_CAMPAIGN;
37
+ static NSString *FIRST_SEEN;
38
+ static NSString *LAST_SEEN;
39
+
40
+ // Ecommerce
41
+ static NSString *TOTAL_ORDER_VALUE;
42
+ static NSString *ADD_TO_CART_N_DAYS;
43
+
44
+ // Financial Services
45
+ static NSString *CREDIT_SCORE;
46
+ static NSString *DEBT_TO_INCOME_RATIO;
47
+ static NSString *SAVINGS_BALANCE;
48
+ static NSString *CHECKING_BALANCE;
49
+ static NSString *AVERAGE_TRANSACTION_AMOUNT;
50
+ static NSString *FREQUENCY_OF_TRANSACTION;
51
+ static NSString *TYPE_OF_TRANSACTION;
16
52
 
17
53
  @interface AppIceReactPlugin : NSObject <RCTBridgeModule,UNUserNotificationCenterDelegate>
18
54
  +(void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken;
@@ -12,6 +12,21 @@ RCT_EXPORT_MODULE()
12
12
  }
13
13
 
14
14
  - (NSDictionary *)constantsToExport {
15
+ FIRST_SEEN = CustomUserPropertyConstants.FIRST_SEEN;
16
+ LAST_SEEN = CustomUserPropertyConstants.LAST_SEEN;
17
+ TOP_N_PRODUCTS_VIEWED = CustomUserPropertyConstants.TOP_N_PRODUCTS_VIEWED;
18
+ N_COMPLAINTS_RAISED = CustomUserPropertyConstants.N_COMPLAINTS_RAISED;
19
+ PREF_LOGIN_DEVICE = CustomUserPropertyConstants.PREF_LOGIN_DEVICE;
20
+ REFERRAL_CAMPAIGN = CustomUserPropertyConstants.REFERRAL_CAMPAIGN;
21
+ TOTAL_ORDER_VALUE = Ecommerce.TOTAL_ORDER_VALUE;
22
+ ADD_TO_CART_N_DAYS = Ecommerce.ADD_TO_CART_N_DAYS;
23
+ CREDIT_SCORE = FinancialServices.CREDIT_SCORE;
24
+ DEBT_TO_INCOME_RATIO = FinancialServices.DEBT_TO_INCOME_RATIO;
25
+ SAVINGS_BALANCE = FinancialServices.SAVINGS_BALANCE;
26
+ CHECKING_BALANCE = FinancialServices.CHECKING_BALANCE;
27
+ AVERAGE_TRANSACTION_AMOUNT = FinancialServices.AVERAGE_TRANSACTION_AMOUNT;
28
+ FREQUENCY_OF_TRANSACTION = FinancialServices.FREQUENCY_OF_TRANSACTION;
29
+ TYPE_OF_TRANSACTION = FinancialServices.TYPE_OF_TRANSACTION;
15
30
  return @{
16
31
  kAppICEPushNotificationClicked : kAppICEPushNotificationClicked,
17
32
  kAppICEInAppClicked : kAppICEInAppClicked,
@@ -23,7 +38,37 @@ RCT_EXPORT_MODULE()
23
38
  ked : @"edt",
24
39
  ket : @"emt",
25
40
  km : km,
26
- kis_emp : @"em"
41
+ kis_emp : @"em",
42
+
43
+ INBOX_MESSAGE : @"message",
44
+ INBOX_TITLE : @"title",
45
+ INBOX_MESSAGE_STATUS : @"messageStatus",
46
+ INBOX_CAMPAIGN_TYPE : @"campType",
47
+ INBOX_MESSAGE_LANGUAGE : @"messageLanguage",
48
+ INBOX_MESSAGE_ID : @"id",
49
+ INBOX_CAMPAIGN_ID : @"campId",
50
+ INBOX_MESSAGE_CATEGORY : @"category",
51
+ INBOX_MESSAGE_ICON : @"icon",
52
+ INBOX_CUSTOM_DATA : @"cdata",
53
+
54
+ DEMOGRAPHIC_INFO :@"customProperties",
55
+ @"TOP_N_PRODUCTS_VIEWED" : TOP_N_PRODUCTS_VIEWED,
56
+ @"N_COMPLAINTS_RAISED" : N_COMPLAINTS_RAISED,
57
+ @"PREF_LOGIN_DEVICE" : PREF_LOGIN_DEVICE,
58
+ @"REFERRAL_CAMPAIGN" : REFERRAL_CAMPAIGN,
59
+ @"FIRST_SEEN" : FIRST_SEEN,
60
+ @"LAST_SEEN" : LAST_SEEN,
61
+
62
+ @"TOTAL_ORDER_VALUE" : TOTAL_ORDER_VALUE,
63
+ @"ADD_TO_CART_N_DAYS" : ADD_TO_CART_N_DAYS,
64
+
65
+ @"CREDIT_SCORE" : CREDIT_SCORE,
66
+ @"DEBT_TO_INCOME_RATIO" : DEBT_TO_INCOME_RATIO,
67
+ @"SAVINGS_BALANCE" : SAVINGS_BALANCE,
68
+ @"CHECKING_BALANCE" : CHECKING_BALANCE,
69
+ @"AVERAGE_TRANSACTION_AMOUNT" : AVERAGE_TRANSACTION_AMOUNT,
70
+ @"FREQUENCY_OF_TRANSACTION": FREQUENCY_OF_TRANSACTION,
71
+ @"TYPE_OF_TRANSACTION" : TYPE_OF_TRANSACTION
27
72
  };
28
73
  }
29
74
  - (dispatch_queue_t)methodQueue {
@@ -233,5 +278,161 @@ RCT_EXPORT_METHOD(getDeviceId:(RCTResponseSenderBlock)callback)
233
278
  }
234
279
  }
235
280
 
281
+ /**
282
+ * Get inbox messages list.
283
+ * @param type the message type
284
+ * 1 = ALL
285
+ * 2 = UNREAD
286
+ * 3 = READ
287
+ * 4 = VIEWED
288
+ * 5 = DELETED
289
+ * @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
290
+ * @callback will have the string json array
291
+ */
292
+
293
+ RCT_EXPORT_METHOD(getInboxMessages:(int)type userId:(NSArray*)userIds callback:(RCTResponseSenderBlock)callback)
294
+ {
295
+ NSMutableArray *inboxMessagesArray = [[appICE sharedInstance] getInboxMessages:type userId:userIds];
296
+ // Convert AppICEInboxMessage objects to dictionaries
297
+
298
+ NSMutableArray *formattedinboxMessages = [NSMutableArray array];
299
+ for (AppICEInboxMessage *inboxMessage in inboxMessagesArray) {
300
+ NSDictionary *formattedMessage = [self formatInboxMessage:inboxMessage];
301
+ [formattedinboxMessages addObject:formattedMessage];
302
+ }
303
+ RCTLog(@"Formatted Inbox Messages: %@", formattedinboxMessages);
304
+ [self returnResult:formattedinboxMessages withCallback:callback andError:nil];
305
+
306
+ }
307
+
308
+ /**
309
+ ---------------
310
+ APPINBOX
311
+ ---------------
312
+ * Get inbox messages count.
313
+ * @param type the message type
314
+ * 1 = ALL
315
+ * 2 = UNREAD
316
+ * 3 = READ
317
+ * 4 = VIEWED
318
+ * 5 = DELETED
319
+ * @param userIds the same way we are passing the value in setUserId same value we need here. ie. [ "useridA" ]
320
+ * @callback will have the integer
321
+ */
322
+
323
+ RCT_EXPORT_METHOD(getMessageCount:(int)type userId:(NSArray*)userId callback:(RCTResponseSenderBlock)callback)
324
+ {
325
+ int inboxMessageCount = [[appICE sharedInstance] getMessageCount:type userId:userId];
326
+ RCTLog(@"Inbox Messages Count: %d", inboxMessageCount);
327
+
328
+ [self returnResult:@(inboxMessageCount) withCallback:callback andError:nil];
329
+ }
330
+
331
+ /**
332
+ * Get messages payload based on message id.
333
+ * @param messageId - message id of the notification
334
+ * @param userId - single userid in string ie. "useridA"
335
+ * @callback will have the json object
336
+ */
337
+ RCT_EXPORT_METHOD(getInboxMessageForId:(NSString*)messageId userId:(NSArray*)userId callback:(RCTResponseSenderBlock)callback)
338
+ {
339
+
340
+ AppICEInboxMessage *inboxMessageId = [[appICE sharedInstance] getInboxMessageForId:messageId userId:userId];
341
+ RCTLog(@"Inbox Messages id: %@", inboxMessageId);
342
+ NSDictionary *formattedMessageforId = [self formatInboxMessage:inboxMessageId];
343
+ RCTLog(@"Formatted Inbox Message id: %@", formattedMessageforId);
344
+
345
+ [self returnResult:formattedMessageforId withCallback:callback andError:nil];
346
+ }
347
+
348
+ /**
349
+ * update message status ex. UNREAD to READ.
350
+ * @param messageId - message id of the notification
351
+ * @param type - integer value for status
352
+ * @param userId - single userid in string
353
+ * @callback will have the boolean
354
+ */
355
+
356
+ RCT_EXPORT_METHOD(updateInboxMessage:(NSString *)messageId type:(int)type userId:(NSString *)userId callback:(RCTResponseSenderBlock)callback)
357
+ {
358
+ BOOL isSuccess = [[appICE sharedInstance] updateInboxMessage:type messageId:messageId userid:userId];
359
+ RCTLog(@"Update Inbox Message Success: %@", isSuccess ? @"YES" : @"NO");
360
+
361
+ [self returnResult:@(isSuccess) withCallback:callback andError:nil];
362
+ }
363
+
364
+ /**
365
+ * synchronizeInbox message Ttue or False.
366
+ * @param messageId - message id of the notification
367
+ * @param type - integer value for status
368
+ * @param userId - single userid in string
369
+ * @callback will have the boolean
370
+ */
371
+ RCT_EXPORT_METHOD(synchronizeInbox:(int)timeout callback:(RCTResponseSenderBlock)callback)
372
+ {
373
+ // Save the callback for later use
374
+ RCTLog(@"synchronizeInbox");
375
+
376
+ [[appICE sharedInstance] synchronizeInbox:^(BOOL success) {
377
+
378
+ [self returnResult:@(success) withCallback:callback andError:nil];
379
+
380
+ } timeoutinSec:timeout];
381
+
382
+ }
383
+
384
+ // Add a method to format AppICEInboxMessage to a dictionary
385
+ - (NSDictionary *)formatInboxMessage:(AppICEInboxMessage *)inboxMessage {
386
+ if (inboxMessage) {
387
+ return @{
388
+ @"messageId": inboxMessage.messageId,
389
+ @"id": inboxMessage.messageMid,
390
+ @"icon": inboxMessage.messageImage,
391
+ @"message": inboxMessage.messageBody,
392
+ @"title": inboxMessage.messageTitle,
393
+ @"messageStatus": inboxMessage.messageStatus,
394
+ @"messageLanguage": inboxMessage.messageLanguage,
395
+ @"campId": inboxMessage.messageCampid,
396
+ @"cdata": inboxMessage.customData,
397
+ @"messageExpiryTime": @(inboxMessage.messageExpiryTime),
398
+ @"campType": inboxMessage.campType
399
+ };
400
+ } else {
401
+ return @{};
402
+ }
403
+ }
404
+ /**
405
+ * GetUser Details
406
+ * @callback will have the dictionary
407
+ */
408
+ RCT_EXPORT_METHOD(getUser:(RCTResponseSenderBlock)callback)
409
+ {
410
+ appICEUserDetails *app = [[appICE sharedInstance] getUserDetail];
411
+ NSDictionary *userDictionary = [app toDictionary];
412
+ NSLog(@"getUserDetails: %@", userDictionary);
413
+ [self returnResult:userDictionary withCallback:callback andError:nil];
414
+ }
415
+
416
+ /**
417
+ * RegisterLifeCycle
418
+ */
419
+ RCT_EXPORT_METHOD(registerLifeCycle) {
420
+
421
+ // implementation to register the lifecycle
422
+ }
423
+
424
+
425
+ - (void)returnResult:(id)result withCallback:(RCTResponseSenderBlock)callback andError:(NSString *)error {
426
+
427
+ if (callback == nil) {
428
+ RCTLog(@"callback was nil");
429
+ return;
430
+ }
431
+ // id e = error != nil ? error : [NSNull null];
432
+ id r = result != nil ? result : [NSNull null];
433
+ RCTLog(@"r: %@",r);
434
+ callback(@[r]);
435
+ }
436
+
236
437
  @end
237
438
 
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>AppIceReactPlugin.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>1</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>Pods-AppIceReactPlugin.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactnative-plugin-appice",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "description": "appICE React Native SDK",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -1,5 +0,0 @@
1
- package com.reactlibrary;
2
-
3
- public interface ClickCallback {
4
- void clickPayload(String obj);
5
- }