在 Swift SDK 中获取设备孪生 - Azure IoT 中心

Getting device twin in Swift Sdk - Azure IoT Hub

有没有办法使用 Azure SDK for Swift 从 Azure IoT-Hub 获取设备的设备孪生?

据我所知,我可以使用适用于 NodeJS 的 Azure SDK 获得设备孪生,也可以使用 C 和其他语言。

在文档中它说 swift sdk 是 C sdk 的一部分。但我不知道如何将设备双胞胎放入 swift。我使用文档中给定的代码示例进行了测试,但它只是如何向设备发送消息。

Is there a way to get the device twin of a device from Azure IoT-Hub, using Azure SDK for Swift?

根据这个开放 issue,截至目前,IoTHubDeviceTwin_GetTwin 没有可用的示例使用 Azure SDK for Swift。

或者,按照 Roman, you can get the device twin using REST API 的建议。

GET https://fully-qualified-iothubname.azure-devices.net/twins/{id}?api-version=2020-05-31-preview

对于Swift,您可以使用AsyncHttpClient 1.6.4, SAS token for authorization header and create it using Device Explorer