我有一个带有LiveQuery的Parse服务器。
我可以通过日志信息连接到实时查询: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");
}];
答案 0 :(得分:1)
正在运行的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")
}