2
votes

For an IoT project, we need to send messages from mobile application (iOS and Android) to Azure IoT Hub. We were able to do it connecting as a device using MQTT library. However, the device simulator too connect as a device and since both uses same device ID, the existing connection is dropped when both connect to IoT Hub at the same time.

We realized we need to connect mobile apps as a service (not as a device) and for that some research shows we need to use following library.

https://github.com/Azure/azure-iot-sdk-java

https://github.com/Azure/azure-iot-sdk-java/blob/master/service/iot-service-samples/service-client-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/ServiceClientSample.java

However, this java sample uses lot of java specific implementations and which are not supported by Android.

Has anyone faced the same problem?

  1. Which library can we use to achieve above from Android mobile application?
  2. Which library can we use to achieve above from iOS mobile application?

Please let me know if any alternate solution is available.

2
We are working at Android support for our Java service SDK for IoT Hub and you should see progress in the coming month in the repo github.com/Azure/azure-iot-sdk-javaOlivier Bloch

2 Answers

4
votes

You can use a REST API for sending a D2C message to the Azure IoT Hub. The following screen snippet shows an example of this call. Note, that no library is required for this request.

Send D2C Message

  • another solution for your scenario is to use an Azure Function as a pre-processor to the Azure IoT Hub, see the following example:

AzureFunction

Thanks Roman

1
votes

Just as additional content about another solution for your scenario. Based on my understanding and per my experience, I think you can try to create an App service, such as Mobile App for using Custom API at the side of client & backend, or WebApps, etc, to receive the payload which includes custom json properties from your Android App, and forward the payload message using Azure IoTHub SDK for NodeJS or Java to IoTHub.