Building the iOS App for a Smart Dog Harness

An owner taps "come here" on their phone. The dog's harness vibrates and plays the owner's own recorded voice. It has to work the same whether the phone is five meters away in the garden or across town at the office. We built the iPhone app, a BLE companion app that talks to the harness over Bluetooth Low Energy, takes a server route when Bluetooth cannot reach it, and runs an AI chat that streams text and spoken voice at once. The hardest decision was none of those. It was deciding that out of range is normal.

How a BLE companion app reaches a smart dog harness: directly over Bluetooth when in range, or through the server when the phone is out of range.

The project at a glance

The project at a glance
FactDetail
ProductiOS companion app for a smart dog harness
PlatformNative iOS 15 and up, Swift and UIKit. No Android app
Built byMobilions. One iOS developer
Not oursThe harness, its firmware, the protocol it speaks and the backend. All client teams
Build cost$10,000 to $15,000 for an iOS app at this scope
Link to the harnessBluetooth Low Energy, JSON messages. Device data uses a separate channel from command replies
When the phone is out of rangeThe command goes through the server instead. Out of range is the normal state, not an error
AI chatText and voice arrive in one response and start before the answer is finished. Voice by OpenAI, the default, or ElevenLabs
A file transfer that drops halfwayCannot resume. The next save sends the whole file again
Training sessions and logsSaved on the phone first, acknowledged to the harness, then uploaded in background batches
StatusBuilt and tested against the client's test firmware. Not in the App Store
Measured speedNone. Every request logs its own duration, but nothing has been stopwatched

The Challenge

A companion app for Bluetooth hardware has one problem, and it is not Bluetooth. The phone and the device are in range of each other for part of the day. An owner walks out the front door and the harness stays with the dog. An app that only really works over Bluetooth is broken for most of the hours the owner has it.

How the BLE Companion App Actually Works

What the owner does, and what the harness does about it. The owner picks a command and sends it. The harness vibrates and plays that command's sound at the volume they chose, in their own recorded voice if they recorded one. A training session is another message on the same Bluetooth channel. The AI chat is the third thing: ask about the dog, and the answer arrives as text and speech at once.

Pairing happens once. Reconnecting happens all day. The app scans for the harness, connects and remembers it, and after that it reconnects by itself whenever the two are close enough. A link that keeps coming and going is the normal case here, not a fault, and the rest of the app is built around that. The Bluetooth layer is plain Core Bluetooth, Apple's own framework, with no third party wrapper.

The app picks the route and the owner never sees the choice. If the phone can reach the harness over Bluetooth, the command goes straight there. The exception is an owner who has set the harness to use Wi-Fi, in which case it goes through the server, the same way it does whenever Bluetooth is out of reach. The app knows which case it is in because the harness reports its own Wi-Fi state in the status it sends over Bluetooth. With Bluetooth gone, a WebSocket carries the dog's live status while the chat is open. This two-route design is the core of most of our IoT app development work.

Both routes write the same history. Over Bluetooth the app adds the command to the chat only after the harness confirms it. The family sees one list, wherever the command came from.

Setup runs over Bluetooth, because the harness is not on the internet yet. The app asks the harness which networks it can see, the owner picks one and types the password, and the app passes both across. Then it waits, because joining a network and registering with the server is not something the app can watch. It asks the server whether the harness has turned up, up to eight times, ten seconds apart, and reports setup as failed if it never does.

Engineering Decisions

01 Every message has to know what reply it expects, if any

  • Decision: each action gets its own reply rule. Clear the timeout the moment a reply arrives, and do not start a timer at all for actions that only answer when they fail.
  • How we got there: we found this while testing the recording screens. Every Bluetooth write started a sixty second timer, and a reply stopped it. That works for almost every action. It does not work for "play this recording on the harness", because the harness only replies when it cannot find the file. Success is silence.
  • What that looked like: a play that had worked looked like a failure. A minute later the timer fired and cleared the Bluetooth callbacks for every screen at once. Nothing crashed, which is what made it hard to find. The screen just stopped updating.
  • What it costs: more bookkeeping per action than one shared timer.

02 Stream text and voice in one response, and be strict about what "finished" means

  • Decision: one request brings back the whole answer, text and voice on the same stream, one small JSON message per line. Text appears word by word and the voice starts as soon as the first piece of audio lands, so nobody waits for a finished audio file.
  • What broke: that only works if the player can tell "the network is slow" apart from "the answer is over". Our first version could not. When audio arrived more slowly than it played, the player ran out of sound, decided the reply was done and stopped. The voice cut out mid sentence while the rest of the answer was still arriving.
  • The fix: playback now ends only when two things are true. The stream has finished, and every piece of audio that arrived has played. An empty buffer on its own means wait.
  • What it costs: a parser that copes with half a line and half a character arriving, and an audio player we maintain a patched copy of.
  • Where the keys are: neither provider key is in the app. It sends the provider's name and the server does the work. We use the same pattern in our voice AI development projects.

03 The phone is the first stop for device data, not the network

  • Decision: data the harness hands over is saved on the phone, acknowledged to the harness, and uploaded later. It arrives on its own Bluetooth channel so it can never interleave with a reply to a command.
  • How the upload runs: in batches, a hundred records at a time while the app is open and thirty while it is in the background, handed to an iOS background URL session so it finishes after the app has gone to sleep. In the background only full batches go, so up to twenty nine records wait for the next batch or for the owner to open the app.
  • What we would change: the app confirms a record as soon as the save starts, not when it finishes. Waiting for the save to complete closes a small gap where the harness believes a record is safe and the phone never stored it.

