2

我有一个带有 LiveQuery 的 Parse 服务器。

我可以通过 log info: 连接到实时查询Create new client: 1,并且 websocket.org 确认连接,但是没有调用任何完成块。

这是完整的代码:

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");
}];
4

1 回答 1

3

Swift 3.0 正在运行的代码:

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")
    }
于 2016-10-19T17:02:43.223 回答