我需要组中的事物列表或AWS的事物列表,我试图从AWSIoT参考中找到解决方案。因此,我使用了以下代码来获取它。以前,我使用来自后端服务的普通API调用来获取它,但我需要与AWS一起充分使用。
func initializeAWS() {
let credentialsProvider = AWSCognitoCredentialsProvider(regionType:AWS_REGION,
identityPoolId:IDENTITY_POOL_ID)
initializeControlPlane(credentialsProvider: credentialsProvider)
}
func initializeControlPlane(credentialsProvider: AWSCredentialsProvider) {
let controlPlaneServiceConfiguration = AWSServiceConfiguration(region:AWS_REGION, credentialsProvider:credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = controlPlaneServiceConfiguration
iot = AWSIoT.default()
let request = AWSIoTListThingsInThingGroupRequest()
request?.thingGroupName = "XXXGroupName"
let output = iot.listThings(inThingGroup: request!)
print("output is (output.result)")
print("error is (output.error)")
}
我在这里使用了AWSIoT
&AWSIoTListThingsInThingGroupRequest
对象获取事物列表我可以知道这是正确的获取方式吗?如果我是CCD_ 3和CCD_。
我试图从Github中找到AWS IOT示例的解决方案,但没有得到任何相关的答案。或者iotDataManager
中有什么东西可以列出清单吗?你能帮我吗?想了解更多信息,我在AWS Github上提出了问题,在事物组中获取事物列表
我已经检查了日志级别的输出是否得到了,所有的配置都是正确的,唯一我不知道的是如何得到东西的响应,得到东西的方法如下。
let credentialsProvider = AWSCognitoCredentialsProvider(regionType:AWS_REGION,
identityPoolId:IDENTITY_POOL_ID)
let controlPlaneServiceConfiguration = AWSServiceConfiguration(region:AWS_REGION, credentialsProvider:credentialsProvider)
AWSServiceManager.default().defaultServiceConfiguration = controlPlaneServiceConfiguration
iot = AWSIoT.default()
let request = AWSIoTListThingsInThingGroupRequest()
request?.thingGroupName = "XXXGroupName"
let output = iot.listThings(inThingGroup: request!)
output.continueOnSuccessWith { (response) -> Any? in
if let result = response.result, let things = result.things {
self.awsDevices = things
completionHandler(true)
}
return self.awsDevices
}