unioil-loyalty-rn-app/app/utils/device.js

47 lines
1.1 KiB
JavaScript

import { Alert, Linking, Platform } from 'react-native';
import DeviceInfo from 'react-native-device-info';
export const getAppVersion = () => {
return DeviceInfo.getVersion();
}
export const getUniqueID = () => {
return DeviceInfo.getUniqueId();
}
export const getOSVersion = () => {
return DeviceInfo.getSystemVersion();
}
export const getOS = () => {
return Platform.OS;
}
export const getModel = () => {
return DeviceInfo.getModel();
}
export const openNumber = (phone) => {
let phoneNumber = phone;
phoneNumber = `${getOS() === 'android' ? 'tel://' : 'telprompt://'}${phone}`;
Linking.canOpenURL(phoneNumber)
.then(supported => {
if (!supported) {
Alert.alert("Information", '\n' + "Call Not Supported")
} else {
Alert.alert("Call Customer Service", '\n' + "You will be redirected to the dialer to call Unioil Customer Service", [
{
text: 'Cancel',
style: 'cancel',
},
{
text: 'OK',
onPress: () => Linking.openURL(phoneNumber)
},
],
{cancelable: true})
}
})
.catch(err => console.log(err));
};