如何在React-Native中实现AWS IoT(设备)? [英] How to implement AWS IoT(device) in React-Native?

查看:186
本文介绍了如何在React-Native中实现AWS IoT(设备)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用React-Native实施AWS-IoT(设备).

I am trying to Implement AWS-IoT(device) using React-Native.

我用过这些包裹,

1) aws-iot-device-sdk-js

2) react-native-aws-iot-device-shadows

,使用该软件包时出现很多错误.我可以调试几个,但是没有得到预期的结果.

and got a lot of errors while using the package. I could debug few, but did not get expected results.

我正在为聊天应用程序实现AWS-IoT.

I am Implementing AWS-IoT for Chatting application.

我正在使用REST API成功创建IoT会话并将其作为响应iotEndpoint, region, accessKey, secretKey, sessionToken. 但是使用这些凭据,我无法使用上述程序包连接.

I am successfully creating an IoT session using REST APIs and get these as responses iotEndpoint, region, accessKey, secretKey, sessionToken. But using these credentials I am unable to Connect using the above packages.

推荐答案

我知道了,

步骤1:安装 aws-iot npm软件包npm install --save aws-sdk aws-iot-device-sdk

Step 1: Install aws-iot npm package npm install --save aws-sdk aws-iot-device-sdk

步骤2:安装 nodeify 软件包npm install --save-dev rn-nodeify

步骤3:运行此命令以安装指定的一系列软件包

Step 3: Run this command to install series of packages specified

npx rn-nodeify --install "fs,util,path,tls,stream,buffer,global,process" --hack

请等待,直到所有软件包都安装完毕"

第4步:scripts部分添加Goto package.json->,

Step 4: Goto package.json -> in scripts section add,

"postinstall": "rn-nodeify --install fs,util,path,tls,stream,buffer,global,process --hack"

第5步::安装 asyncstorage-down 软件包npm install --save asyncstorage-down

第6步: rn-nodeify 将自动在本机项目的根目录中生成文件shim.js.只需将其导入index.js文件中,例如import './shim'

Step 6: rn-nodeify will auto-generate a file shim.js in the root part of your react-native project. Just import it in index.js file like this import './shim'

最后,您准备好使用您的aws-iot程序包!!!

Finally, you are ready to use your aws-iot package !!!

建议使用后端的REST API生成上述问题中指定的iot-session密钥.

It is advisable to generate the iot-session keys as specified in the question above using REST API's in the backend.

这篇关于如何在React-Native中实现AWS IoT(设备)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