Beispiel #1
0
    // 获取设备信息
    async _getDeviceInfo() {
            // 收集数据,本地存储
            var device_info = await AsyncStorage.getItem(DEVICE_KEY);
            if (device_info == null) {
                var ret = {
                    device_unique: DeviceInfo.getUniqueID(),
                    model: DeviceInfo.getModel(),
                    device: DeviceInfo.getDeviceId(),
                    device_name: DeviceInfo.getDeviceName(),
                    system: DeviceInfo.getSystemName(),
                    system_version: DeviceInfo.getSystemVersion(),
                    bundle: DeviceInfo.getBundleId(),
                    bundle_name: DeviceInfo.getBuildNumber(),
                    version: DeviceInfo.getVersion(),
                    datetime: (new Date()).Format("yyyy-MM-dd hh:mm:ss"),
                };
                navigator.geolocation.getCurrentPosition(
                  (initialPosition) => {
                    ret.latitude = initialPosition.coords.latitude;
                    ret.longitude = initialPosition.coords.longitude;
                    AsyncStorage.setItem(DEVICE_KEY, JSON.stringify(ret));

                  },
                  (error) => {
                    AsyncStorage.setItem(DEVICE_KEY, JSON.stringify(ret));
                  },
                );
            }
    }
Beispiel #2
0
 .then(() => fetch(`${baseUrl}/submit`, {
   method: 'POST',
   headers: {
     'Content-Type': 'application/json',
     // 'Accept': 'application/json',
     // 'Access-Key': 'myAccessKey',  // use in future for safer requests
   },
   body: JSON.stringify({
     image,
     device_id: DeviceInfo.getDeviceId(), // store images/pieces per device in database
   })
 }))
  constructor(props){
    super(props);
    let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
  
    this.state = {
      username : "",
      password: "",
      hobby: "",
      dataSource: ds.cloneWithRows([
        {"name":"Device Unique ID", "item":DeviceInfo.getUniqueID()},
        {"name":"Device Manufacturer", "item":DeviceInfo.getManufacturer()},
        {"name":"Device Model", "item":DeviceInfo.getModel()},
        {"name":"Device ID", "item":DeviceInfo.getDeviceId()},
        {"name":"Device Name", "item":DeviceInfo.getSystemName()},
        {"name":"Bundle Id", "item":DeviceInfo.getBundleId()},
        {"name":"Build Number", "item":DeviceInfo.getBuildNumber()},
        {"name":"User Agent", "item":DeviceInfo.getUserAgent()},
        {"name":"Device Locale", "item":DeviceInfo.getDeviceLocale()},
        {"name":"Device Country", "item":DeviceInfo.getDeviceCountry()}
       ])
    }

  }
Beispiel #4
0
  async ping() {
    var message = {
      time: {
        sent: Moment().utc().format(ISO_DATE_FORMAT),
        lastPing: Moment(this.state.lastPing).utc().format(ISO_DATE_FORMAT),
        lastMessage: Moment(this.state.lastMessage).utc().format(ISO_DATE_FORMAT),
      },
      app: {
        version: APPINFO.buildVersion,
        source: APPINFO.sourceVersion,
        time: Moment(APPINFO.buildTime, APPINFO_DATE_FORMAT).utc().format(ISO_DATE_FORMAT),
      },
      device: {
        id: DeviceInfo.getUniqueID(),
        manufacturer: DeviceInfo.getManufacturer(),
        model: DeviceInfo.getDeviceId(),
        country: DeviceInfo.getDeviceCountry(),
        screen: {
          width: Math.floor(GLOBAL.SCREEN_WIDTH),
          height: Math.floor(GLOBAL.SCREEN_HEIGHT),
          scale: Math.round(GLOBAL.PIXEL_SCALE * 100) / 100,
        },
        platform: {
          os: Platform.OS,
          version: DeviceInfo.getSystemVersion(),
        },
      },
      visited: this.state.visited,
    }

    // console.log('Ping Request', JSON.stringify(message, null, 2))

    try {
      // lastAttempt can be lossy
      this.state.lastAttempt = Moment().valueOf()

      var resp = await fetch(this.url, {
        method: 'POST',
        headers: {
          'Connection': 'close',
          'Accept': 'application/json',
          'Content-Type': 'application/json',
          'Watoto-Type': 'PING',
          'Watoto-Version': '1',
        },
        body: JSON.stringify(message),
      })

      // console.log('Ping', resp)

      if (resp.status == 200 && resp.headers.get('Content-Type') == 'application/json') {
        var type = resp.headers.get('Watoto-Type')
        var latestApp = resp.headers.get('Watoto-Latest-App')
        switch (type) {
          case 'PONG':
            var message = await resp.json()
            this.save({
              lastPing: Moment().valueOf(),
              visited: {},
              latestApp: latestApp,
            })
            break
          case 'PONG-RESET':
            var message = await resp.json()
            this.save(message.state)
            break
          case 'PONG-MESSAGE':
            var message = await resp.json()
            this.save({
              lastPing: Moment().valueOf(),
              lastMessage: Moment(message.time).valueOf(),
              visited: {},
              latestApp: latestApp,
            })
            this.onMessage(message)
            break
        }
      }
    }
    catch (e) {
      console.log(e)
    }
    finally {
      this.schedulePingCheck()
    }
  }
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 = [
  {title: 'Bundle Id', info: DeviceInfo.getBundleId()},
  {title: 'Build Number', info: DeviceInfo.getBuildNumber()},
  {title: 'App Version', info: DeviceInfo.getVersion()},
  {title: 'App Version (Readable)', info: DeviceInfo.getReadableVersion()}
]

