unioil-loyalty-rn-app/app/components/netstatus.js

19 lines
483 B
JavaScript

import NetInfo from "@react-native-community/netinfo";
NetInfo.configure({
reachabilityUrl: 'https://google.com',
reachabilityTest: async (response) => response.status === 204,
reachabilityLongTimeout: 60 * 1000, // 60s
reachabilityShortTimeout: 5 * 1000, // 5s
reachabilityRequestTimeout: 15 * 1000, // 15s
});
const netstatus = (callback) => {
NetInfo.fetch().then(state => {
callback(state.isConnected)
});
}
export default {
netstatus
}