reactnative-plugin-appice 1.7.10 → 1.7.12

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/example/App.js CHANGED
@@ -9,272 +9,230 @@
9
9
  import React from 'react';
10
10
  import { Alert,
11
11
  Text,
12
- Platform,
13
- Image,
14
- Linking,
15
12
  Button,
16
- AppState,
17
- View
13
+ View,
14
+ AppState
18
15
  } from 'react-native';
19
-
16
+
17
+ import { getInboxMessages, getMessageCounts, setUser, updatedInboxMessage } from './ancilliary';
20
18
  const AppICE = require('reactnative-plugin-appice');
21
19
  const HelloWorldApp = () => {
22
- const certs = [];
20
+ const certs: never[] = [];
23
21
  if (AppICE) {
24
22
  console.log('AppICE is available');
23
+ AppICE.preInitialise();
24
+ console.log('preInitialize completed');
25
+
25
26
  AppICE.startContext(
26
- // '5bebe93c25d705690ffbc758',
27
- // '9e9ec60197c8373a11ac15ce4dae80e973608ab2',
28
- // 'd985715d1bb48942d36d5d08de3b6a8c',
29
- // '7a55ba2f-52c3-4d88-917d-0365e2f7c9cf',
30
- // "US",
31
- // "https://stagingapi.appice.io",
32
- "5bebe93c25d705690ffbc758",
33
- "9e9ec60197c8373a11ac15ce4dae80e973608ab2",
34
- "844770e0edf3b795cd7508fa71789572",
35
- "",
36
- "US",
37
- "https://a.appice.io",
38
-
39
- certs);
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);
27
+ "5bebe93c25d705690ffbc758",
28
+ "9e9ec60197c8373a11ac15ce4dae80e973608ab2",
29
+ "e5aa4b293f3188fac9cb1a4017963604",
30
+ "",
31
+ "US",
32
+ "https://a.appice.io",
33
+ certs
34
+ );
35
+
36
+ addAppICEAPIListeners();
37
+
38
+ AppState.addEventListener('change', (nextAppState) => {
39
+ if (nextAppState === 'active') {
40
+ AppICE.isDeviceReady(true);
41
+ }
42
+ else if (nextAppState === 'background'){
43
+ AppICE.isDeviceReady(false);
44
+ }
45
+ });
46
+
49
47
  }
50
- });
51
48
 
52
- addAppICEAPIListeners();
49
+
50
+
51
+
52
+
53
53
  return (
54
54
  <View
55
55
  style={{
56
56
  flex: 1,
57
- justifyContent: "center",
58
- alignItems: "center",
57
+ justifyContent: 'center',
58
+ alignItems: 'center',
59
59
  marginBottom: 10,
60
-
61
60
  }}>
62
61
  <Text>AppICE React Demo</Text>
63
- <Button
64
- onPress={sendEvent}
65
- title="Send Event"
66
- color="#841584"
67
-
68
- />
69
- <View
70
- >
71
-
72
- </View>
73
- <Button
74
- onPress={setUserProfile}
75
- title="set User Profile"
76
- color="#841584"
77
-
78
- />
79
-
80
- <Button
81
- onPress={setSampleUserID}
82
- title="set Sample User ID"
83
- color="#841584"
84
-
85
- />
86
- <Button
87
- onPress={setLanguage}
88
- title="set Language"
89
- color="#841584"
90
-
91
- />
92
- <Button
93
- onPress={sendView}
94
- title="Send View"
95
- color="#841584"
96
-
97
- />
98
- <Button
99
- onPress={getUserId}
100
- title="getUserId"
101
- color="#841584"
102
-
103
- />
104
- <Button
105
- onPress={getInboxMessage}
106
- title="getInboxMessage"
107
- color="#841584"
108
-
109
- />
110
- <Button
111
- onPress={getMessageCount}
112
- title="getMessageCount"
113
- color="#841584"
114
- />
115
- <Button
116
- onPress={getInboxMessageForId}
117
- title="getInboxMessageForId"
118
- color="#841584"
119
- />
120
- <Button
121
- onPress={updateInboxMessage}
122
- title="updateInboxMessage"
123
- color="#841584"
124
- />
125
- <Button
126
- onPress={synchronizeInbox}
127
- title="synchronizeInbox"
128
- color="#841584"
129
- />
62
+ <Button onPress={sendEvent} title="Send Event" color="#841584" />
63
+ <Button onPress={setSampleUserID} title="setUserID" color="#841584" />
64
+ <Button onPress={getUserId} title="getUserId" color="#841584" />
65
+ <Button onPress={setUserProfile} title="setUserProfile" color="#841584" />
66
+ <Button onPress={getUser} title="getUserProfile" color="#841584" />
67
+ <Button onPress={setLanguage} title="set Custom Variable" color="#841584" />
68
+ <Button onPress={getInboxMessage} title="getInboxMessage" color="#841584" />
69
+ <Button onPress={getInboxMessageForId} title="getInboxMessageForId" color="#841584" />
70
+ <Button onPress={getMessageCount} title="getMessageCount" color="#841584" />
71
+ <Button onPress={updateInboxMessage} title="updateInbox" color="#841584" />
72
+ <Button onPress={synchronizeInbox} title="synchronizeInbox" color="#841584" />
73
+ <Button onPress={getUserDetails} title="getUserDetails" color="#841584" />
74
+ <Button onPress={getUserData} title="getUserData" color="#841584" />
130
75
  </View>
131
- )
76
+ );
132
77
 