export default class DeviceInfoScreen extends React.Component {
  static propTypes = {
    navigator: PropTypes.object.isRequired
  }
Beispiel #6
0
import Device from 'react-native-device-info'

const { FEEDBACK_URL } = require('../AppSettings')

const FeedbackService = {
	FetchFeedback(feedback) {
		const formData = new FormData()
		formData.append('element_1', feedback.comment)
		formData.append('element_2', feedback.name)
		formData.append('element_3', feedback.email)
		formData.append(
			'element_4',
			'Device Manufacturer: ' + Device.getManufacturer() + '\n' +
			'Device Brand: ' + Device.getBrand() + '\n' +
			'Device Model: ' + Device.getModel() + '\n' +
			'Device ID: ' + Device.getDeviceId() + '\n' +
			'System Name: ' + Device.getSystemName() + '\n' +
			'System Version: ' + Device.getSystemVersion() + '\n' +
			'Bundle ID: ' + Device.getBundleId() + '\n' +
			'App Version: ' + Device.getVersion() + '\n' +
			'Build Number: ' + Device.getBuildNumber() + '\n' +
			'Device Name: ' + Device.getDeviceName() + '\n' +
			'User Agent: ' + Device.getUserAgent() + '\n' +
			'Device Locale: ' + Device.getDeviceLocale() + '\n' +
			'Device Country: ' + Device.getDeviceCountry() + '\n' +
			'Timezone: ' + Device.getTimezone()
		)
		formData.append('form_id','175631')
		formData.append('submit_form','1')
		formData.append('page_number','1')
		formData.append('submit_form','Submit')
import React, {
  AppRegistry,
  Component,
  StyleSheet,
  Text,
  View
} from 'react-native';


// sample device id to store in appstate for debugging
var DeviceInfo = require('react-native-device-info');
console.log("Device Unique ID", DeviceInfo.getUniqueID());  // e.g. FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9
// * note this is IDFV on iOS so it will change if all apps from the current apps vendor have been previously uninstalled
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
console.log("Device Name", DeviceInfo.getDeviceName());  // e.g. Becca's iPhone 6
console.log("User Agent", DeviceInfo.getUserAgent()); // e.g. Dalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D)
console.log("Device Locale", DeviceInfo.getDeviceLocale()); // e.g en-US



import JasaRaharjaMobileApp from './App/Root';

AppRegistry.registerComponent('JasaRaharjaMobileApp', () => JasaRaharjaMobileApp);
Beispiel #8
0
'use strict'

import {Dimensions} from 'react-native'
import DeviceInfo from 'react-native-device-info'

const {height, width} = Dimensions.get('window')

export const Device = {
  uniqueId: DeviceInfo.getUniqueID(),
  manufacturer: DeviceInfo.getManufacturer(),
  model: DeviceInfo.getModel(),
  deviceId: DeviceInfo.getDeviceId(),
  deviceName: DeviceInfo.getDeviceName(),
  systemName: DeviceInfo.getSystemName(),
  systemVersion: DeviceInfo.getSystemVersion(),
  bundleId: DeviceInfo.getBundleId(),
  buildNumber: DeviceInfo.getBuildNumber(),
  appVersion: DeviceInfo.getVersion(),
  appVersionReadable: DeviceInfo.getReadableVersion(),
  userAgent: DeviceInfo.getUserAgent(),
  locale: DeviceInfo.getDeviceLocale(),
  country: DeviceInfo.getDeviceCountry(),
  height,
  width
}

const common = require('../../common/__.js')

export const CONSTANTS = common.CONSTANTS
export const UTIL = common.UTIL
export const FETCH = common.FETCH
Beispiel #9
0
    componentDidMount() {

        console.log("Device Unique ID", DeviceInfo.getUniqueID());  // e.g. FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9
// * note this is IDFV on iOS so it will change if all apps from the current apps vendor have been previously uninstalled

        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

        console.log("Device Name", DeviceInfo.getDeviceName());  // e.g. Becca's iPhone 6

        console.log("User Agent", DeviceInfo.getUserAgent()); // e.g. Dalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D)


        const {navigator} = this.props;
        storge.load({
            key:'AppVersion',
            autoSync:true,
        }).then(ret =>{
            version = ret.AppVersion;
            console.log(JSON.stringify(version))
        }).catch(err => {
            // 如果没有找到数据且没有同步方法,
            // 或者有其他异常,则在catch中返回
            console.warn(err);
        })

        this.timer = setTimeout(()=> {
            InteractionManager.runAfterInteractions(() => {
                if (version ===DeviceInfo.getVersion()){
                    navigator.resetTo({
                        component: MainContainer,
                        name: 'Main'
                    });
                }else{
                    storge.save({
                        key:'AppVersion',
                        rawData:{
                            AppVersion:DeviceInfo.getVersion(),
                        }
                        ,
                        expires:null
                    });
                    navigator.resetTo({
                        component: GuidePage,
                        name: 'GuidePage'
                    });
                    console.log(DeviceInfo.getVersion());

                }

            });
        }, 1000)
    }