I’m building a companion app that connects to a custom hardware hub (IoT device) used for home safety monitoring. The hub is installed in homes and is responsible for triggering critical alerts like fire alarms, motion detection, door sensor activity, and baby monitor events.
Current Architecture:
- The hub initially connects to the app via Bluetooth (BLE) for provisioning (to get Wi-Fi credentials).
- Once provisioned, the hub switches to Wi-Fi and communicates with the app via a WebSocket connection to stream real-time event updates.
What I’m Trying to Achieve:
- My goal is to maintain background communication with the hub even when the app is not actively in use, in order to:
- Receive real-time updates from the hub while the device is locked or the app is in background.
- Trigger local notifications immediately when critical sensor events (e.g., fire, motion) occur.
- Ensure persistence across backgrounding, app swipes (force close), and device reboots, if possible.
What I'm Observing:
- On iOS, WebSocket connection is suspended or dropped shortly after the app goes to the background or is locked.
- Even though the I've scheduled periodic fetches, notifications are delayed until the app is reopened, at which point all missed WebSocket messages arrive at once.
- If the app is force-closed or after reboot, no reconnection or notification happens at all.
Key Questions I Have:
- Since the hub is initially provisioned via BLE, and could potentially send BLE flags or triggers for key events, can I use bluetooth-central mode to keep the app active or wake it up on BLE activity?
- Once the hub switches to Wi-Fi and uses WebSocket, is it possible to combine BLE triggers to wake the app and then reconnect to the WebSocket to fetch the full event payload?
- Is there a legitimate and App Store-compliant way to maintain a connection or background task with:
- BLE accessory triggers followed by
- Real-time data processing via Wi-Fi/WebSocket?
- Would this use case qualify as a "companion device" scenario under iOS background execution policies?
- What is the best practice for handling this kind of hybrid BLE + WebSocket alerting flow to ensure timely user notifications, even in background/locked/force-closed states?
Any advice, documentation links, implementation patterns, or examples from similar companion device apps would be greatly appreciated. Thanks in advance!