133
78
  }
134
79
 
135
- function addAppICEAPIListeners() {
136
-
137
- console.log('handleAppICETapEvent');
138
-
139
- AppICE.addListener(AppICE.AppICEPushNotificationClicked, (event) => {
140
- if (typeof event !== 'undefined'){
141
- console.log('handleAppICETapEvent', AppICE.AppICEPushNotificationClicked, event.AppICEPushNotificationClicked);
142
- AppICE.pushNotificationClicked(event.AppICEPushNotificationClicked);
143
- //fetching custom data from push payload
144
- var data = AppICE.getCustomDataFromPayload(event.AppICEPushNotificationClicked);
145
- console.log(data);
146
- }
147
- });
148
80
 
149
- AppICE.addListener(AppICE.AppICEInAppClicked, (event) => {
150
- if (typeof event !== 'undefined'){
151
- console.log('handleAppICETapEvent', AppICE.AppICEInAppClicked, event.AppICEInAppClicked);
152
- // AppICE.pushNotificationClicked(event.AppICEInAppClicked);
153
- }
154
- });
81
+ function addAppICEAPIListeners() {
82
+ AppICE.addListener(
83
+ AppICE.AppICEPushNotificationClicked,
84
+ (event: {AppICEPushNotificationClicked: any}) => {
85
+ if (typeof event !== 'undefined') {
86
+ console.log(
87
+ 'handleAppICETapEvent',
88
+ AppICE.AppICEPushNotificationClicked,
89
+ event.AppICEPushNotificationClicked,
90
+ );
91
+ AppICE.pushNotificationClicked(event.AppICEPushNotificationClicked);
92
+ }
93
+ },
94
+ );
95
+
96
+ AppICE.addListener(
97
+ AppICE.AppICEInAppClicked,
98
+ (event: {AppICEInAppClicked: any}) => {
99
+ if (typeof event !== 'undefined') {
100
+ console.log('event AppICEInAppClicked: ' + event);
101
+ console.log(
102
+ 'event is from AppICEInAppClicked is ' + event.AppICEInAppClicked,
103
+ );
104
+ console.log('handleAppICETapEvent', AppICE.AppICEInAppClicked);
105
+
106
+ callbackInApp(event.AppICEInAppClicked);
107
+ }
108
+ },
109
+ );
155
110
  }
156
111
  const sendEvent = () => {
157
- console.log("inside sendEvent");
112
+ console.log('inside sendEvent');
158
113
  var dataObj = {
159
- "ClickedMenuBtn": "false",
160
- "CLickedSubmitBtn": "false",
161
- "AppName": "ReactSampleApp"
114
+ ClickedMenuBtn: 'false',
115
+ CLickedSubmitBtn: 'false',
116
+ AppName: 'ReactSampleApp',
162
117
  };
163
- AppICE.tagEvent("ReactSampleApp", dataObj);
164
- //Recording an Event
165
- }
166
-
118
+ AppICE.tagEvent('ReactSampleApp', dataObj);
119
+ };
167
120
 
168
121
  const setUserProfile = () => {
169
- AppICE.setUser({
170
- [AppICE.name]: 'testUserA1', [AppICE.phone]: '123456', [AppICE.email]: 'test@test.com', [AppICE.age]: 23
171
- });
122
+ var user = AppICE.User("Amit@getstream.io")
123
+ console.log("userid user "+user)
124
+ AppICE.setUser(user);
172
125
  };
173
126
 
174
127
  const setSampleUserID = () => {
175
- AppICE.setUserId(['1232323','kuOEN8bCqdrROmJPVCeKSg==']);
176
-
177
- };
178
-
179
- const setLanguage = () => {
180
- AppICE.setCustomVariable("_lang", "ar-AE");
181
-
182
-
183
- AppICE.sendClickCallback((value) => {
184
- console.log(`INAPP callback`, value);
185
- });
186
-
187
- };
188
- const sendView = () => {
189
- AppICE.tagEvent("HomeScreen", {});
128
+ AppICE.setUserId(['181166344']);
190
129
  };
