You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
iOS real-time event subscriptions do not working when the app is in the background.
Issue Description: When subscribing to real-time events using the Amplify API, the callback functions work fine when the app is in the foreground. However, once the app is moved to the background, the callbacks are not triggered. I have also enabled background mode from Xcode capabilities, but the issue persists.
Amplify Version: -- 12.12.2
Sample Code: {
func createSubscription() {
subscription = Amplify.API.subscribe(request: .subscription(of: Todo.self, type: .onCreate))
Task {
do {
if let subscriptions = subscription {
for try await subscriptionEvent in subscriptions {
switch subscriptionEvent {
case .connection(let subscriptionConnectionState):
print("Subscription connect state is \(subscriptionConnectionState)")
case .data(let result):
switch result {
case .success(let createdTodo):
isOnCreateSubscriptionEstablished = true
print("Successfully got todo from subscription: \(createdTodo)")
case .failure(let error):
print("Got failed result with \(error.errorDescription)")
}
}
}
}
} catch {
print("Subscription has terminated with \(error)")
}
}
}
}
This behavior is expected. The real-time event subscription relies on a WebSocket connection, but Apple does not support running URLSessionWebSocketTask in the background.
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
iOS real-time event subscriptions do not working when the app is in the background.
Issue Description: When subscribing to real-time events using the Amplify API, the callback functions work fine when the app is in the foreground. However, once the app is moved to the background, the callbacks are not triggered. I have also enabled background mode from Xcode capabilities, but the issue persists.
Amplify Version: -- 12.12.2
Sample Code: {
}
Originally posted by @Santosh2332 in #3437 (comment)
The text was updated successfully, but these errors were encountered: