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