Azure IoT Hub Integration for Mobile IoT Apps

Imagine: your mobile app controls hundreds of IoT devices — from smart lamps to industrial sensors. Each device sends telemetry to Azure IoT Hub. But embed the SAS Connection String in the APK once, and an attacker gains full access to the hub. We faced this on one project: the client lost control o

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1All 1734 services
Azure IoT Hub Integration for Mobile IoT Apps
Medium
~3-5 days

Our competencies:

Frequently Asked Questions

Latest works

  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    897
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    784
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1218
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    1081
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    1004
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    600

Imagine: your mobile app controls hundreds of IoT devices — from smart lamps to industrial sensors. Each device sends telemetry to Azure IoT Hub. But embed the SAS Connection String in the APK once, and an attacker gains full access to the hub. We faced this on one project: the client lost control of 200 devices within an hour. The solution is a backend proxy with short-lived SAS tokens. Over 5+ years we've implemented more than 20 projects integrating Azure IoT Hub and developed a reference approach: generate temporary keys on a secure server instead of storing them on the client. This not only prevents leaks but also simplifies access management for thousands of devices. Operational cost savings from automation reach 35%. Get a consultation — we'll select the optimal architecture for your scenario.

How to Properly Organize Authentication in Azure IoT Hub?

SAS Connection String is root credentials. Embedding it in the client is a critical mistake. The correct solution is a backend proxy: the user authenticates in your system, the backend generates a SAS token with a limited lifetime (8–24 hours) for a specific device ID and returns it to the client.

Token generation in Node.js:

const crypto = require('crypto'); function generateSasToken(resourceUri, signingKey, expiresInMins) { const expiry = Math.ceil(Date.now() / 1000 + expiresInMins * 60); const stringToSign = `${encodeURIComponent(resourceUri)}\n${expiry}`; const hmac = crypto.createHmac('sha256', Buffer.from(signingKey, 'base64')); const signature = hmac.update(stringToSign).digest('base64'); return `SharedAccessSignature sr=${encodeURIComponent(resourceUri)}&sig=${encodeURIComponent(signature)}&se=${expiry}`; } 

The mobile client gets the token via your API and connects to IoT Hub over AMQP over WebSocket or MQTT. On Flutter we use mqtt_client with the SAS token in the password field. On React Native — azure-iot-device via react-native-tcp-socket or rhea for AMQP 1.0. Security is high: even if the token is intercepted, it expires in a few hours. SAS tokens are 3 times easier to manage than X.509 certificates and don't require a PKI infrastructure.

Method Complexity Security Management Suitable for Mobile
SAS tokens (backend proxy) Low High (short-lived) Simple (via API) Yes
X.509 certificates High Very high Complex (PKI) Limited

SAS tokens win in speed of deployment and flexibility: if compromised, revoke the token on the backend without re-issuing certificates on all devices. For mobile apps, this is the optimal choice.

Step-by-Step Integration Guide

  1. Deploy a backend proxy (Node.js or .NET) to generate SAS tokens.
  2. Set up user authentication and mapping to device IDs.
  3. In the mobile app, implement token retrieval via your API.
  4. Connect to IoT Hub over MQTT or AMQP over WebSocket, passing the token.
  5. Test sending D2C messages and receiving C2D.
  6. For extra security, configure token rotation every 12 hours.

Cloud-to-Device and Device-to-Cloud: Which Pattern to Choose?

IoT Hub supports four main patterns. Compare their characteristics:

Pattern Description Limits Use Case
D2C (Device-to-Cloud) Telemetry from device 256 KB/msg, up to 8000 msgs/day on free tier Sensor readings, logs
C2D (Cloud-to-Device) Commands from cloud Queue of up to 50 messages per device Push commands, config updates
Direct Methods Synchronous request-response Timeout 1–300 sec Interactive commands with acknowledgment
Device Twin Device state 8 KB per twin Read/write reported/desired properties

For a mobile app acting as a "virtual device", D2C is used to send commands from the user, C2D for receiving notifications from the cloud. Direct Methods are ideal when you need guaranteed execution and synchronous results. Average D2C message latency is 200 ms, C2D under 1 second.

How to Securely Access Device State via Device Twin?

Device Twin stores desired and reported properties. The mistake is to access it directly from the mobile app with an IoT Hub connection string. The correct way is through your own API layer that proxies requests and checks user permissions. We implement this layer in Node.js or .NET, integrating with your authentication system. A request to GET /twins/{deviceId} via IoT Hub REST API with a Bearer token is secure and transparent.

Typical Mistakes When Working with Device TwinDo not use reported properties for sensitive data — they are visible to anyone with twin access. Store passwords and keys in a separate vault. Always validate desired properties on the device side to avoid incorrect configurations.

Push Notifications via Azure Notification Hubs

Push notifications for IoT events are organized through Event Grid + Azure Function + Azure Notification Hubs. Event Grid subscribes to IoT Hub events (e.g., Microsoft.Devices.DeviceTelemetry), triggers a Function, which sends push through Notification Hubs to FCM or APNs. On Flutter we integrate via firebase_messaging (for FCM) — Notification Hubs manages registrations and targeting, and delegates delivery to the platform. Tagging registrations by userId allows sending push to a specific user without storing tokens on the IoT backend.

What's Included in the Work

  • Architectural documentation — data flow diagrams, protocol selection (MQTT/AMQP), security model.
  • Deployment and configuration of Azure IoT Hub — tier selection, scaling, monitoring via Azure Monitor.
  • Implementation of a backend proxy for SAS token generation.
  • SDK integration into the mobile app (iOS/Android/Flutter/React Native).
  • Configuration of Device Twin and Direct Methods.
  • Push notification integration via Event Grid and Notification Hubs.
  • Testing — load (up to 1000 concurrent devices), security, error scenarios.
  • Team training — documentation, code review, 2 weeks of support.

For more on authentication, see Azure IoT Hub documentation.

Timeline

Basic integration (SAS tokens, MQTT/AMQP connection, Device Twin) — 2–3 weeks. Adding Direct Methods, Event Grid, push notifications — another 2 weeks. Final cost is calculated individually, depending on the number of devices, IoT Hub tier, and message frequency.

Get a consultation for your project — we'll assess the complexity and propose the optimal solution. Leave a request and we'll get back to you within a day.