LiveQuery is never subscribing #201
Replies: 3 comments 4 replies
-
The .findAll is loading everything fine as well so I don't think it is the query |
Beta Was this translation helpful? Give feedback.
-
Did you compare your code to the playground examples? Also, you can test the playgrounds (and your code) with a known working server config (https://github.com/netreconlab/Parse-Swift?tab=readme-ov-file#test-drive-parse-swift). After you confirm that works, you can change the settings in the playground files and see if they work with your server. If the playgrounds work, you are doing something incorrectly in your code. Working examples are below: You can also look at this thread along with others: https://community.parseplatform.org/t/livequery-stops-and-does-not-restart-in-the-background/2410 |
Beta Was this translation helpful? Give feedback.
-
I suspect you either have something configured incorrectly on your server or your client as I've tested again on Parse Server 8.2.4 and Parse-Swift 5.12.3. Mind you, there are several unit tests that have been in place for years, which should detect if LiveQuery breaks, so I doubt there's an issue with ParseSwift itself. Did you test using the Playgrounds as I mentioned in #201 (comment)? I get the following logs, which show everything works correctly: Current Swift SDK version is "5.12.3"
Server health is: ok
Saved "GameScore" with the following info:
GameScore ({"createdAt":{"__type":"Date","iso":"2025-10-07T17:35:36.511Z"},"objectId":"xkwx4VHIAQCJmfyR5MIagzsD8Y9aLDZc","points":10,"updatedAt":{"__type":"Date","iso":"2025-10-07T17:35:36.511Z"}})
Updated "GameScore" with the following info:
GameScore ({"createdAt":{"__type":"Date","iso":"2025-10-07T17:35:36.511Z"},"objectId":"xkwx4VHIAQCJmfyR5MIagzsD8Y9aLDZc","points":200,"updatedAt":{"__type":"Date","iso":"2025-10-07T17:35:36.540Z"}})
Saved "GameScore" with
points Optional(10) successfully
Saved "GameScore" with
points Optional(3) successfully
Updated score: Optional(GameScore ({"createdAt":{"__type":"Date","iso":"2025-10-07T17:35:57.059Z"},"objectId":"Dgla6kjDXAos5HBTkGhF5LUeAohf4CAs","points":200,"updatedAt":{"__type":"Date","iso":"2025-10-07T17:35:57.072Z"}}))
Saved "GameScore" with points Optional(10) successfully
Saved "GameScore" with points Optional(3) successfully
Successfully saved: GameScore ({"createdAt":{"__type":"Date","iso":"2025-10-07T17:35:57.093Z"},"objectId":"6X4YTQYUuqbUj6I7iyCPUpCZQtMwNVEv","points":30,"updatedAt":{"__type":"Date","iso":"2025-10-07T17:35:57.093Z"}})
Successfully deleted: GameScore ({"createdAt":{"__type":"Date","iso":"2025-10-07T17:35:57.093Z"},"objectId":"6X4YTQYUuqbUj6I7iyCPUpCZQtMwNVEv","points":30,"updatedAt":{"__type":"Date","iso":"2025-10-07T17:35:57.093Z"}})
Successfully subscribed to new query {"_method":"GET","limit":100,"skip":0,"where":{"points":{"$lt":11}}}
Unsubscribed from {"_method":"GET","limit":100,"skip":0,"where":{"points":{"$lt":11}}}
Successfully pinged server! On the client-side, did you convert to the async/await initialization? On the server-side, did you actually setup LiveQuery for the Lastly, your code doesn't look correct, you need to store the subscription in your @StateObject var and you are not doing that, so your subscription is never being captured. You should also add more debug statements. .task {
do {
let subscribe = try await query.subscribe()
subscription = subscribe // You need to store this on your view so it updates the view everytime there's new data. Similar to my Playgrounds example.
print("\(subscribe)"
} catch {
print(error.localizedDescription)
}
}
.
.
.
// Add more debug statements
Button(action: {
Task {
do {
try await subscription.query.unsubscribe()
print("Unsubscribed")
} catch{
print("\(error)")
}
}
}, label: {
Text("Unsubscribe")
.font(.headline)
.background(Color.red)
.foregroundColor(.white)
.padding()
.cornerRadius(20.0)
}) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey @cbaker6 I switched over to this version of Parse-Swift and everything has been great except LiveQuery
So to prevent me from having to deal with an async view init I am doing this
@StateObject private var subscription: Subscription<Patient> = .init(query: Query<Patient>())
Then on launch of the view I am doing this
But under no circumstances is this every changing from "Not subscribed to query"
What am I doing wrong? The server is setup correctly to have it enabled and the Patient object is listed in the array for livequery.
Information:
Server: Parse Server 6.2.0
SDK: 5.12.3
Xcode: 26
Building for: macOS 26, iOS 26, iPadOS 26, VisionOS 26
Beta Was this translation helpful? Give feedback.
All reactions