dblythy
dblythy

Reputation: 108

Parse LiveQuery not working

I have a Parse server with a LiveQuery.

I can connect to the live query by the log info: Create new client: 1, and websocket.org confirms the connection, however none of the completion blocks are being called.

Here is the full code:

self.pfclient = [[PFLiveQueryClient alloc] init];
PFQuery* query = [PFQuery queryWithClassName:@"Reqs"];
[query whereKey:@"objectId" notEqualTo:@"asdfas"];
self.subscription = [self.pfclient subscribeToQuery:query];

[self.subscription addSubscribeHandler:^(PFQuery * _Nonnull query) {
    NSLog(@"Subscribed");
}];

[self.subscription addUpdateHandler:^(PFQuery * _Nonnull query, PFObject * _Nonnull obj) {
    NSLog(@"Update");
}];

[self.subscription addErrorHandler:^(PFQuery * _Nonnull query, NSError * _Nonnull error) {
    NSLog(@"Error");
}];

Upvotes: 2

Views: 2557

Answers (1)

protspace
protspace

Reputation: 2147

Swift 3.0 Code that is working:

let liveQueryClient = ParseLiveQuery.Client(server: "...", applicationId: ..., clientKey: ..)

...

var subscription: Subscription<PFObject>?

let query: PFQuery<PFObject> = PFQuery(className: "className").whereKey("objectId", equalTo: "168sdf8438")

subscription = liveQueryClient.subscribe(query).handle(Event.created) { _, message in
            print("Object created")
    }

Upvotes: 3

Related Questions