react-native-flyy 1.4.29 → 1.4.31

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/src/index.tsx CHANGED
@@ -12,10 +12,7 @@ import {
12
12
  Linking,
13
13
  FlatList
14
14
  } from 'react-native';
15
- import Draggable from 'react-native-draggable';
16
15
  import FlyyCheckinComponent from './flyy_checkin_view';
17
- import AsyncStorage from '@react-native-async-storage/async-storage';
18
- import Toast from 'react-native-simple-toast';
19
16
  import { FlyyStoriesWidget } from './flyy_stories';
20
17
 
21
18
  type FlyyType = {
@@ -42,224 +39,224 @@ const windowHeight = Dimensions.get('window').height;
42
39
  const windowWidth = Dimensions.get('window').width;
43
40
 
44
41
  // ****** Flyy Floating Widget ******
45
- export const FlyyFloatingWidget = ({
46
- props = {
47
- backgroundColor: "#654EA3",
48
- buttonHeight: 55,
49
- buttonWidth: 55,
50
- buttonCornerRadius: 40,
51
- buttonIcon: require('./assets/images/rewardwidget.png'),
52
- onPress: () => { },
53
- x: windowWidth - 75,
54
- y: windowHeight - 100,
55
- minX: 5,
56
- minY: 5,
57
- maxX: windowWidth - 5,
58
- maxY: windowHeight - 5,
59
- show: true,
60
- stick: false,
61
- startDate: 0,
62
- endDate: 0
63
- } }) => {
64
-
65
- const [showWidget,setShowWidget] = useState(false);
66
- const [userData,setUserData] = useState({});
67
- const [iconUrl,setIconUrl] = useState(require('./assets/images/rewardwidget.png'));
68
- const [backgroundColor,setBackgroundColor] = useState("#654EA3");
69
- const [buttonSize,setButtonSize] = useState(55);
70
- const [buttonXPosition,setButtonXPosition] = useState(windowWidth - 75);
71
- const [buttonYPosition,setButtonYPosition] = useState(windowHeight - 100);
72
- const [deeplink,setDeeplink] = useState(null);
73
- const flyyConfigDate = "flyy_config_date";
74
- const flyyConfigUserId = "user_id";
75
- var oldState = null;
76
- var currentState = null;
77
- var data = null;
78
-
79
- useEffect(()=>{
80
- fetchData();
81
- },[]);
82
-
83
- const fetchData = async() => {
84
- const sdkInfo = await Flyy.getUserData();
85
- const appData = await Flyy.getAppData();
86
- const resp = await fetch(`https://${sdkInfo["environment"] == 0 ? "ghc-stage" : "ghc"}.theflyy.com/api/v8/flyy_app_info`, {
87
- headers: {
88
- "X-Key": sdkInfo["partner_id"],
89
- "Content-Type": "application/json",
90
- "X-App-Data": appData
91
- }
92
- });
93
- data = await resp.json();
94
- if(!data.success){
95
- if (Platform.OS === 'android') {
96
- ToastAndroid.show(data.message, ToastAndroid.SHORT);
97
- } else {
98
- Toast.showWithGravity(data.message, Toast.SHORT, Toast.BOTTOM);
99
- }
100
- return;
101
- }
102
- const widgetConfig = data.info.floating_widget_configuration;
103
-
104
- if (widgetConfig.icon_url != null && widgetConfig.icon_url != '') {
105
- setIconUrl({ uri: widgetConfig.icon_url })
106
- } else {
107
- setIconUrl(props.buttonIcon)
108
- }
109
-
110
- if (widgetConfig.color != null && widgetConfig.color != '') {
111
- setBackgroundColor(widgetConfig.color)
112
- } else {
113
- setBackgroundColor(props.backgroundColor)
114
- }
115
-
116
- if (widgetConfig.size != null && widgetConfig.color != 0) {
117
- setButtonSize(parseInt(data.info.floating_widget_configuration.size))
118
- } else {
119
- setButtonSize(props.buttonHeight)
120
- }
121
-
122
- //FloatingButton Position
123
- if (widgetConfig.position == "bottom_left") {
124
- setButtonXPosition(10)
125
- } else if (widgetConfig.position == "bottom_right") {
126
- setButtonXPosition(windowWidth - 75)
127
- } else if (widgetConfig.position == "upper_left") {
128
- setButtonXPosition(10)
129
- if (Platform.OS === 'android'){
130
- setButtonYPosition(10)
131
- }else{
132
- setButtonYPosition(50)
133
- }
134
- } else if (widgetConfig.position == "upper_right") {
135
- setButtonXPosition(windowWidth - 75)
136
- if (Platform.OS === 'android'){
137
- setButtonYPosition(10)
138
- }else{
139
- setButtonYPosition(50)
140
- }
141
- }
142
-
143
- //Set DeepLink
144
- if (widgetConfig.deeplink != null && widgetConfig.deeplink != "") {
145
- setDeeplink(widgetConfig.deeplink)
146
- }
147
- //Set Visibility of FloatingButton
148
- var currentDate = new Date();
149
- const getDate = await AsyncStorage.getItem(flyyConfigDate);
150
- const userId = await AsyncStorage.getItem(flyyConfigUserId);
151
- var date = new Date(parseInt(getDate));
152
- const diffTime = Math.abs(getDate - currentDate);
153
- const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))-1;
154
- if(diffDays != 0 || userId == null || userId != sdkInfo[flyyConfigUserId]){
155
- var data = await Flyy.getAppOccurence(1);
156
- await AsyncStorage.setItem(
157
- flyyConfigUserId,
158
- sdkInfo[flyyConfigUserId]
159
- );
160
- }
161
- const occurrenceCount = await Flyy.getAppOccurence(0);
162
- if (widgetConfig.show_to_user && occurrenceCount <= parseInt(widgetConfig.num_times)) {
163
- // var numberOfDaysToAdd = widgetConfig.num_days+1;
164
- // var result = currentDate.setDate(currentDate.getDate() + numberOfDaysToAdd);
165
- if(getDate === null || userId == null || userId != sdkInfo[flyyConfigUserId]){
166
- await AsyncStorage.setItem(
167
- flyyConfigDate,
168
- JSON.stringify(currentDate.getTime())
169
- );
170
- }
171
- const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
172
- var date = new Date(parseInt(getDate2));
173
- const diffTime = Math.abs(getDate2 - currentDate);
174
- const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))-1;
175
- //Show widget on same day
176
- if(diffDays === 0 || diffDays === -1){
177
- setShowWidget(true)
178
- }else{
179
- //reset occurrence on next day
180
- await Flyy.getAppOccurence(1);
181
- if(diffDays >= parseInt(widgetConfig.num_days)+1){
182
- await AsyncStorage.setItem(
183
- flyyConfigDate,
184
- JSON.stringify(currentDate.getTime())
185
- );
186
- setShowWidget(true)
187
- }
188
- }
189
- }else{
190
- setShowWidget(false);
191
- const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
192
- var date = new Date(parseInt(getDate2));
193
- const diffTime = Math.abs(getDate2 - currentDate);
194
- const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
195
- if(diffDays != 1){
196
- var data = await Flyy.getAppOccurence(1);
197
- }
198
- }
199
- }
200
-
201
- // if(props.show){
202
- // if(props.startDate != null && props.startDate != 0){
203
- // var now = new Date().getTime();
204
- // if(now >= props.startDate && now <= props.endDate){
205
- // props.show = true
206
- // }else{
207
- // props.show = false
208
- // }
209
- // }
210
- // }
211
-
212
- // AppState.addEventListener('change', state =>{
213
- // console.log('AppState updated to', AppState.currentState)
214
- // oldState = currentState;
215
- // currentState = state;
216
- // if(oldState == null){
217
- // console.log('App is newly start :::')
218
- // }})
219
-
220
- return (
221
- // @ts-ignore
222
- props.show && showWidget? <Draggable x={buttonXPosition}
223
- y={buttonYPosition}
224
- minX={props.minX ?? 5}
225
- minY={props.minY ?? 5}
226
- maxX={props.maxX ?? windowWidth - 5}
227
- maxY={props.maxY ?? windowHeight - 5}
228
- renderSize={56}
229
- // shouldReverse = {true}
230
- onDragRelease={props.stick ? () => {
231
-
232
- } : null} isCircle>
233
- <TouchableOpacity
234
- onPress={deeplink != null ? async()=>{
235
- if (Platform.OS === 'android' || !deeplink.startsWith("flyy://")) {
236
- const supported = await Linking.canOpenURL(deeplink);
237
- await Linking.openURL(deeplink);
238
- } else {
239
- navigateTo(deeplink);
240
- }
241
- }:props.onPress}
242
- style={{
243
- height: buttonSize,
244
- width: buttonSize,
245
- backgroundColor: backgroundColor,
246
- borderRadius: buttonSize/2,
247
- justifyContent: 'center',
248
- alignItems: 'center',
249
- }}>
250
- <Image source={iconUrl} style={{ height: buttonSize*55/100, width: buttonSize*55/100 }} />
251
- <TouchableOpacity
252
- onPress={()=>{
253
- props.show = false;
254
- setShowWidget(false);
255
- }}
256
- style = {{height: 20, width: 20, backgroundColor: "transparent",position:'absolute',left:buttonSize-11, bottom: buttonSize*72/100}}>
257
- <Image source={require('./assets/images/xmark.png')} style={{ height: 18, width: 18, tintColor: "black"}} />
258
- </TouchableOpacity>
259
- </TouchableOpacity>
260
- </Draggable> : <View/>
261
- );
262
- }
42
+ // export const FlyyFloatingWidget = ({
43
+ // props = {
44
+ // backgroundColor: "#654EA3",
45
+ // buttonHeight: 55,
46
+ // buttonWidth: 55,
47
+ // buttonCornerRadius: 40,
48
+ // buttonIcon: require('./assets/images/rewardwidget.png'),
49
+ // onPress: () => { },
50
+ // x: windowWidth - 75,
51
+ // y: windowHeight - 100,
52
+ // minX: 5,
53
+ // minY: 5,
54
+ // maxX: windowWidth - 5,
55
+ // maxY: windowHeight - 5,
56
+ // show: true,
57
+ // stick: false,
58
+ // startDate: 0,
59
+ // endDate: 0
60
+ // } }) => {
61
+
62
+ // const [showWidget,setShowWidget] = useState(false);
63
+ // const [userData,setUserData] = useState({});
64
+ // const [iconUrl,setIconUrl] = useState(require('./assets/images/rewardwidget.png'));
65
+ // const [backgroundColor,setBackgroundColor] = useState("#654EA3");
66
+ // const [buttonSize,setButtonSize] = useState(55);
67
+ // const [buttonXPosition,setButtonXPosition] = useState(windowWidth - 75);
68
+ // const [buttonYPosition,setButtonYPosition] = useState(windowHeight - 100);
69
+ // const [deeplink,setDeeplink] = useState(null);
70
+ // const flyyConfigDate = "flyy_config_date";
71
+ // const flyyConfigUserId = "user_id";
72
+ // var oldState = null;
73
+ // var currentState = null;
74
+ // var data = null;
75
+
76
+ // useEffect(()=>{
77
+ // fetchData();
78
+ // },[]);
79
+
80
+ // const fetchData = async() => {
81
+ // const sdkInfo = await Flyy.getUserData();
82
+ // const appData = await Flyy.getAppData();
83
+ // const resp = await fetch(`https://${sdkInfo["environment"] == 0 ? "ghc-stage" : "ghc"}.theflyy.com/api/v8/flyy_app_info`, {
84
+ // headers: {
85
+ // "X-Key": sdkInfo["partner_id"],
86
+ // "Content-Type": "application/json",
87
+ // "X-App-Data": appData
88
+ // }
89
+ // });
90
+ // data = await resp.json();
91
+ // if(!data.success){
92
+ // if (Platform.OS === 'android') {
93
+ // ToastAndroid.show(data.message, ToastAndroid.SHORT);
94
+ // } else {
95
+ // // Toast.showWithGravity(data.message, Toast.SHORT, Toast.BOTTOM);
96
+ // }
97
+ // return;
98
+ // }
99
+ // const widgetConfig = data.info.floating_widget_configuration;
100
+
101
+ // if (widgetConfig.icon_url != null && widgetConfig.icon_url != '') {
102
+ // setIconUrl({ uri: widgetConfig.icon_url })
103
+ // } else {
104
+ // setIconUrl(props.buttonIcon)
105
+ // }
106
+
107
+ // if (widgetConfig.color != null && widgetConfig.color != '') {
108
+ // setBackgroundColor(widgetConfig.color)
109
+ // } else {
110
+ // setBackgroundColor(props.backgroundColor)
111
+ // }
112
+
113
+ // if (widgetConfig.size != null && widgetConfig.color != 0) {
114
+ // setButtonSize(parseInt(data.info.floating_widget_configuration.size))
115
+ // } else {
116
+ // setButtonSize(props.buttonHeight)
117
+ // }
118
+
119
+ // //FloatingButton Position
120
+ // if (widgetConfig.position == "bottom_left") {
121
+ // setButtonXPosition(10)
122
+ // } else if (widgetConfig.position == "bottom_right") {
123
+ // setButtonXPosition(windowWidth - 75)
124
+ // } else if (widgetConfig.position == "upper_left") {
125
+ // setButtonXPosition(10)
126
+ // if (Platform.OS === 'android'){
127
+ // setButtonYPosition(10)
128
+ // }else{
129
+ // setButtonYPosition(50)
130
+ // }
131
+ // } else if (widgetConfig.position == "upper_right") {
132
+ // setButtonXPosition(windowWidth - 75)
133
+ // if (Platform.OS === 'android'){
134
+ // setButtonYPosition(10)
135
+ // }else{
136
+ // setButtonYPosition(50)
137
+ // }
138
+ // }
139
+
140
+ // //Set DeepLink
141
+ // if (widgetConfig.deeplink != null && widgetConfig.deeplink != "") {
142
+ // setDeeplink(widgetConfig.deeplink)
143
+ // }
144
+ // //Set Visibility of FloatingButton
145
+ // var currentDate = new Date();
146
+ // const getDate = await AsyncStorage.getItem(flyyConfigDate);
147
+ // const userId = await AsyncStorage.getItem(flyyConfigUserId);
148
+ // var date = new Date(parseInt(getDate));
149
+ // const diffTime = Math.abs(getDate - currentDate);
150
+ // const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))-1;
151
+ // if(diffDays != 0 || userId == null || userId != sdkInfo[flyyConfigUserId]){
152
+ // var data = await Flyy.getAppOccurence(1);
153
+ // await AsyncStorage.setItem(
154
+ // flyyConfigUserId,
155
+ // sdkInfo[flyyConfigUserId]
156
+ // );
157
+ // }
158
+ // const occurrenceCount = await Flyy.getAppOccurence(0);
159
+ // if (widgetConfig.show_to_user && occurrenceCount <= parseInt(widgetConfig.num_times)) {
160
+ // // var numberOfDaysToAdd = widgetConfig.num_days+1;
161
+ // // var result = currentDate.setDate(currentDate.getDate() + numberOfDaysToAdd);
162
+ // if(getDate === null || userId == null || userId != sdkInfo[flyyConfigUserId]){
163
+ // await AsyncStorage.setItem(
164
+ // flyyConfigDate,
165
+ // JSON.stringify(currentDate.getTime())
166
+ // );
167
+ // }
168
+ // const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
169
+ // var date = new Date(parseInt(getDate2));
170
+ // const diffTime = Math.abs(getDate2 - currentDate);
171
+ // const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))-1;
172
+ // //Show widget on same day
173
+ // if(diffDays === 0 || diffDays === -1){
174
+ // setShowWidget(true)
175
+ // }else{
176
+ // //reset occurrence on next day
177
+ // await Flyy.getAppOccurence(1);
178
+ // if(diffDays >= parseInt(widgetConfig.num_days)+1){
179
+ // await AsyncStorage.setItem(
180
+ // flyyConfigDate,
181
+ // JSON.stringify(currentDate.getTime())
182
+ // );
183
+ // setShowWidget(true)
184
+ // }
185
+ // }
186
+ // }else{
187
+ // setShowWidget(false);
188
+ // const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
189
+ // var date = new Date(parseInt(getDate2));
190
+ // const diffTime = Math.abs(getDate2 - currentDate);
191
+ // const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
192
+ // if(diffDays != 1){
193
+ // var data = await Flyy.getAppOccurence(1);
194
+ // }
195
+ // }
196
+ // }
197
+
198
+ // // if(props.show){
199
+ // // if(props.startDate != null && props.startDate != 0){
200
+ // // var now = new Date().getTime();
201
+ // // if(now >= props.startDate && now <= props.endDate){
202
+ // // props.show = true
203
+ // // }else{
204
+ // // props.show = false
205
+ // // }
206
+ // // }
207
+ // // }
208
+
209
+ // // AppState.addEventListener('change', state =>{
210
+ // // console.log('AppState updated to', AppState.currentState)
211
+ // // oldState = currentState;
212
+ // // currentState = state;
213
+ // // if(oldState == null){
214
+ // // console.log('App is newly start :::')
215
+ // // }})
216
+
217
+ // return (
218
+ // // @ts-ignore
219
+ // props.show && showWidget? <Draggable x={buttonXPosition}
220
+ // y={buttonYPosition}
221
+ // minX={props.minX ?? 5}
222
+ // minY={props.minY ?? 5}
223
+ // maxX={props.maxX ?? windowWidth - 5}
224
+ // maxY={props.maxY ?? windowHeight - 5}
225
+ // renderSize={56}
226
+ // // shouldReverse = {true}
227
+ // onDragRelease={props.stick ? () => {
228
+
229
+ // } : null} isCircle>
230
+ // <TouchableOpacity
231
+ // onPress={deeplink != null ? async()=>{
232
+ // if (Platform.OS === 'android' || !deeplink.startsWith("flyy://")) {
233
+ // const supported = await Linking.canOpenURL(deeplink);
234
+ // await Linking.openURL(deeplink);
235
+ // } else {
236
+ // navigateTo(deeplink);
237
+ // }
238
+ // }:props.onPress}
239
+ // style={{
240
+ // height: buttonSize,
241
+ // width: buttonSize,
242
+ // backgroundColor: backgroundColor,
243
+ // borderRadius: buttonSize/2,
244
+ // justifyContent: 'center',
245
+ // alignItems: 'center',
246
+ // }}>
247
+ // <Image source={iconUrl} style={{ height: buttonSize*55/100, width: buttonSize*55/100 }} />
248
+ // <TouchableOpacity
249
+ // onPress={()=>{
250
+ // props.show = false;
251
+ // setShowWidget(false);
252
+ // }}
253
+ // style = {{height: 20, width: 20, backgroundColor: "transparent",position:'absolute',left:buttonSize-11, bottom: buttonSize*72/100}}>
254
+ // <Image source={require('./assets/images/xmark.png')} style={{ height: 18, width: 18, tintColor: "black"}} />
255
+ // </TouchableOpacity>
256
+ // </TouchableOpacity>
257
+ // </Draggable> : <View/>
258
+ // );
259
+ // }
263
260
 
264
261
  const navigateTo = (deeplink) => {
265
262
  let components = deeplink.split("/");
@@ -360,7 +357,7 @@ const navigateTo = (deeplink) => {
360
357
  }
361
358
  break;
362
359
  default:
363
- Toast.showWithGravity("ACTION NOT FOUND", Toast.SHORT, Toast.BOTTOM);
360
+ // Toast.showWithGravity("ACTION NOT FOUND", Toast.SHORT, Toast.BOTTOM);
364
361
 
365
362
  }
366
363
  }
@@ -637,7 +634,7 @@ export const FlyyStories = ({
637
634
  }
638
635
  break;
639
636
  default:
640
- Toast.showWithGravity("ACTION NOT FOUND", Toast.SHORT, Toast.BOTTOM);
637
+ // Toast.showWithGravity("ACTION NOT FOUND", Toast.SHORT, Toast.BOTTOM);
641
638
 
642
639
  }
643
640
  }