DeviceInfo Module

The Device Info module provides information about the device on which the app is running.

Methods

getDeviceId()

  • Description: Returns the device identifier
  • Return Type: String
  • Method Usage Example: DeviceInfo.getDeviceId()
  • Platforms Supported: All

getSystemName()

  • Description: Returns the system name
  • Return Type: String
  • Method Usage Example: DeviceInfo.getSystemName()
  • Platforms Supported: All

getSystemVersion()

  • Description: Returns the system version
  • Return Type: String
  • Method Usage Example: DeviceInfo.getSystemVersion()
  • Platforms Supported: All

getClosedCaptionsStatus()

  • Description: Returns a promise for the closed captions status
  • Return Type: A promise object of the boolean type
  • Method Usage Example: DeviceInfo.getClosedCaptionsStatus()
  • Platforms Supported: Android, iOS, tvOS, and Tizen

getDeviceLocale()

  • Description: Returns the device locale
  • Return Type: String
  • Method Usage Example: DeviceInfo.getDeviceLocale()
  • Platforms Supported: All

getDeviceName()

  • Description: Returns the user-configurable name of the device, if applicable; e.g. “Susan’s iPhone Xr”
  • Return Type: String
  • Method Usage Example: DeviceInfo.getDeviceName()
  • Platforms Supported: All except Tizen and webOS

getDeviceManufacturer()

  • Description: Returns the name of the device manufacturer, e.g., Apple, Samsung
  • Return Type: String
  • Method Usage Example: DeviceInfo.getDeviceManufacturer()
  • Platforms Supported: All

getDeviceType()

  • Description: Returns the kind of device, e.g., Tv, Handset, Tablet, Desktop
  • Return Type: String
  • Method Usage Example: DeviceInfo.getDeviceType()
  • Platforms Supported: All

getDeviceModel()

  • Description: Returns a readable version of DeviceId; e.g., for iPhone, DeviceId would be “iphone10,2”, and DeviceModel would be “iPhone 8 Plus”
  • Return Type: String
  • Method Usage Example: DeviceInfo.getDeviceModel()
  • Platforms Supported: All. As of You.i Platform 5.3, the content of DeviceModel for Roku Cloud Solution will be corrected to the device model name.

getMACAddress()

  • Description: Returns the MAC address of the device
  • Return Type: String
  • Method Usage Example: DeviceInfo.getMACAddress()
  • Platforms Supported: All except UWP, Roku, iOS, and tvOS

getTimeZone()

  • Description: Returns the time zone of the device in Region/City format
  • Return Type: String
  • Method Usage Example: DeviceInfo.getTimeZone()
  • Platforms Supported: All except PS4

getUniqueID()

  • Description: Returns the unique identifier
  • Return Type: String
  • Method Usage Example: DeviceInfo.getUniqueId()
  • Platforms Supported: All

Usage

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import {
  DeviceInfo 
} from '@youi/react-native-youi';

export default class DeviceInfoExample extends Component {

  constructor(props) {
    super(props);
    DeviceInfo.getTimeZone().then(timeZone => {
      this.setState({timeZone: timeZone});
    }).catch(error => {
      console.log(error);
    });  
  }

  state = {
    deviceId: DeviceInfo.getDeviceId(),
    systemName: DeviceInfo.getSystemName(),
    systemVersion: DeviceInfo.getSystemVersion(),
    deviceType: DeviceInfo.getDeviceType(),
    deviceModel: DeviceInfo.getDeviceModel(),
    deviceName: DeviceInfo.getDeviceName(),
    deviceManufacturer: DeviceInfo.getDeviceManufacturer()
    MACAddress: DeviceInfo.getMACAddress()
  }

  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.heading}>DeviceInfo exposes information about the device the app is running on.</Text>
        <Text style={styles.text}>Device Id: {this.state.deviceId}</Text>
        <Text style={styles.text}>System Name: {this.state.systemName}</Text>
        <Text style={styles.text}>System Version: {this.state.systemVersion}</Text>
        <Text style={styles.text}>Device Type: {this.state.deviceType}</Text>
        <Text style={styles.text}>Device Model: {this.state.deviceModel}</Text>
        <Text style={styles.text}>Device Name: {this.state.deviceName}</Text>
        <Text style={styles.text}>Device Manufacturer: {this.state.deviceManufacturer}</Text>
        <Text style={styles.text}>MAC Address: {this.state.MACAddress}</Text>
        <Text style={styles.text}>Time Zone: {this.state.timeZone}</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    backgroundColor: '#d0d0d0'
  },
  heading: {
    fontSize: 16
  },
  text: {
    fontSize: 12
  }
});