Sending a Sound the Owner Recorded

Two delivery paths, same as a command. Owners record their own voice for a command, and that file has to cross a link never built for files. The recording goes to the server first, and the server delivers it when Bluetooth cannot reach the harness. When Bluetooth is there, the app sends it across in small pieces, with the file's name and a checksum ahead of them so the harness can tell whether anything arrived broken. The firmware team defined that format and we built the phone side.

A few seconds, and no resume. If Bluetooth drops halfway, the transfer fails, the screen says the sync did not finish, and the next save starts the whole file again.

Engineer's Notes

Treat "out of range" as the normal state, not an error.

An owner's phone leaves Bluetooth range every time they walk out of the front door. If the app only really works over Bluetooth, it's broken for most of the day, and the owner won't blame the phone. They'll blame the harness. So plan the cloud route from day one, even if it ships second. Let Bluetooth be the fast path when it happens to be there. Get that order wrong and every screen ends up built around the wrong assumption.

The other thing we'd push for: check every firmware change on test firmware before it goes anywhere near a real dog. A doc tells you what the firmware team meant. The test build tells you what it actually does, and the two aren't always the same. The app logs every message it sends for the same reason. When the docs and the device disagree, the log shows you which side is wrong.

If we built it again, the first thing we'd fix is the timeout. One timer shared by every Bluetooth message was simple to write and hard to live with. Each message should know what reply it expects, if any. We'd also add Bluetooth state restoration from day one, and the app would wait for a record to be saved before telling the harness it has it. The gap is small, which is exactly why it's easy to miss. They're cheap to get right early and painful to change later.

Mihir Shingala, Full Stack Mobile Developer, Mobilions

Limitations and Lessons

  • The app has no Bluetooth state restoration, so an iOS background shutdown ends the connection until the owner opens the app again. A force quit is worse: iOS does not relaunch an app its owner killed, whatever you build. A day one choice dressed up as a detail.
  • A readable protocol costs bytes on air, and it was still worth it. Plain JSON turned every disagreement with the firmware team into a five minute conversation. A command fits in one write whatever the encoding, so there it is free. A file does not, which is part of why transfers take seconds.
  • Every protocol on this page is somebody else's design. We built the phone side of a format the firmware team owned, so our schedule moved whenever their doc did. Logging every message we sent and testing against their test firmware was the only defence that worked.
  • Hiding the route is right for the owner and awkward for support. A slow reply looks the same whether Bluetooth was missing or the server was busy. The logs carry the difference. The screen does not.

Outcome

Our scope was the iPhone app and its Bluetooth layer, built by one developer from our iOS app development team. Every harness protocol on this page was designed by the client's firmware team, and we built and tested the phone side of each one against their test firmware. The app side is complete, every feature described here works, and it is not in the App Store.

Building a companion app for Bluetooth hardware?

Building a companion app for Bluetooth hardware, a pet wearable or a fitness tracker or a home sensor, with an AI chat or voice layer on top? Book a call and we will walk you through how we would handle range, file transfer and streamed voice for your device.

Frequently Asked Questions

Between $10,000 and $15,000 for the iOS app at this scope: 46 screens covering Bluetooth control of the device, sending audio files to it, a server route for when the phone is out of range, AI chat with streamed voice, and storing and uploading the data the device collects. Hardware, firmware and the backend are separate costs.

Keep each command inside the single write your device accepts, and write it so iOS confirms delivery rather than firing and forgetting. Frame the device's replies so the app can tell where one ends, and rejoin the pieces before parsing. Then give each action its own reply rule: some reply only when they fail.

Send it through your server instead of showing an error, and design that path first rather than second. In our app Bluetooth carries the command when connected and the server when not, landing in the same shared history either way. The owner never learns which route it took.

Have the server send one response of newline delimited JSON, with text tokens and audio chunks in the same stream. Parse it line by line, show tokens as they arrive, and feed audio to a player that accepts pieces. The trap is a player reading an empty buffer as the end of the answer. End playback only when the stream is done and every chunk has played.

A few seconds for a short command sound, and proportionally longer as the recording grows. Bluetooth cannot carry a whole file at once, so it goes in pieces with a checksum the device verifies. Assume no resume unless your firmware supports it: a disconnect halfway means starting again. If the device has Wi-Fi, let the server deliver it.

Save each record on the phone as it arrives and acknowledge it, so a bad network never blocks the device. Upload in batches through a background session, which the system finishes after the app is suspended. Acknowledge only once the record is on disk, and add Bluetooth state restoration if you need the app relaunched.

Read the HTTP status in the task completion delegate, not the close handler. A handshake rejected with 401 or 403 never reaches the close callback, because that fires only after a successful upgrade, so a token problem looks like a silent failure. Our app reads it there, refreshes the token and reconnects. Everything else follows the normal retry policy.

Under a cent per reply with OpenAI voice, the default. Voice is billed per character, so answer length sets the bill: a spoken reply of about a hundred words is roughly six hundred characters, which costs under one cent at the list price we checked on 26 November 2026. OpenAI retires its per character speech models on 6 January 2027, and the replacement it names bills per audio token, so redo this math then.

Let's build your next big thing

Let's build your next big thing. Share your idea and get a free consultation. We respond within one business day.

Call Us (USA)
+1-856-524-5593

Get a Free Quote

A senior engineer replies within one business day · NDA on request · no obligation · you own the code and IP.