1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
import React from 'react';
import OneSignal from 'react-native-onesignal'
import { AppRegistry, View, Text, TouchableOpacity, Image, StyleSheet, } from 'react-native';
import { NavigationActions, StackActions } from 'react-navigation';
import NetInfo from '@react-native-community/netinfo';
import Snackbar from 'react-native-snackbar';
import { API } from "./WebServices/RestClient";
import AsyncStorage from '@react-native-community/async-storage';
//One signal new method since they relesed the SDK new version and havent relese complete documentation as example
//id :25b8f6bc-6ba5-467c-aa1d-8d40aff11a82
const resetAction = StackActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'NavigationRouter' })
]
})
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
name: props.name,
isSubscribed: false,
requiresPrivacyConsent: false,
isLocationShared: false,
inputValue: "",
consoleValue: ""
}
}
async componentDidMount() {
/* O N E S I G N A L S E T U P */
OneSignal.setAppId("25b8f6bc-6ba5-467c-aa1d-8d40aff11a82");
OneSignal.setLogLevel(6, 0);
OneSignal.setRequiresUserPrivacyConsent(this.state.requiresPrivacyConsent);
OneSignal.promptForPushNotificationsWithUserResponse(response => {
this.OSLog("Prompt response:", response);
});
OneSignal.setNotificationOpenedHandler(notification => {
console.log("OneSignal: notification opened:", notification);
});
OneSignal.setInAppMessageClickHandler(event => {
//this.OSLog("OneSignal IAM clicked:", event);
});
OneSignal.addEmailSubscriptionObserver((event) => {
// this.OSLog("OneSignal: email subscription changed: ", event);
});
OneSignal.addSubscriptionObserver(event => {
// this.OSLog("OneSignal: subscription changed:", event);
this.setState({ isSubscribed: event.to.isSubscribed })
});
OneSignal.addPermissionObserver(event => {
// this.OSLog("OneSignal: permission changed:", event);
});
const state = await OneSignal.getDeviceState();
// alert(this.state.userId)
AsyncStorage.setItem('userId', state.userId);
console.log(state.userId)
setTimeout(
() => {
this.Maintenance();
},
2000
);
}
//Maintanace Page for Checking the Heathcheck
Maintenance = () => {
NetInfo.fetch().then(state => {
if (state.type == "none" || state.type == "unknown" || state.type == 'undefined') {
console.log(state.type);
Snackbar.show({
title: 'No Internet Connection',
backgroundColor: '#b52424',
textAlign:'center',
alignItems: 'center',
duration: Snackbar.LENGTH_LONG,
});
// this.props.navigation.dispatch(respropsetAction)
this.props.navigation.dispatch(resetAction)
}
else {
fetch(API + "healthCheck.php")
.then((response) => response.json())
.then((responseJson) => {
console.warn(JSON.stringify(responseJson))
if (responseJson.dbconnect === 'dbconnected') {
console.warn(responseJson);
this.props.navigation.dispatch(resetAction)
}
else {
console.warn(responseJson);
this.props.navigation.navigate('Maintenance');
}
})
.catch((error) => {
this.props.navigation.navigate('Maintenance');
console.log(error);
});
}
});
};
render() {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center", }} >
<Image style={{ width: 400, height: 150 }} source={require('./Images/agile2.png')} />
<Text style={styles.text}>Powered by Novisync</Text>
<Text></Text>
<Text style={styles.text1}>1.0.1 15-09-2021</Text>
</View>
);
};
}
const styles = StyleSheet.create({
text: {
textAlign: 'center',
fontSize: 20,
color: 'black',
},
text: {
textAlign: 'center',
fontSize: 15,
color: 'black',
},
})