Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getSyncDeviceInfo() {
let deviceJSON = {};
deviceJSON.manufacturer = getManufacturerSync();
deviceJSON.buildId = DeviceInfo.getBuildIdSync();
deviceJSON.isCameraPresent = DeviceInfo.isCameraPresentSync();
deviceJSON.deviceName = DeviceInfo.getDeviceNameSync();
deviceJSON.usedMemory = DeviceInfo.getUsedMemorySync();
deviceJSON.instanceId = DeviceInfo.getInstanceIdSync();
deviceJSON.installReferrer = DeviceInfo.getInstallReferrerSync();
deviceJSON.isEmulator = DeviceInfo.isEmulatorSync();
deviceJSON.fontScale = DeviceInfo.getFontScaleSync();
deviceJSON.hasNotch = DeviceInfo.hasNotch();
deviceJSON.firstInstallTime = DeviceInfo.getFirstInstallTimeSync();
deviceJSON.lastUpdateTime = DeviceInfo.getLastUpdateTimeSync();
deviceJSON.serialNumber = DeviceInfo.getSerialNumberSync();
deviceJSON.androidId = DeviceInfo.getAndroidIdSync();
deviceJSON.IpAddress = DeviceInfo.getIpAddressSync();
deviceJSON.MacAddress = DeviceInfo.getMacAddressSync(); // needs android.permission.ACCESS_WIFI_STATE
deviceJSON.phoneNumber = DeviceInfo.getPhoneNumberSync(); // needs android.permission.READ_PHONE_STATE
deviceJSON.ApiLevel = DeviceInfo.getApiLevelSync();
deviceJSON.carrier = DeviceInfo.getCarrierSync();
deviceJSON.totalMemory = DeviceInfo.getTotalMemorySync();
deviceJSON.maxMemory = DeviceInfo.getMaxMemorySync();
deviceJSON.totalDiskCapacity = DeviceInfo.getTotalDiskCapacitySync();
deviceJSON.freeDiskStorage = DeviceInfo.getFreeDiskStorageSync();
deviceJSON.batteryLevel = DeviceInfo.getBatteryLevelSync();
deviceJSON.isLandscape = DeviceInfo.isLandscapeSync();
deviceJSON.isAirplaneMode = DeviceInfo.isAirplaneModeSync();
async componentDidMount() {
let deviceJSON = {};
try {
deviceJSON.manufacturer = await getManufacturer();
deviceJSON.buildId = await DeviceInfo.getBuildId();
deviceJSON.isCameraPresent = await DeviceInfo.isCameraPresent();
deviceJSON.deviceName = await DeviceInfo.getDeviceName();
deviceJSON.usedMemory = await DeviceInfo.getUsedMemory();
deviceJSON.userAgent = await DeviceInfo.getUserAgent();
deviceJSON.instanceId = await DeviceInfo.getInstanceId();
deviceJSON.installReferrer = await DeviceInfo.getInstallReferrer();
deviceJSON.isEmulator = await DeviceInfo.isEmulator();
deviceJSON.fontScale = await DeviceInfo.getFontScale();
deviceJSON.hasNotch = await DeviceInfo.hasNotch();
deviceJSON.firstInstallTime = await DeviceInfo.getFirstInstallTime();
deviceJSON.lastUpdateTime = await DeviceInfo.getLastUpdateTime();
deviceJSON.serialNumber = await DeviceInfo.getSerialNumber();
deviceJSON.androidId = await DeviceInfo.getAndroidId();
deviceJSON.IpAddress = await DeviceInfo.getIpAddress();
deviceJSON.MacAddress = await DeviceInfo.getMacAddress(); // needs android.permission.ACCESS_WIFI_STATE
deviceJSON.phoneNumber = await DeviceInfo.getPhoneNumber(); // needs android.permission.READ_PHONE_STATE
deviceJSON.ApiLevel = await DeviceInfo.getApiLevel();
deviceJSON.carrier = await DeviceInfo.getCarrier();
deviceJSON.totalMemory = await DeviceInfo.getTotalMemory();
deviceJSON.maxMemory = await DeviceInfo.getMaxMemory();
deviceJSON.totalDiskCapacity = await DeviceInfo.getTotalDiskCapacity();
deviceJSON.freeDiskStorage = await DeviceInfo.getFreeDiskStorage();
deviceJSON.batteryLevel = await DeviceInfo.getBatteryLevel();
deviceJSON.isLandscape = await DeviceInfo.isLandscape();
deviceJSON.isAirplaneMode = await DeviceInfo.isAirplaneMode();
const { width: WINDOW_WIDTH, height } = Dimensions.get('window');
const IS_ANDROID = Platform.OS === 'android';
const IS_IOS = !IS_ANDROID;
const IS_OVER_IPHONEX = IS_IOS && !Platform.isPad && !Platform.isTVOS && height >= 812;
const WINDOW_HEIGHT = height;
const VIDEO_PLAYER_HEIGHT = parseInt(WINDOW_HEIGHT * 0.625, 10);
const COMMENTS_HEIGHT = WINDOW_HEIGHT - VIDEO_PLAYER_HEIGHT;
const WITH_NOTCH = DeviceInfo.hasNotch();
const REACTIONS = {
LIKE: require('./assets/reaction-like.png'),
LOVE: require('./assets/reaction-love.png'),
HAHA: require('./assets/reaction-haha.png'),
WOW: require('./assets/reaction-wow.png'),
};
export {
IS_ANDROID,
IS_IOS,
IS_OVER_IPHONEX,
REACTIONS,
WINDOW_WIDTH,
WINDOW_HEIGHT,
VIDEO_PLAYER_HEIGHT,
import DeviceInfo from 'react-native-device-info';
import { isBig } from '../../styles/space';
const NOTCH_BOTTOM_PADDING = DeviceInfo.hasNotch() ? 20 : 0;
export const FOOTER_HEIGHT = (64 * (isBig ? 1.2 : 1)) + NOTCH_BOTTOM_PADDING;
componentDidMount = async () => {
const deviceHaveNotch = await DeviceInfo.hasNotch()
if (Platform.OS === 'ios') {
const iosHeight = deviceHaveNotch ? 44: 20
this.setState({navbarHeight: iosHeight, deviceHaveNotch: deviceHaveNotch})
} else if (Platform.OS === 'android') {
this.setState({navbarHeight: StatusBar.currentHeight, deviceHaveNotch: deviceHaveNotch})
}
}
renderWebView() {
return (
{
this.webview = ref;
}}
source={{uri: this.state.uri}}
startInLoadingState={false}
bounces={true}
mixedContentMode="always"
sharedCookiesEnabled={true}
allowsBackForwardNavigationGestures={true}
onNavigationStateChange={this._onNavigationStateChange.bind(this)}
onMessage={e => this._handleMessage(e)}
onShouldStartLoadWithRequest={this._onShouldStartLoadWithRequest.bind(
this,
)}
renderError={this._renderError.bind(this)}
this.onTokenRefreshListener = firebase
.messaging()
.onTokenRefresh(fcmToken => {
if (fcmToken) {
this._siteManager.registerClientId(fcmToken);
}
});
}
this.state = {
hasNotch: true,
deviceId: ""
};
DeviceInfo.hasNotch().then(hasNotch => {
if (hasNotch === false) {
this.setState({ hasNotch: false });
}
});
DeviceInfo.getDeviceId().then(deviceId => {
this.setState({ deviceId: deviceId });
});
}