Implementing IoT Device Interaction via Mobile App

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
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 1 servicesAll 1735 services
Implementing IoT Device Interaction via Mobile App
Complex
~1-2 weeks
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1050
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

IoT Device Integration Through Mobile Applications

IoT integration is not one protocol, but a choice among several depending on physical distance, latency requirements, and energy consumption. An app for controlling a smart bulb in the next room and an app for monitoring industrial sensors on a production floor use different stacks, but face identical problems: connection breaks, state synchronization, and firmware updates.

Transport Selection

Protocol Range Energy Typical Use
BLE 5.0 up to 100m very low wearables, sensors, locks
Wi-Fi up to 50m indoors medium smart outlets, cameras
Zigbee / Z-Wave up to 30m (mesh) low smart home
MQTT over TCP via network depends on network industrial sensors
Matter up to 50m low smart home (new standard)
Thread mesh low Matter devices

Mobile app most often acts as MQTT client or BLE Central. Direct Zigbee control from phone without hub is rare.

MQTT: The Most Common IoT Transport

MQTT is a pub/sub protocol over TCP. Broker (Mosquitto, AWS IoT, HiveMQ) receives messages and distributes to subscribers. Mobile app subscribes to device topics and publishes commands.

iOS—MQTT-Client-Framework or CocoaMQTT:

import CocoaMQTT

let client = CocoaMQTT(clientID: "mobile-\(UUID().uuidString)", host: "broker.example.com", port: 8883)
client.username = "user"
client.password = "pass"
client.enableSSL = true
client.keepAlive = 60
client.delegate = self

client.connect()

// Subscribe after connect:
func mqtt(_ mqtt: CocoaMQTT, didConnectAck ack: CocoaMQTTConnAck) {
    guard ack == .accept else { return }
    mqtt.subscribe("devices/sensor-01/temperature", qos: .qos1)
}

// Receive data:
func mqtt(_ mqtt: CocoaMQTT, didReceiveMessage message: CocoaMQTTMessage, id: UInt16) {
    if let payload = message.string {
        let temp = Double(payload)
        updateUI(temperature: temp)
    }
}

// Publish command:
client.publish("devices/lamp-01/command", withString: "{\"state\":\"on\",\"brightness\":80}")

Android—Paho MQTT Android Service or HiveMQ MQTT Client:

// HiveMQ (more modern, no deprecated API)
val client = MqttClient.builder()
    .useMqttVersion5()
    .serverHost("broker.example.com")
    .serverPort(8883)
    .sslWithDefaultConfig()
    .simpleAuth()
        .username("user")
        .password("pass".toByteArray())
        .applySimpleAuth()
    .buildAsync()

client.connect().whenComplete { _, throwable ->
    if (throwable == null) {
        client.subscribeWith()
            .topicFilter("devices/sensor-01/temperature")
            .qos(MqttQos.AT_LEAST_ONCE)
            .callback { publish ->
                val payload = String(publish.payloadAsBytes)
                // update UI via Handler or LiveData
            }
            .send()
    }
}

QoS and Its Impact on Reliability

  • QoS 0 — at most once. Fast, no confirmation. For frequent updates (temperature every second)—normal.
  • QoS 1 — at least once. With confirmation, possible duplicates. For commands (on/off)—minimum.
  • QoS 2 — exactly once. Delivery guarantee without duplicates. For payments, critical commands.

Last Will Message

MQTT allows setting a message the broker sends when a client unexpectedly disconnects. For IoT this is important: if phone goes offline, other clients should know:

client.willMessage = CocoaMQTTMessage(
    topic: "clients/mobile-app/status",
    string: "{\"online\":false}"
)

Device State Synchronization

Main architectural problem: the app opened—what's the current state of all devices? MQTT doesn't store history by default. Solutions:

Retained messages. Device publishes its state with retain = true flag. Broker stores the last message and immediately returns on subscription. Mobile app on startup subscribes to devices/+/state and gets current states.

Shadow/Digital Twin. AWS IoT Device Shadow, Azure Device Twin—REST API for reading the last known device state. Suits when states are many and retained MQTT is insufficient.

OTA Firmware Updates

If device supports update via mobile app (BLE OTA or MQTT), this is separate work. Standards: Nordic DFU (for nRF chips via BLE), ESP-IDF OTA via HTTP/MQTT, MCU Bootloader via UART-bridge.

Nordic DFU on iOS—iOSDFULibrary, on Android—Android-DFU-Library. Both official libraries from Nordic Semiconductor.

Background Work and Notifications

Mobile app can't keep MQTT connection open constantly in background. For device event notifications—APNS/FCM: broker or backend sends push on state change.

On Android WorkManager + ForegroundService allow keeping MQTT connection if needed. On iOS—Background App Refresh with time-limit restrictions.

Integration timeline: from 1 week (MQTT client with basic control) to 3-4 weeks (full stack with OTA, state synchronization, push notifications). Cost is calculated individually.