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/src/index.tsx
CHANGED
|
@@ -10,10 +10,13 @@ import {
|
|
|
10
10
|
AppState,
|
|
11
11
|
ToastAndroid,
|
|
12
12
|
Linking,
|
|
13
|
-
FlatList
|
|
13
|
+
FlatList,
|
|
14
|
+
Alert
|
|
14
15
|
} from 'react-native';
|
|
15
16
|
import FlyyCheckinComponent from './flyy_checkin_view';
|
|
16
17
|
import { FlyyStoriesWidget } from './flyy_stories';
|
|
18
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
19
|
+
import Draggable from 'react-native-draggable';
|
|
17
20
|
|
|
18
21
|
type FlyyType = {
|
|
19
22
|
getUserId(arg0: (data: any) => void): unknown;
|
|
@@ -39,224 +42,225 @@ const windowHeight = Dimensions.get('window').height;
|
|
|
39
42
|
const windowWidth = Dimensions.get('window').width;
|
|
40
43
|
|
|
41
44
|
// ****** Flyy Floating Widget ******
|
|
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
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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 - 200);
|
|
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
|
+
Alert.alert(data.message);
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const widgetConfig = data.info.floating_widget_configuration;
|
|
104
|
+
|
|
105
|
+
if (widgetConfig.icon_url != null && widgetConfig.icon_url != '') {
|
|
106
|
+
setIconUrl({ uri: widgetConfig.icon_url })
|
|
107
|
+
} else {
|
|
108
|
+
setIconUrl(props.buttonIcon)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (widgetConfig.color != null && widgetConfig.color != '') {
|
|
112
|
+
setBackgroundColor(widgetConfig.color)
|
|
113
|
+
} else {
|
|
114
|
+
setBackgroundColor(props.backgroundColor)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (widgetConfig.size != null && widgetConfig.color != 0) {
|
|
118
|
+
setButtonSize(parseInt(data.info.floating_widget_configuration.size))
|
|
119
|
+
} else {
|
|
120
|
+
setButtonSize(props.buttonHeight)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//FloatingButton Position
|
|
124
|
+
if (widgetConfig.position == "bottom_left") {
|
|
125
|
+
setButtonXPosition(10)
|
|
126
|
+
} else if (widgetConfig.position == "bottom_right") {
|
|
127
|
+
setButtonXPosition(windowWidth - 75)
|
|
128
|
+
} else if (widgetConfig.position == "upper_left") {
|
|
129
|
+
setButtonXPosition(10)
|
|
130
|
+
if (Platform.OS === 'android'){
|
|
131
|
+
setButtonYPosition(10)
|
|
132
|
+
}else{
|
|
133
|
+
setButtonYPosition(50)
|
|
134
|
+
}
|
|
135
|
+
} else if (widgetConfig.position == "upper_right") {
|
|
136
|
+
setButtonXPosition(windowWidth - 75)
|
|
137
|
+
if (Platform.OS === 'android'){
|
|
138
|
+
setButtonYPosition(10)
|
|
139
|
+
}else{
|
|
140
|
+
setButtonYPosition(50)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//Set DeepLink
|
|
145
|
+
if (widgetConfig.deeplink != null && widgetConfig.deeplink != "") {
|
|
146
|
+
setDeeplink(widgetConfig.deeplink)
|
|
147
|
+
}
|
|
148
|
+
//Set Visibility of FloatingButton
|
|
149
|
+
var currentDate = new Date();
|
|
150
|
+
const getDate = await AsyncStorage.getItem(flyyConfigDate);
|
|
151
|
+
const userId = await AsyncStorage.getItem(flyyConfigUserId);
|
|
152
|
+
var date = new Date(parseInt(getDate));
|
|
153
|
+
const diffTime = Math.abs(getDate - currentDate);
|
|
154
|
+
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))-1;
|
|
155
|
+
if(diffDays != 0 || userId == null || userId != sdkInfo[flyyConfigUserId]){
|
|
156
|
+
var data = await Flyy.getAppOccurence(1);
|
|
157
|
+
await AsyncStorage.setItem(
|
|
158
|
+
flyyConfigUserId,
|
|
159
|
+
sdkInfo[flyyConfigUserId]
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
const occurrenceCount = await Flyy.getAppOccurence(0);
|
|
163
|
+
if (widgetConfig.show_to_user && occurrenceCount <= parseInt(widgetConfig.num_times)) {
|
|
164
|
+
// var numberOfDaysToAdd = widgetConfig.num_days+1;
|
|
165
|
+
// var result = currentDate.setDate(currentDate.getDate() + numberOfDaysToAdd);
|
|
166
|
+
if(getDate === null || userId == null || userId != sdkInfo[flyyConfigUserId]){
|
|
167
|
+
await AsyncStorage.setItem(
|
|
168
|
+
flyyConfigDate,
|
|
169
|
+
JSON.stringify(currentDate.getTime())
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
|
|
173
|
+
var date = new Date(parseInt(getDate2));
|
|
174
|
+
const diffTime = Math.abs(getDate2 - currentDate);
|
|
175
|
+
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))-1;
|
|
176
|
+
//Show widget on same day
|
|
177
|
+
if(diffDays === 0 || diffDays === -1){
|
|
178
|
+
setShowWidget(true)
|
|
179
|
+
}else{
|
|
180
|
+
//reset occurrence on next day
|
|
181
|
+
await Flyy.getAppOccurence(1);
|
|
182
|
+
if(diffDays >= parseInt(widgetConfig.num_days)+1){
|
|
183
|
+
await AsyncStorage.setItem(
|
|
184
|
+
flyyConfigDate,
|
|
185
|
+
JSON.stringify(currentDate.getTime())
|
|
186
|
+
);
|
|
187
|
+
setShowWidget(true)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}else{
|
|
191
|
+
setShowWidget(false);
|
|
192
|
+
const getDate2 = await AsyncStorage.getItem(flyyConfigDate);
|
|
193
|
+
var date = new Date(parseInt(getDate2));
|
|
194
|
+
const diffTime = Math.abs(getDate2 - currentDate);
|
|
195
|
+
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
|
196
|
+
if(diffDays != 1){
|
|
197
|
+
var data = await Flyy.getAppOccurence(1);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// if(props.show){
|
|
203
|
+
// if(props.startDate != null && props.startDate != 0){
|
|
204
|
+
// var now = new Date().getTime();
|
|
205
|
+
// if(now >= props.startDate && now <= props.endDate){
|
|
206
|
+
// props.show = true
|
|
207
|
+
// }else{
|
|
208
|
+
// props.show = false
|
|
209
|
+
// }
|
|
210
|
+
// }
|
|
211
|
+
// }
|
|
212
|
+
|
|
213
|
+
// AppState.addEventListener('change', state =>{
|
|
214
|
+
// console.log('AppState updated to', AppState.currentState)
|
|
215
|
+
// oldState = currentState;
|
|
216
|
+
// currentState = state;
|
|
217
|
+
// if(oldState == null){
|
|
218
|
+
// console.log('App is newly start :::')
|
|
219
|
+
// }})
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
// @ts-ignore
|
|
223
|
+
props.show && showWidget? <Draggable x={buttonXPosition}
|
|
224
|
+
y={buttonYPosition}
|
|
225
|
+
minX={props.minX ?? 5}
|
|
226
|
+
minY={props.minY ?? 5}
|
|
227
|
+
maxX={props.maxX ?? windowWidth - 5}
|
|
228
|
+
maxY={props.maxY ?? windowHeight - 5}
|
|
229
|
+
renderSize={56}
|
|
230
|
+
// shouldReverse = {true}
|
|
231
|
+
onDragRelease={props.stick ? () => {
|
|
232
|
+
|
|
233
|
+
} : null} isCircle>
|
|
234
|
+
<TouchableOpacity
|
|
235
|
+
onPress={deeplink != null ? async()=>{
|
|
236
|
+
if (Platform.OS === 'android' || !deeplink.startsWith("flyy://")) {
|
|
237
|
+
const supported = await Linking.canOpenURL(deeplink);
|
|
238
|
+
await Linking.openURL(deeplink);
|
|
239
|
+
} else {
|
|
240
|
+
navigateTo(deeplink);
|
|
241
|
+
}
|
|
242
|
+
}:props.onPress}
|
|
243
|
+
style={{
|
|
244
|
+
height: buttonSize,
|
|
245
|
+
width: buttonSize,
|
|
246
|
+
backgroundColor: backgroundColor,
|
|
247
|
+
borderRadius: buttonSize/2,
|
|
248
|
+
justifyContent: 'center',
|
|
249
|
+
alignItems: 'center',
|
|
250
|
+
}}>
|
|
251
|
+
<Image source={iconUrl} style={{ height: buttonSize*55/100, width: buttonSize*55/100 }} />
|
|
252
|
+
<TouchableOpacity
|
|
253
|
+
onPress={()=>{
|
|
254
|
+
props.show = false;
|
|
255
|
+
setShowWidget(false);
|
|
256
|
+
}}
|
|
257
|
+
style = {{height: 20, width: 20, backgroundColor: "transparent",position:'absolute',left:buttonSize-11, bottom: buttonSize*72/100}}>
|
|
258
|
+
<Image source={require('./assets/images/xmark.png')} style={{ height: 18, width: 18, tintColor: "black"}} />
|
|
259
|
+
</TouchableOpacity>
|
|
260
|
+
</TouchableOpacity>
|
|
261
|
+
</Draggable> : <View/>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
260
264
|
|
|
261
265
|
const navigateTo = (deeplink) => {
|
|
262
266
|
let components = deeplink.split("/");
|
|
@@ -265,7 +269,7 @@ const navigateTo = (deeplink) => {
|
|
|
265
269
|
case "flyy_offers":
|
|
266
270
|
{
|
|
267
271
|
Flyy.openOffersScreen();
|
|
268
|
-
}
|
|
272
|
+
}
|
|
269
273
|
break;
|
|
270
274
|
case "challenge_details":
|
|
271
275
|
{
|
|
@@ -345,7 +349,7 @@ const navigateTo = (deeplink) => {
|
|
|
345
349
|
{
|
|
346
350
|
Flyy.openFlyyGamesPage();
|
|
347
351
|
}
|
|
348
|
-
break;
|
|
352
|
+
break;
|
|
349
353
|
case "flyy_bonanza":
|
|
350
354
|
{
|
|
351
355
|
Flyy.openFlyyBonanzaPage();
|
|
@@ -358,6 +362,7 @@ const navigateTo = (deeplink) => {
|
|
|
358
362
|
break;
|
|
359
363
|
default:
|
|
360
364
|
// Toast.showWithGravity("ACTION NOT FOUND", Toast.SHORT, Toast.BOTTOM);
|
|
365
|
+
Alert.alert("ACTION NOT FOUND");
|
|
361
366
|
|
|
362
367
|
}
|
|
363
368
|
}
|
|
@@ -518,7 +523,7 @@ export const FlyyStories = ({
|
|
|
518
523
|
},[]);
|
|
519
524
|
|
|
520
525
|
const fetchStoriesData = async() => {
|
|
521
|
-
const sdkInfo = await Flyy.getUserData();
|
|
526
|
+
const sdkInfo = await Flyy.getUserData();
|
|
522
527
|
const appData = await Flyy.getAppData();
|
|
523
528
|
const resp = await fetch(`https://${sdkInfo["environment"] == 0 ? "ghc-stage" : "ghc"}.theflyy.com/api/storyboard`, {
|
|
524
529
|
headers: {
|
|
@@ -536,7 +541,7 @@ export const FlyyStories = ({
|
|
|
536
541
|
case "offers":
|
|
537
542
|
{
|
|
538
543
|
Flyy.openOffersScreen();
|
|
539
|
-
}
|
|
544
|
+
}
|
|
540
545
|
break;
|
|
541
546
|
case "spin_wheel":
|
|
542
547
|
{
|
|
@@ -549,25 +554,25 @@ export const FlyyStories = ({
|
|
|
549
554
|
Flyy.openFlyyChallengeDetailPage(0);
|
|
550
555
|
}
|
|
551
556
|
break;
|
|
552
|
-
|
|
557
|
+
|
|
553
558
|
case "quiz_list":
|
|
554
559
|
{
|
|
555
560
|
Flyy.openFlyyQuizListPage();
|
|
556
561
|
}
|
|
557
562
|
break;
|
|
558
|
-
|
|
563
|
+
|
|
559
564
|
case "stamp_campaign":
|
|
560
565
|
{
|
|
561
566
|
Flyy.openFlyyStampsPage();
|
|
562
567
|
}
|
|
563
568
|
break;
|
|
564
|
-
|
|
569
|
+
|
|
565
570
|
case "campaign_home":
|
|
566
571
|
{
|
|
567
572
|
Flyy.openFlyyStampsPage();
|
|
568
573
|
}
|
|
569
574
|
break;
|
|
570
|
-
|
|
575
|
+
|
|
571
576
|
case "bonanza_details":
|
|
572
577
|
{
|
|
573
578
|
Flyy.openFlyyBonanzaPage();
|
|
@@ -635,7 +640,7 @@ export const FlyyStories = ({
|
|
|
635
640
|
break;
|
|
636
641
|
default:
|
|
637
642
|
// Toast.showWithGravity("ACTION NOT FOUND", Toast.SHORT, Toast.BOTTOM);
|
|
638
|
-
|
|
643
|
+
Alert.alert("ACTION NOT FOUND");
|
|
639
644
|
}
|
|
640
645
|
}
|
|
641
646
|
|
|
@@ -675,7 +680,7 @@ export const FlyyStories = ({
|
|
|
675
680
|
}}
|
|
676
681
|
numberOfLines={2}
|
|
677
682
|
>
|
|
678
|
-
{data.title}
|
|
683
|
+
{data.title}
|
|
679
684
|
</Text>
|
|
680
685
|
</View>
|
|
681
686
|
<View style={{ height: 10 }} />
|
|
@@ -690,5 +695,5 @@ export const FlyyStories = ({
|
|
|
690
695
|
renderItem={({ item }) => <StoriesItem data={item} />}
|
|
691
696
|
keyExtractor={item => item.id}
|
|
692
697
|
/>
|
|
693
|
-
</View>);
|
|
698
|
+
</View>);
|
|
694
699
|
}
|