//this is my code
//its showing error undefine is not an object "RNDevice.Uniqueid;
import React, { Component } from ‘react’;
import { Platform, StyleSheet, View, Text, TouchableOpacity } from ‘react-native’;
import DeviceInfo from ‘react-native-device-info’;
export default class Myproject extends Component {
constructor(){
super();
this.state={
DeviceID : ' '
}
}
getDeviceID=()=>{
var id = DeviceInfo.getUniqueID();
this.setState({
DeviceID : id
})
}
render() {
return (
<View style={styles.MainContainer}>
<Text style={{textAlign: 'center', fontSize: 20, marginBottom: 10}}>{this.state.DeviceID}</Text>
<TouchableOpacity onPress={this.getDeviceID} activeOpacity={0.5} style={styles.button} >
<Text style={styles.TextStyle}> CLICK HERE TO GET DEVICE UNIQUE ID </Text>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create({
MainContainer :{
justifyContent: ‘center’,
alignItems: ‘center’,
flex:1,
paddingTop: (Platform.OS == ‘ios’ ? 20 : 0)
},
button: {
paddingTop: 10,
paddingBottom: 10,
width: ‘90%’,
backgroundColor: ‘#4CAF50’,
},
TextStyle:{
color:‘#fff’,
textAlign:‘center’,
}
});