-
Notifications
You must be signed in to change notification settings - Fork 900
Description
We are observing an issue where the MQTT connection to AWS IoT Core gets disconnected whenever the iOS app moves to the background. When the app is brought back to the foreground, the SDK attempts to re-establish the MQTT connection automatically.
This behavior is only observed on iOS.
On Android, the MQTT connection remains alive even when the app is backgrounded.
To Reproduce
Steps to reproduce the behavior:
- Install the iOS app fresh.
- Launch the app.
- Log in using valid credentials.
- Navigate to the Dashboard and move the app to the background.
- After a few seconds, bring the app back to the foreground. The MQTT connection gets disconnected, and for the next few seconds the connection fluctuates between Connected and Disconnected states.
Observed Behavior
iOS app → moves to background
MQTT connection → gets disconnected
App returns to foreground → MQTT reconnect attempt is triggered and fluctuates between Connected and Disconnected states.
Expected Behavior
- MQTT connection should remain active while the app is in background (similar to Android), or not fluctuates between Connected and Disconnected states once application is in foreground
- There should be a recommended way to maintain the connection using iOS background and foreground application state
**Areas of the SDK you are using: AWSMobileClient
Environment(please complete the following information):
- SDK Version: 2.41.0
- Dependency Manager: Cocoapods
- Swift Version : Swift 6
- Xcode Version: 16.2
Device Information (please complete the following information):
- Device: iPhone 11
- iOS Version: 26.1
Questions / Clarification Needed
Is this expected behavior on iOS due to OS limitations?
Does the AWS IoT iOS SDK officially support persistent MQTT connections in background?
Are there recommended approaches (e.g., background modes, keep-alive settings, reconnect strategies)?
Is there any SDK-level configuration to handle this more gracefully?
Additional context
This is particularly impactful for IoT use cases (e.g., real-time status updates) where users expect consistent connectivity similar to Android behavior.