i am building IoT app with react native. used this package
https://github.com/aws/aws-iot-device-sdk-js
but got error while running app
import React, {Component} from 'react';
import {Platform,
StyleSheet,
Text,
View,
TextInput,
TouchableOpacity,
StatusBar,
} from 'react-native';
import AwsIot from 'aws-iot-device-sdk'
export default class App extends Component {
constructor(props){
super(props)
this.connectToIoT()
}
connectToIoT(){
var device = AwsIot.device({
keyPath:'1d8bea736f-private.pem.key',
certPath: '1d8bea736f-certificate.pem.crt',
caPath: 'AmazonRootCA1.pem',
clientId: 'IoTcloud',
host: 'a3ckca0x6pesml.iot.ap-northeast-2.amazonaws.com'
});
console.log(device)
device
.on('connect', function() {
console.log('connect');
});
device
.on('message', function(topic, payload) {
console.log('message', topic, payload.toString());
});
}
}
here i called this function connectToIoT when app is opened.. keyPath,certPath,caPath files are stored in root of the project
how to get rid of this error and connect my device to aws-iot???
already followed this solution from stack How to implement AWS IoT(device) in React-Native?
but still stuck at this error