Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
this._loadInitialState().done();//获取地理位置信息
InteractionManager.runAfterInteractions(() => {
this.setState({renderPlaceholderOnly: false});
});
console.log("Device Unique ID:"+ DeviceInfo.getUniqueID()); // e.g. FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9
console.log("Device Manufacturer:"+ DeviceInfo.getManufacturer()); // e.g. Apple
console.log("Device Model:"+ DeviceInfo.getModel()); // e.g. iPhone 6
console.log("Device ID:"+DeviceInfo.getDeviceId()); // e.g. iPhone7,2 / or the board on Android e.g. goldfish
console.log("Device Name:"+ DeviceInfo.getSystemName()); // e.g. iPhone OS
console.log("Device Version:"+ DeviceInfo.getSystemVersion()); // e.g. 9.0
console.log("Bundle Id:"+ DeviceInfo.getBundleId()); // e.g. com.learnium.mobile
console.log("Build Number:"+ DeviceInfo.getBuildNumber()); // e.g. 89
console.log("App Version:"+ DeviceInfo.getVersion()); // e.g. 1.1.0
console.log("App Version (Readable) :"+ DeviceInfo.getReadableVersion()); // e.g. 1.1.0.89
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(),
UserAgent: await DeviceInfo.getUserAgent(),
Version: DeviceInfo.getVersion(),
isEmulator: await DeviceInfo.isEmulator(),
isTablet: DeviceInfo.isTablet(),
}
}
// 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 getDeviceInfo = () => ({
apiLevel: Platform.OS === 'ios' ? '' : DeviceInfo.getAPILevel(),
appName: DeviceInfo.getApplicationName(),
brand: DeviceInfo.getBrand(),
buildNumber: DeviceInfo.getBuildNumber(),
bundleId: DeviceInfo.getBundleId(),
deviceCountry: DeviceInfo.getDeviceCountry(),
deviceId: DeviceInfo.getDeviceId(),
deviceLocale: DeviceInfo.getDeviceLocale(),
deviceName: DeviceInfo.getDeviceName(),
firstInstallTime: Platform.OS === 'ios' ? '' : DeviceInfo.getFirstInstallTime(),
freeDiskStorage: DeviceInfo.getFreeDiskStorage(),
referrer: Platform.OS === 'ios' ? '' : DeviceInfo.getInstallReferrer(),
instanceId: Platform.OS === 'ios' ? '' : DeviceInfo.getInstanceID(),
lastUpdateTime: Platform.OS === 'ios' ? '' : DeviceInfo.getLastUpdateTime(),
manufacturer: DeviceInfo.getManufacturer(),
maxMemory: DeviceInfo.getMaxMemory(),
model: DeviceInfo.getModel(),
phoneNumber: Platform.OS === 'ios' ? '' : DeviceInfo.getPhoneNumber(), // 权限http://t.cn/EP3kKhY
readableVersion: DeviceInfo.getReadableVersion(),
serialNumber: Platform.OS === 'ios' ? '' : DeviceInfo.getSerialNumber(),
systemName: DeviceInfo.getSystemName(),
systemVersion: DeviceInfo.getSystemVersion(),
timezone: DeviceInfo.getTimezone(),
storageSize: DeviceInfo.getTotalDiskCapacity(),
totalMemory: DeviceInfo.getTotalMemory(),
uniqueId: DeviceInfo.getUniqueID(),
userAgent: DeviceInfo.getUserAgent(),
version: DeviceInfo.getVersion(),
is24Hour: DeviceInfo.is24Hour(),
isEmulator: DeviceInfo.isEmulator(),
isTablet: DeviceInfo.isTablet(),
var SettingsService = (function() {
var STORAGE_KEY = "@TSLocationManager:settings";
// react-native-device-info
var deviceInfo = {
uuid: DeviceInfo.getUniqueID(),
model: DeviceInfo.getModel(),
platform: DeviceInfo.getSystemName(),
manufacturer: DeviceInfo.getManufacturer(),
version: DeviceInfo.getSystemVersion()
};
var _settings = {
common: [
{name: 'url', group: 'http', inputType: 'text', dataType: 'string', defaultValue: 'http://posttestserver.com/post.php?dir=ionic-cordova-background-geolocation'},
{name: 'autoSync', group: 'http', dataType: 'boolean', inputType: 'select', values: [true, false], defaultValue: true},
{name: 'batchSync', group: 'http', dataType: 'boolean', inputType: 'select', values: [true, false], defaultValue: false},
{name: 'maxBatchSize', group: 'http', dataType: 'integer', inputType: 'select', values: [50, 100, 250, 500], defaultValue: 250},
{name: 'stopOnTerminate', group: 'application', dataType: 'boolean', inputType: 'select', values: [true, false], defaultValue: true},
{name: 'debug', group: 'application', dataType: 'boolean', inputType: 'select', values: [true, false], defaultValue: true},
{name: 'stopAfterElapsedMinutes', group: 'geolocation', dataType: 'number', inputType: 'select', values: [0, 1, 2, 5, 10, 15], defaultValue: 0},
{name: 'activityRecognitionInterval', group: 'activity recognition', dataType: 'integer', inputType: 'select', values: [0, 1000, 10000, 30000, 60000], defaultValue: 10000},
{name: 'stopTimeout', group: 'activity recognition', dataType: 'integer', inputType: 'select', values: [0, 1, 5, 10, 15], defaultValue: 1},
{name: 'disableElasticity', group: 'geolocation', dataType: 'boolean', inputType: 'select', values: [true, false], defaultValue: false},
],
const AWS = require('aws-sdk/dist/aws-sdk-react-native')
const AMA = require('react-native-aws-mobile-analytics')
const DeviceInfo = require('react-native-device-info')
import settings from '../config/settings'
AWS.config.region = settings.awsRegion
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
region: settings.awsRegion,
IdentityPoolId: settings.awsIdentityPoolId
})
const mobileAnalyticsClient = new AMA.default.Manager({
appId: settings.awsAppId,
appTitle: settings.awsTitle,
appVersionName: DeviceInfo.getReadableVersion(),
make: DeviceInfo.getManufacturer(),
model: DeviceInfo.getModel(),
platform: convertPlatformName(DeviceInfo.getSystemName()),
platformVersion: DeviceInfo.getSystemVersion()
})
function initAwsMobileAnalytics () {
mobileAnalyticsClient.initialize(() => {
console.log('Cognito Identity ID: ' + AWS.config.credentials.params.IdentityPoolId)
recordDynamicCustomEvent('APP_STARTED')
})
}
function recordDynamicCustomEvent (type) {
mobileAnalyticsClient.recordEvent(type)
}
import React from 'react';
import {Button, Text, TextInput, ToastAndroid, View} from 'react-native';
import SharedPreferences from 'react-native-shared-preferences';
import Icon from 'react-native-vector-icons/Ionicons'
import DeviceInfo from 'react-native-device-info';
import * as axios from "axios";
const urlRegex = new RegExp("^(http|https)://", "i");
const defaultClientName = DeviceInfo.getManufacturer() + ' ' + DeviceInfo.getDeviceId();
export default class Login extends React.Component {
state = {
tryConnect: null,
url: null,
error: null,
version: null,
name: '',
pass: '',
loggedIn: null,
client: defaultClientName
};
componentDidMount() {
SharedPreferences.getItem("@global:url", (url) => {
if (url) {
this.setState({...this.state, url: url}, this.checkUrl);
getDeviceSpecs: function(state) {
let address = state.user.appIdentifier;
let name = DeviceInfo.getDeviceName();
let description = DeviceInfo.getManufacturer() + " : " + DeviceInfo.getBrand() + ' : ' + DeviceInfo.getDeviceId();
let os = DeviceInfo.getSystemName() + ' ' + DeviceInfo.getSystemVersion();
let deviceType = DeviceInfo.getDeviceId();
let model = DeviceInfo.getModel();
let userAgent = DeviceInfo.getUserAgent();
let locale = DeviceInfo.getDeviceLocale();
return { name, address, description, os, userAgent, locale, deviceType, model };
},
getDeviceInfo(){
var deviceInfo = {
menufacturer: DeviceInfo.getManufacturer(),
model: DeviceInfo.getModel(),
osVersion: DeviceInfo.getSystemVersion(),
releaseVersion: DeviceInfo.getVersion(),
platform: Platform.OS
}
return deviceInfo;
}
};
_getDeviceInfos() {
const infos = [];
infos.push({label:"Device Manufacturer", data: DeviceInfo.getManufacturer()});
infos.push({label:"Device Brand", data: DeviceInfo.getBrand()});
infos.push({label:"Device Model", data: DeviceInfo.getModel()});
infos.push({label:"Device ID", data: DeviceInfo.getDeviceId()});
infos.push({label:"System Name", data: DeviceInfo.getSystemName()});
infos.push({label:"System Version", data: DeviceInfo.getSystemVersion()});
infos.push({label:"Bundle ID", data: DeviceInfo.getBundleId()});
infos.push({label:"Build Number", data: DeviceInfo.getBuildNumber()});
infos.push({label:"App Version", data: DeviceInfo.getVersion()});
infos.push({label:"App Version Readable", data: DeviceInfo.getReadableVersion()});
infos.push({label:"Device name", data: DeviceInfo.getDeviceName()});
infos.push({label:"User Agent", data: DeviceInfo.getUserAgent()});
infos.push({label:"Device Locale", data: DeviceInfo.getDeviceLocale()});
infos.push({label:"Device Country", data: DeviceInfo.getDeviceCountry()});
infos.push({label:"Unique ID", data: DeviceInfo.getUniqueID()});
infos.push({label:"App Instance ID", data: DeviceInfo.getInstanceID()});