SBirthare
SBirthare

Reputation: 5137

Send message from Android mobile app to Azure IoT Hub

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.

Upvotes: 2

Views: 1377

Answers (2)

Roman Kiss
Roman Kiss

Reputation: 8235

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

Upvotes: 4

Peter Pan
Peter Pan

Reputation: 24138

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.

Upvotes: 1

Related Questions