react-native-flyy 1.4.29 → 1.4.30

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