Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!pushManager.hasAllTokens) {
log('Cannot update tokens yet because they are still loading');
return;
}
console.log('Have device and tokens, will compare to stored server answer');
// this needs to understand what to do with multiple tokens
const jsonTokens = JSON.stringify(pushManager.tokens);
log('Server has: ', device.pushToken);
if (jsonTokens !== device.pushToken) {
log('Sending tokens to the server: ', jsonTokens);
this.props.updateDevice({
token: jsonTokens,
name: DeviceInfo.getDeviceName(),
}).then(() => {
log('Token update was successful');
}).catch((err) => {
log('Token update failed: ', err);
});
} else {
log('Not sending tokens to the server');
}
}
// An All Components Screen is a great way to dev and quick-test components
import React from 'react'
import { View, ScrollView, Text, Image, NetInfo, TouchableOpacity } from 'react-native'
import DeviceInfo from 'react-native-device-info'
import { Metrics, Images } from './DevTheme'
import styles from './Styles/DeviceInfoScreenStyles'
const HARDWARE_DATA = [
{title: 'Device Manufacturer', info: DeviceInfo.getManufacturer()},
{title: 'Device Name', info: DeviceInfo.getDeviceName()},
{title: 'Device Model', info: DeviceInfo.getModel()},
{title: 'Device Unique ID', info: DeviceInfo.getUniqueID()},
{title: 'Device Locale', info: DeviceInfo.getDeviceLocale()},
{title: 'Device Country', info: DeviceInfo.getDeviceCountry()},
{title: 'User Agent', info: DeviceInfo.getUserAgent()},
{title: 'Screen Width', info: Metrics.screenWidth},
{title: 'Screen Height', info: Metrics.screenHeight}
]
const OS_DATA = [
{title: 'Device System Name', info: DeviceInfo.getSystemName()},
{title: 'Device ID', info: DeviceInfo.getDeviceId()},
{title: 'Device Version', info: DeviceInfo.getSystemVersion()}
]
const APP_DATA = [
async function getDeviceInfo() {
return {
AppName: DeviceInfo.getApplicationName(),
Brand: DeviceInfo.getBrand(),
BuildNumber: DeviceInfo.getBuildNumber(),
BundleId: DeviceInfo.getBundleId(),
Carrier: await DeviceInfo.getCarrier(),
DeviceId: DeviceInfo.getDeviceId(),
DeviceName: await DeviceInfo.getDeviceName(), // NOTE(nitya) this might contain PII, monitor
FirstInstallTime: await DeviceInfo.getFirstInstallTime(),
FontScale: await DeviceInfo.getFontScale(),
FreeDiskStorage: await DeviceInfo.getFreeDiskStorage(),
InstallReferrer: await DeviceInfo.getInstallReferrer(),
InstanceID: await DeviceInfo.getInstanceId(),
LastUpdateTime: await DeviceInfo.getLastUpdateTime(),
Manufacturer: await DeviceInfo.getManufacturer(),
MaxMemory: await DeviceInfo.getMaxMemory(),
Model: DeviceInfo.getModel(),
ReadableVersion: DeviceInfo.getReadableVersion(),
SerialNumber: await DeviceInfo.getSerialNumber(),
SystemName: DeviceInfo.getSystemName(),
SystemVersion: DeviceInfo.getSystemVersion(),
TotalDiskCapacity: await DeviceInfo.getTotalDiskCapacity(),
TotalMemory: await DeviceInfo.getTotalMemory(),
UniqueID: DeviceInfo.getUniqueId(),
export const defaultUsername = () => {
if (Platform.OS !== 'ios') {
return ''
}
let deviceName = DeviceInfo.getDeviceName()
const defaultNamesParts = ['iPhone', 'iPad', 'iPod']
if (!deviceName) {
return ''
}
deviceName = deviceName.replace("'s ", ' ')
const hasDefaultName = defaultNamesParts.some(
defaultPart => deviceName.indexOf(defaultPart) !== -1
)
if (hasDefaultName) {
return (
deviceName
// Split device name
// An All Components Screen is a great way to dev and quick-test components
import React from 'react'
import { View, ScrollView, Text, Image, NetInfo, TouchableOpacity } from 'react-native'
import DeviceInfo from 'react-native-device-info'
import Reactotron from 'reactotron-react-native'
import { Metrics, Images } from './DevTheme'
import styles from './Styles/DeviceInfoScreenStyles'
const HARDWARE_DATA = [
{title: 'Device Manufacturer', info: DeviceInfo.getManufacturer()},
{title: 'Device Name', info: DeviceInfo.getDeviceName()},
{title: 'Device Model', info: DeviceInfo.getModel()},
{title: 'Device Unique ID', info: DeviceInfo.getUniqueID()},
{title: 'Device Locale', info: DeviceInfo.getDeviceLocale()},
{title: 'Device Country', info: DeviceInfo.getDeviceCountry()},
{title: 'User Agent', info: DeviceInfo.getUserAgent()},
{title: 'Screen Width', info: Metrics.screenWidth},
{title: 'Screen Height', info: Metrics.screenHeight}
]
const OS_DATA = [
{title: 'Device System Name', info: DeviceInfo.getSystemName()},
{title: 'Device ID', info: DeviceInfo.getDeviceId()},
{title: 'Device Version', info: DeviceInfo.getSystemVersion()}
]
const APP_DATA = [
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();
// @flow
// An All Components Screen is a great way to dev and quick-test components
import React from 'react'
import { View, ScrollView, Text, Image, NetInfo } from 'react-native'
import DeviceInfo from 'react-native-device-info'
import { Metrics, Images } from '../Themes'
import styles from './Styles/DeviceInfoScreenStyles'
const HARDWARE_DATA = [
{title: 'Device Manufacturer', info: DeviceInfo.getManufacturer()},
{title: 'Device Name', info: DeviceInfo.getDeviceName()},
{title: 'Device Model', info: DeviceInfo.getModel()},
{title: 'Device Unique ID', info: DeviceInfo.getUniqueID()},
{title: 'Device Locale', info: DeviceInfo.getDeviceLocale()},
{title: 'Device Country', info: DeviceInfo.getDeviceCountry()},
{title: 'User Agent', info: DeviceInfo.getUserAgent()},
{title: 'Screen Width', info: Metrics.screenWidth},
{title: 'Screen Height', info: Metrics.screenHeight}
]
const OS_DATA = [
{title: 'Device System Name', info: DeviceInfo.getSystemName()},
{title: 'Device ID', info: DeviceInfo.getDeviceId()},
{title: 'Device Version', info: DeviceInfo.getSystemVersion()}
]
const APP_DATA = [
_deviceName() {
let deviceName = "Unknown Mobile Device";
try {
deviceName = DeviceInfo.getDeviceName();
} catch (e) {
// on android maybe this can fail?
}
return deviceName;
}
import { values, pick, omit } from 'lodash';
import { Platform } from 'react-native';
import deviceInfo from 'react-native-device-info';
import { initialize, batchDebugEvents } from './redux/module';
const device = {
bundleId: deviceInfo.getBundleId(),
name: deviceInfo.getDeviceName(),
platform: Platform.OS,
id: deviceInfo.getUniqueID(),
buildNumber: deviceInfo.getBuildNumber(),
country: deviceInfo.getDeviceCountry(),
};
const __config = {
isVisible: false,
logLevel: 'ALL',
eventTypes: [
{
TYPE: 'NETWORK',
CATEGORY_NAME: 'Network request logging',
EVENT_NAME: 'Net. Request',
}
],