@inngageregistry/inngage-react 3.2.0 → 3.3.0-alpha.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inngageregistry/inngage-react",
3
- "version": "3.2.0",
3
+ "version": "3.3.0-alpha.1",
4
4
  "description": "Inngage Plugin for React Native applications for marketing campaign optimization using Push Notification.",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.d.ts",
@@ -28,15 +28,14 @@
28
28
  "react-native-localize": "^2.2.6",
29
29
  "react-native-permissions": "^3.8.0",
30
30
  "react-native-push-notification": "^8.1.1",
31
- "react-native-snap-carousel": "^3.9.1"
31
+ "react-native-reanimated-carousel": "^3.5.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/jest": "^29.5.1",
35
35
  "@types/react": "^18.2.0",
36
36
  "@types/react-native": "^0.71.6",
37
37
  "@types/react-native-push-notification": "^8.1.1",
38
- "@types/react-native-snap-carousel": "^3.8.5",
39
38
  "@types/react-test-renderer": "^18.0.0",
40
39
  "typescript": "^5.0.4"
41
40
  }
42
- }
41
+ }
package/src/Inngage.ts CHANGED
@@ -71,27 +71,11 @@ interface SubscriptionProps {
71
71
  email?: string
72
72
  }
73
73
 
74
- interface SendEventProps {
75
- newEventRequest: {
76
- app_token: string,
77
- identifier: string,
78
- event_name: string,
79
- conversion_event: boolean,
80
- conversion_value: number,
81
- conversion_notid: string,
82
- event_values: {
83
- nome_promo: string,
84
- categoria: string,
85
- foto_promo: string,
86
- redirect_link: string
87
- }
88
- },
89
- }
90
-
91
74
  interface SendEventProps {
92
75
  appToken: string,
93
- identifier: string,
94
76
  eventName: string,
77
+ identifier?: string,
78
+ registration?: string,
95
79
  conversionEvent?: boolean,
96
80
  conversionValue?: number,
97
81
  conversionNotId?: string,
@@ -164,8 +148,9 @@ const Inngage = {
164
148
 
165
149
  SendEvent: async ({
166
150
  appToken,
167
- identifier,
168
151
  eventName,
152
+ identifier,
153
+ registration,
169
154
  conversionEvent,
170
155
  conversionValue,
171
156
  conversionNotId,
@@ -176,6 +161,7 @@ const Inngage = {
176
161
  newEventRequest: {
177
162
  app_token: appToken,
178
163
  identifier: identifier,
164
+ registration: registration,
179
165
  event_name: eventName,
180
166
  conversion_event: conversionEvent ?? false,
181
167
  conversion_value: conversionValue ?? 0,
@@ -10,10 +10,11 @@ import {
10
10
  ImageBackground,
11
11
  Linking,
12
12
  Dimensions,
13
+ Button,
13
14
  } from "react-native";
14
15
  import DeviceInfo from "react-native-device-info";
15
16
  import AsyncStorage from '@react-native-async-storage/async-storage';
16
- import Carousel, { Pagination } from 'react-native-snap-carousel';
17
+ // import Carousel, { Pagination } from 'react-native-snap-carousel';
17
18
 
18
19
  import { showAlertLink, isEmpty } from "../utils";
19
20
  import { linkInApp } from "../notificationsListener";
@@ -21,6 +22,7 @@ import { styleInapp, styleItem } from './styles';
21
22
 
22
23
  const SLIDER_WIDTH = Dimensions.get('window').width;
23
24
  const SLIDER_HEIGHT = Dimensions.get('window').height;
25
+
24
26
  const ITEM_WIDTH = Math.round(SLIDER_WIDTH * 0.8);
25
27
  const ITEM_HEIGHT = Math.round(SLIDER_HEIGHT * 0.8);
26
28
 
@@ -41,11 +43,15 @@ export const Inapp = (props: InappProps) => {
41
43
  const [visible, setVisible] = useState(true)
42
44
  const [bgImage, setbgImage] = useState<any>(undefined) // TODO, need a placeholder
43
45
 
44
- const CarouselRef = useRef<Carousel<any>>(null);
46
+ // const CarouselRef = useRef<Carousel<any>>(null);
45
47
  const ScrollRef1 = useRef<ScrollView>(null);
46
48
  const ScrollRef2 = useRef<ScrollView>(null);
47
49
  const ScrollRef3 = useRef<ScrollView>(null);
48
50
 
51
+ // const inAppData = JSON.parse(data[0].data.additional_data)
52
+ // const styles = styleInapp({ inAppData, SLIDER_WIDTH })
53
+ // const itemStyles = styleItem({ inAppData })
54
+
49
55
 
50
56
  interface _renderItemProps {
51
57
  item: any;
@@ -64,7 +70,7 @@ export const Inapp = (props: InappProps) => {
64
70
  }
65
71
  }
66
72
 
67
- const itemStyles = styleItem({ msg, checkBG })
73
+ // const itemStyles = styleItem({ msg, checkBG })
68
74
 
69
75
  const chooseRef = () => {
70
76
  if (index == 0) {
@@ -79,46 +85,46 @@ export const Inapp = (props: InappProps) => {
79
85
  }
80
86
 
81
87
 
82
- const pagination = ref => {
83
- return (
84
- <Pagination
85
- dotsLength={arrayImgs.length}
86
- activeDotIndex={indIm}
87
- containerStyle={{ height: 2, padding: 0, margin: 0 }}
88
- renderDots={(activeIndex, total, context) => {
89
- let dots: any = []
90
- var size = 0
91
- for (let i = 0; i < total; i++) {
92
- if (activeIndex == i) {
93
- size = 13
94
- } else {
95
- size = 8
96
- }
97
- dots.push(
98
- <TouchableOpacity
99
- onPress={() => {
100
- ref.current.scrollTo({ x: i * 220, y: 0, animated: true })
101
- if (i * 220 === 0) {
102
- setIndImg(0)
103
- } else if (i * 220 === 220) {
104
- setIndImg(1)
105
- } else if (i * 220 === 440) {
106
- setIndImg(2)
107
- }
108
- }}
109
- key={i.toString()}
110
- style={[itemStyles.dot, { width: size, height: size }]}
111
- />
112
- )
113
- }
114
- return (
115
- dots
116
- )
117
- }
118
- }
119
- />
120
- );
121
- }
88
+ // const pagination = ref => {
89
+ // return (
90
+ // <Pagination
91
+ // dotsLength={arrayImgs.length}
92
+ // activeDotIndex={indIm}
93
+ // containerStyle={{ height: 2, padding: 0, margin: 0 }}
94
+ // renderDots={(activeIndex, total, context) => {
95
+ // let dots: any = []
96
+ // var size = 0
97
+ // for (let i = 0; i < total; i++) {
98
+ // if (activeIndex == i) {
99
+ // size = 13
100
+ // } else {
101
+ // size = 8
102
+ // }
103
+ // dots.push(
104
+ // <TouchableOpacity
105
+ // onPress={() => {
106
+ // ref.current.scrollTo({ x: i * 220, y: 0, animated: true })
107
+ // if (i * 220 === 0) {
108
+ // setIndImg(0)
109
+ // } else if (i * 220 === 220) {
110
+ // setIndImg(1)
111
+ // } else if (i * 220 === 440) {
112
+ // setIndImg(2)
113
+ // }
114
+ // }}
115
+ // key={i.toString()}
116
+ // // style={[itemStyles.dot, { width: size, height: size }]}
117
+ // />
118
+ // )
119
+ // }
120
+ // return (
121
+ // dots
122
+ // )
123
+ // }
124
+ // }
125
+ // />
126
+ // );
127
+ // }
122
128
 
123
129
  const handleButton = (title: string, body: string, url: string, type: string) => {
124
130
  if (type === '' || url === '') {
@@ -165,10 +171,11 @@ export const Inapp = (props: InappProps) => {
165
171
  )
166
172
  }
167
173
  }
168
- return (
169
- <View style={[itemStyles.body]}>
170
- <Text style={[itemStyles.title, props.titleStyle]}>{msg.title}</Text>
171
- <ScrollView
174
+
175
+ // return (
176
+ // <View style={[itemStyles.body]}>
177
+ // <Text style={[itemStyles.title, props.titleStyle]}>{msg.title}</Text>
178
+ {/* <ScrollView
172
179
  ref={chooseRef()}
173
180
  horizontal
174
181
  snapToInterval={220}
@@ -200,22 +207,26 @@ export const Inapp = (props: InappProps) => {
200
207
  msg.rich_content.carousel == true ?
201
208
  pagination(chooseRef()) : null
202
209
 
203
- }
204
- <Text style={[itemStyles.bodyText, props.bodyStyle]}>{msg.body}</Text>
205
- <View style={{ flexDirection: "row", marginBottom: 0, justifyContent: 'center' }}>
206
- <TouchableOpacity onPress={() => handleButton(msg.title, msg.body, msg.btn_left_action_link, msg.btn_left_action_type)} style={[itemStyles.btn_left, props.buttonLeftStyle]}>
207
- <View>
208
- <Text style={[itemStyles.btn_left_title, props.buttonTitleLeftStyle]}>{msg.btn_left_txt}</Text>
209
- </View>
210
- </TouchableOpacity>
211
- <TouchableOpacity onPress={() => handleButton(msg.title, msg.body, msg.btn_right_action_link, msg.btn_right_action_type)} style={[itemStyles.btn_right, props.buttonRightStyle]}>
212
- <View>
213
- <Text style={[itemStyles.btn_right_title, props.buttonTitleRightStyle]}>{msg.btn_right_txt}</Text>
214
- </View>
215
- </TouchableOpacity>
216
- </View>
217
- </View>
218
- );
210
+ } */}
211
+ /* <Text style={[itemStyles.bodyText, props.bodyStyle]}>{msg.body}</Text>
212
+ <View style={{ flexDirection: "row", marginBottom: 0, justifyContent: 'center' }}>
213
+ {msg.btn_left_txt != null
214
+ ? <TouchableOpacity onPress={() => handleButton(msg.title, msg.body, msg.btn_left_action_link, msg.btn_left_action_type)} style={[itemStyles.btn_left, props.buttonLeftStyle]}>
215
+ <View>
216
+ <Text style={[itemStyles.btn_left_title, props.buttonTitleLeftStyle]}>{msg.btn_left_txt}</Text>
217
+ </View>
218
+ </TouchableOpacity>
219
+ : null}
220
+ {msg.btn_left_txt != null
221
+ ? <TouchableOpacity onPress={() => handleButton(msg.title, msg.body, msg.btn_right_action_link, msg.btn_right_action_type)} style={[itemStyles.btn_right, props.buttonRightStyle]}>
222
+ <View>
223
+ <Text style={[itemStyles.btn_right_title, props.buttonTitleRightStyle]}>{msg.btn_right_txt}</Text>
224
+ </View>
225
+ </TouchableOpacity>
226
+ : null}
227
+ </View> */
228
+ // </View>
229
+ // );
219
230
  }
220
231
 
221
232
  useEffect(() => {
@@ -268,26 +279,65 @@ export const Inapp = (props: InappProps) => {
268
279
  }
269
280
 
270
281
  if (data.length > 0) {
282
+ const inAppData = JSON.parse(data[0].data.additional_data)
283
+ const styles = styleInapp({ inAppData, SLIDER_WIDTH })
284
+ const itemStyles = styleItem({ inAppData })
285
+
286
+ const { width: screenWidth } = Dimensions.get('window')
287
+
288
+ const sliderWidth = screenWidth;
289
+ const itemWidth = screenWidth * 8;
290
+
291
+ const _renderItemCarrousel = ({ item }) => {
292
+ <Image style={itemStyles.img} source={{ uri: inAppData.rich_content[item] }}></Image>
293
+ }
294
+
295
+ console.log(inAppData.rich_content)
271
296
  return (
272
- <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
297
+ <View style={styles.centeredView}>
273
298
  <Modal
274
299
  animationType='slide'
275
300
  visible={visible}
276
301
  transparent={true}
277
- style={{ justifyContent: 'center', alignItems: 'center', backgroundColor: 'blue' }}
278
- ><View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
279
- <View style={[styles.styleContainer, props.styleContainer]}>
280
- <ImageBackground style={{ width: '100%', alignItems: 'center', justifyContent: 'center' }} resizeMode='cover' imageStyle={{ borderRadius: 10, alignSelf: 'stretch', height: 480 }} source={bgImage}>
281
- <TouchableHighlight
282
- onPress={() => handleClose()}
283
- underlayColor='#cccccc'
284
- style={styles.closeButton}
285
- >
286
- <Text style={{ fontWeight: 'bold', color: '#ffffff' }}>
287
- X
288
- </Text>
289
- </TouchableHighlight>
290
- <Carousel
302
+ >
303
+ <View style={styles.centeredView}>
304
+ <View style={styles.styleContainer}>
305
+ {/* <Carousel
306
+ layout='default'
307
+ data={data}
308
+ renderItem={_renderItemCarrousel}
309
+ sliderWidth={sliderWidth}
310
+ itemWidth={itemWidth}
311
+ /> */}
312
+ <Text style={itemStyles.title}>{inAppData.title}</Text>
313
+ <Text style={itemStyles.bodyText}>{inAppData.body}</Text>
314
+ <View style={itemStyles.containerButtons}>
315
+ <TouchableOpacity
316
+ onPress={() => { }}
317
+ style={[itemStyles.btn_left, props.buttonLeftStyle]}>
318
+ <View>
319
+ <Text style={[itemStyles.btn_left_title, props.buttonTitleLeftStyle]}>{inAppData.btn_left_txt}</Text>
320
+ </View>
321
+ </TouchableOpacity>
322
+ <TouchableOpacity onPress={() => { }} style={[itemStyles.btn_right, props.buttonRightStyle]}>
323
+ <View>
324
+ <Text style={[itemStyles.btn_right_title, props.buttonTitleRightStyle]}>{inAppData.btn_right_txt}</Text>
325
+ </View>
326
+ </TouchableOpacity>
327
+ </View>
328
+
329
+ {/* <ImageBackground style={{ width: '100%', alignItems: 'center', justifyContent: 'center' }} resizeMode='cover' imageStyle={{ borderRadius: 10, alignSelf: 'stretch', height: 480 }} source={bgImage}> */}
330
+ <TouchableHighlight
331
+ onPress={() => handleClose()}
332
+ underlayColor='#cccccc'
333
+ style={styles.closeButton}
334
+ >
335
+ <Text style={{ fontWeight: 'bold', color: '#ffffff' }}>
336
+ X
337
+ </Text>
338
+ </TouchableHighlight>
339
+
340
+ {/* <Carousel
291
341
  vertical
292
342
  ref={CarouselRef}
293
343
  layout={'default'}
@@ -309,16 +359,16 @@ export const Inapp = (props: InappProps) => {
309
359
  renderItem={({ item, index }) => _renderItem({ item, index })}
310
360
  sliderHeight={500}
311
361
  itemHeight={500}
312
- />
313
- </ImageBackground>
362
+ /> */}
363
+ {/* </ImageBackground> */}
314
364
  </View>
315
365
  </View>
316
366
  </Modal>
317
- </View>
367
+ </View >
318
368
  );
319
369
  } else {
320
370
  return null
321
371
  }
322
372
  };
323
373
 
324
- const styles = styleInapp({ SLIDER_WIDTH })
374
+
@@ -2,24 +2,30 @@ import { StyleSheet } from "react-native";
2
2
 
3
3
 
4
4
  interface styleInappProps {
5
+ inAppData: any;
5
6
  SLIDER_WIDTH: number;
6
7
  }
7
- export const styleInapp = ({SLIDER_WIDTH}: styleInappProps) => StyleSheet.create({
8
+ export const styleInapp = ({ inAppData, SLIDER_WIDTH }: styleInappProps) => StyleSheet.create({
9
+ centeredView: {
10
+ flex: 1,
11
+ justifyContent: 'center',
12
+ alignItems: 'center',
13
+ },
8
14
  carouselContainer: {
9
15
  width: "100%",
10
16
  marginTop: 10,
11
17
  },
12
18
  styleContainer: {
13
- backgroundColor: 'white',
19
+ alignItems: 'center',
20
+ backgroundColor: inAppData.background_color || 'white',
14
21
  elevation: 10,
15
22
  borderRadius: 10,
16
23
  width: SLIDER_WIDTH * 0.8,
17
- height: 480,
18
- },
19
- counter: {
20
- alignSelf: 'center',
21
- marginVertical: 10
22
24
  },
25
+ // counter: {
26
+ // alignSelf: 'center',
27
+ // marginVertical: 10
28
+ // },
23
29
  closeButton: {
24
30
  position: 'absolute',
25
31
  alignSelf: 'flex-end',
@@ -36,62 +42,66 @@ export const styleInapp = ({SLIDER_WIDTH}: styleInappProps) => StyleSheet.create
36
42
  });
37
43
 
38
44
  interface styleItemProps {
39
- msg: any,
40
- checkBG: Function,
45
+ inAppData: any,
41
46
  }
42
- export const styleItem = ({msg, checkBG}: styleItemProps) => StyleSheet.create({
47
+ export const styleItem = ({ inAppData }: styleItemProps) => StyleSheet.create({
43
48
  btn_left: {
44
- backgroundColor: msg.btn_left_bg_color || "#FFFFFF",
45
- height: 40,
46
- width: 100,
49
+ width: inAppData.btn_right != '' ? '50%' : '100%',
47
50
  alignItems: 'center',
48
- justifyContent: 'center',
49
- marginRight: 20,
50
- marginLeft: 10,
51
- flex: 1
51
+ backgroundColor: inAppData.btn_left_bg_color || '#DDDDDD',
52
+ padding: 10,
53
+ elevation: 10,
54
+ borderRadius: 5,
52
55
  },
53
56
  btn_right: {
54
- backgroundColor: msg.btn_right_bg_color || "#FFFFFF",
55
- height: 40,
56
- width: 100,
57
+ width: inAppData.btn_left != '' ? '50%' : '100%',
57
58
  alignItems: 'center',
58
- justifyContent: 'center',
59
- marginRight: 10,
60
- flex: 1
59
+ backgroundColor: inAppData.btn_right_bg_color || '#DDDDDD',
60
+ padding: 10,
61
+ elevation: 10,
62
+ borderRadius: 5,
61
63
  },
62
64
  btn_left_title: {
63
- color: msg.btn_left_txt_color || "#000000"
65
+ color: inAppData.btn_left_txt_color || "#000000"
64
66
  },
65
67
  btn_right_title: {
66
- color: msg.btn_right_txt_color || "#000000"
68
+ color: inAppData.btn_right_txt_color || "#000000"
67
69
  },
68
70
  body: {
69
- backgroundColor: checkBG(),
71
+ backgroundColor: inAppData.background_color,
70
72
  width: '100%',
71
- height: 450,
72
73
  alignSelf: 'center',
73
74
  alignItems: 'center',
74
75
  justifyContent: 'center',
75
76
  },
76
77
  bodyText: {
77
- color: msg.body_font_color || "#000000",
78
+ color: inAppData.body_font_color || "#000000",
78
79
  textAlign: 'justify',
79
80
  marginBottom: 10,
80
81
  fontSize: 15,
81
82
  marginHorizontal: 10
82
83
  },
83
84
  title: {
84
- color: msg.title_font_color || "#000000",
85
+ color: inAppData.title_font_color || "#000000",
85
86
  fontWeight: "bold",
86
87
  fontSize: 18,
87
- marginTop: 40
88
+ marginTop: 10
88
89
  },
89
90
  dot: {
90
- backgroundColor: msg.dot_color || "#FFFFFF",
91
+ backgroundColor: inAppData.dot_color || "#FFFFFF",
91
92
  borderRadius: 100,
92
93
  width: 8,
93
94
  height: 8,
94
95
  marginLeft: 5,
95
96
  elevation: 5,
97
+ },
98
+ containerButtons: {
99
+ flexDirection: 'row',
100
+ justifyContent: 'center',
101
+ margin: 10
102
+ },
103
+ img: {
104
+ width: '100%',
105
+ height: 150
96
106
  }
97
107
  });
package/src/index.d.ts CHANGED
@@ -1,8 +1,11 @@
1
+ import React from 'react';
2
+ import { ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';
3
+
1
4
  interface notificationsListenerProps {
2
- appToken: string,
3
- dev?: boolean,
4
- enableAlert: boolean,
5
- onNotificationOpenedApp?: any,
5
+ appToken: string;
6
+ dev?: boolean;
7
+ enableAlert: boolean;
8
+ onNotificationOpenedApp?: any;
6
9
  }
7
10
 
8
11
  interface SubscriptionProps {
@@ -17,13 +20,14 @@ interface SubscriptionProps {
17
20
  }
18
21
 
19
22
  interface SendEventProps {
20
- appToken: string,
21
- identifier: string,
22
- eventName: string,
23
- conversionEvent?: boolean,
24
- conversionValue?: number,
25
- conversionNotId?: string,
26
- eventValues?: any
23
+ appToken: string;
24
+ eventName: string;
25
+ identifier?: string;
26
+ registration?: string;
27
+ conversionEvent?: boolean;
28
+ conversionValue?: number;
29
+ conversionNotId?: string;
30
+ eventValues?: any;
27
31
  }
28
32
 
29
33
  declare const Inngage: {
@@ -32,4 +36,18 @@ declare const Inngage: {
32
36
  SendEvent: (props: SendEventProps) => Promise<any>;
33
37
  };
34
38
 
35
- export default Inngage;
39
+ interface InappProps {
40
+ mediaStyle?: StyleProp<ImageStyle>;
41
+ titleStyle?: StyleProp<TextStyle>;
42
+ bodyStyle?: StyleProp<TextStyle>;
43
+ buttonLeftStyle?: StyleProp<ViewStyle>;
44
+ buttonRightStyle?: StyleProp<ViewStyle>;
45
+ buttonTitleLeftStyle?: StyleProp<TextStyle>;
46
+ buttonTitleRightStyle?: StyleProp<TextStyle>;
47
+ styleContainer?: StyleProp<ViewStyle>;
48
+ onClose?: 'clear';
49
+ }
50
+
51
+ export const Inapp: React.FC<InappProps>;
52
+
53
+ export default Inngage;