191
130
 
192
131
  const getUserId = () => {
193
132
  AppICE.getUserId((userIds: any[]) => {
194
133
  console.log('User IDs:', userIds);
134
+ const inboxMessageString = JSON.stringify(userIds, null, 2);
135
+
136
+ Alert.alert(`getInboxMessageForId: \n ${inboxMessageString}`);
195
137
  });
196
138
  };
197
139
 
198
- const type = 1;
199
- const userIds = ['1232323' , 'kuOEN8bCqdrROmJPVCeKSg=='];
140
+ const setLanguage = () => {
141
+ AppICE.setCustomVariable('_lang', 'ar-AE');
142
+ };
200
143
 
201
- const getInboxMessage = () => {
202
- AppICE.getInboxMessages(type, userIds, (inboxMessages: any[]) => {
203
- console.log('Received Inbox Messages:', inboxMessages);
144
+ const getUserDetails = () => {
145
+ console.log('GET USER Details:');
146
+ AppICE.getUser((user: any) => {
147
+ const inboxMessageString = JSON.stringify(user);
148
+ console.log('GET USER Details:' + inboxMessageString);
149
+ });
150
+ };
151
+ const getUser = () => {
152
+ console.log('GET USER:');
204
153
 
205
- inboxMessages.forEach((message) => {
206
- const mediaKey = 'imageUrl';
207
- AppICE.getMediaData(message, mediaKey, (mediaData: any) => {
208
- console.log('Media Data:', mediaData);
154
+ const userData = AppICE.getUser((res: any) => {
155
+ if (res) {
156
+ var response;
157
+ const resData = JSON.stringify(res);
158
+ console.log('res ' + resData);
209
159
 
210
- AppICE.getMediaUrl(mediaData,(mediaUrl:any) => {
211
- console.log('getMediaUrl is :', mediaUrl);
212
- });
160
+ const data = JSON.parse(resData);
161
+ response = data;
213
162
 
214
- AppICE.getMediaType(mediaData,(mediaType:any) => {
215
- console.log('getmediaType is:', mediaType);
216
- });
163
+ const customProperties = response[AppICE.DEMOGRAPHIC_INFO];
164
+ console.log('customProperties ' + customProperties);
165
+ }
166
+ });
167
+ };
217
168
 
218
- AppICE.getMediaThumbnail(mediaData,(mediaThumbnail:any) => {
219
- console.log('getMediaThumbnail is:', mediaThumbnail);
220
- });
221
- });
222
-
223
- });
169
+ function callbackInApp(payload: any) {
170
+ console.log('Call BAck payload:', payload);
171
+
172
+ if (payload) {
173
+ const screen = JSON.parse(payload);
174
+ console.log('Call BAck Screen:', screen);
175
+ }
224
176
  }
225
177
 
226
- const getMessageCount = () => {
227
- AppICE.getMessageCount(type, userIds, (count: number) => {
228
- console.log('Messages count :', count);
178
+ const getInboxMessage = () => {
179
+ console.log('Call getInboxMessage');
180
+ const userId = ['181166344'];
181
+ getInboxMessages(1, userId, 'Alerts', 10, 0, 10, false, (result: any) => {
182
+ console.log('Inbox data set: ', result);
183
+ Alert.alert(`Inbox Data: \n ${result}`);
229
184
  });
230
- }
185
+ };
231
186
 
232
-
233
- const getInboxMessageForId = () => {
234
- const messageId = "df73e314-2a61-4615-9fa5-348419e3fc82";
235
- const userIds = ['1232323' , 'kuOEN8bCqdrROmJPVCeKSg=='];
187
+ const getMessageCount = () => {
188
+ const userId = ['181166344'];
189
+ const count = getMessageCounts(1, userId, 10, (result: number) => {
190
+ Alert.alert(`getMessageCounts count : \n ${result}`);
191
+ console.log(count);
192
+ });
193
+ };
236
194
 
237
- AppICE.getInboxMessageForId(messageId, userIds, (inboxMessage: any) => {
238
- console.log('getInboxMessageForId in JS:', inboxMessage);
239
- });
240
- }
241
195
 
242
-
196
+ const getInboxMessageForId = () => {
197
+ console.log('call getInboxMessageForId Entry:');
198
+ const messageId = '1715782030369-3894c943-b47d-456c-b530-7c2eb8820af4';
199
+ const useIds = '181166344';
243
200
 
244
- const updateInboxMessage = () => {
245
- const messageId = "df73e314-2a61-4615-9fa5-348419e3fc82";
246
- const userId = ['1232323' , 'kuOEN8bCqdrROmJPVCeKSg=='];
247
- AppICE.updateInboxMessage(messageId, 1, userId, (isSuccess: boolean) => {
248
- console.log('Update Inbox Message Success:', isSuccess);
249
- });
250
- }
201
+ AppICE.getInboxMessageForId(messageId, useIds, (inboxMessage: any) => {
202
+ console.log('getInboxMessageForId in JS:', inboxMessage);
203
+ });
204
+ };
251
205
 
252
-
206
+ const updateInboxMessage = () => {
207
+ const messageId = '1715782030369-3894c943-b47d-456c-b530-7c2eb8820af4';
208
+ updatedInboxMessage(messageId, 3, '181166344', (result: boolean) => {
209
+ Alert.alert("Update Inbox Result : "+result
210
+ );
211
+ });
212
+ };
253
213
 
254
- const synchronizeInbox = () => {
255
- AppICE.synchronizeInbox(10, (success: boolean) => {
256
- console.log('Inbox synchronization success:', success);
257
- const userIds = ['1232323' , 'kuOEN8bCqdrROmJPVCeKSg=='];
258
- AppICE.getInboxMessages( 1, userIds, (inboxMessages: any[]) => {
259
- console.log('Inbox Messages:', inboxMessages);
260
- // everytime will return next set of data from payload
261
- // var inbox = getInboxFilteredData (inbox, key= "Transaction", limit=10, offset=1 );
262
- });
263
214
 
215
+ const synchronizeInbox = () => {
216
+ AppICE.synchronizeInbox(10, (success: boolean) => {
217
+ console.log('Inbox synchronization success:', success);
218
+ const useIds = ['181166344'];
219
+ AppICE.getInboxMessages(1, useIds, (inboxMessages: any[]) => {
220
+ console.log('Inbox Messages:', inboxMessages);
264
221
  });
265
- }
222
+ });
223
+ };
266
224
 
267
- const getUserData = () => {
268
- AppICE.synchronizeData(10,(success: boolean) => {
269
- console.log('Profile synchronization success:', success);
225
+ const getUserData = () => {
226
+ AppICE.synchronizeData(100, (success: boolean) => {
227
+ console.log('Profile synchronizeData success:', success);
270
228
  Alert.alert(`synchronizeData: \n ${success}`);
271
- const userIds = ['160840156'];
272
- AppICE.getUserForIds(userIds, (res:any[]) => {
273
-
274
- console.log('Receive getUser:', res);
229
+ const userIds = ['181166344'];
230
+ AppICE.getUserForIds(userIds, (res: any) => {
231
+ console.log('Receive getUser:', res);
232
+ Alert.alert('Receive getUser Alert:' + JSON.stringify(res));
275
233
  for (var index = 0; index < res.length; index++) {
276
234
  let userData = res[index];
277
- console.log('Received Inbox:', userData);
235
+ console.log('Received Inbox:', userData);
278
236
  const name = userData[AppICE.name];
279
237
  const phone = userData[AppICE.phone];
280
238
  const gender = userData[AppICE.gender];
@@ -286,25 +244,30 @@ const getMessageCount = () => {
286
244
  const marriage = userData[AppICE.married];
287
245
  const isEmployed = userData[AppICE.isEmployed];
288
246
 
289
- console.log('GetUser name:', name);
290
- console.log('GetUser phone:', phone);
247
+ console.log('GetUser Name:', name);
248
+ console.log('GetUser PHONE:', phone);
291
249
  console.log('GetUser gender:', gender);
292
250
  console.log('GetUser dob:', dob);
293
- console.log('GetUser educationType:', edt);
251
+ console.log('GetUser edt:', edt);
294
252
  console.log('GetUser email:', email);
295
253
  console.log('GetUser employment:', employment);
296
254
  console.log('GetUser age:', age);
297
255
  console.log('GetUser marriage:', marriage);
298
- console.log('GetUser isEmployed:', isEmployed);
299
-
256
+ console.log('GetUser ISEMPLOYED:', isEmployed);
300
257
 
301
258
  const customProperties = userData[AppICE.DEMOGRAPHIC_INFO];
302
- const customPropertiesObj = JSON.parse(customProperties);
303
- console.log("user Profile, top_n_product_viewed = "+customPropertiesObj[AppICE.TOP_N_PRODUCTS_VIEWED]);
304
-
305
- }
259
+ const customPropertiesObj = JSON.parse(customProperties);
260
+ console.log(
261
+ 'customPropertiesObj ' + JSON.stringify(customPropertiesObj),
262
+ );
263
+
264
+ console.log(
265
+ 'user Profile, top_n_product_viewed = ' +
266
+ customPropertiesObj[AppICE.TOP_N_PRODUCTS_VIEWED],
267
+ );
268
+ }
306
269
  });
307
270
  });
308
- }
271
+ };
309
272
 
310
273
  export default HelloWorldApp;