我有一个iOS和Android应用程序,部署在Parse Server中。现在,我想从云功能中使用LiveQuery SDK!
这是我的云代码:
Parse.Cloud.define("subscribeQueryFunction", function(request, response) {
var query = new Parse.Query("Message");
var subscription = query.subscribe();
subscription.on("create", (object) => {
response.success(object);
});
});
我的Swift代码:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
PFCloud.callFunction(inBackground: "subscribeQueryFunction", withParameters: nil) { (res: Any?, e: Error?) in
print(res)
print(e)
}
}
问题是,客户没有得到回复!虽然,我检查了日志,但似乎已建立订阅:
2017-05-14T16:49:12.442Z - Ran cloud function subscribeQueryFunction for user D7FP3cts5p with:
Input: {}
Result: {"text":"hey","createdAt":"2017-05-14T16:49:12.412Z","updatedAt":"2017-05-14T16:49:12.412Z","objectId":"DXCiumOTal","__type":"Object","className":"Message"}
2017-05-14T16:49:11.101Z - Ran cloud function subscribeQueryFunction for user D7FP3cts5p with:
Input: {}
Result: {"text":"hey","createdAt":"2017-05-14T16:49:11.044Z","updatedAt":"2017-05-14T16:49:11.044Z","objectId":"qkXS6csCKJ","__type":"Object","className":"Message"}
2017-05-14T16:49:09.099Z - Ran cloud function subscribeQueryFunction for user D7FP3cts5p with:
Input: {}
Result: {"text":"hey","createdAt":"2017-05-14T16:49:09.080Z","updatedAt":"2017-05-14T16:49:09.080Z","objectId":"ydnrDHO9AP","__type":"Object","className":"Message"}
2017-05-14T16:47:45.183Z - Create new client: 0
有什么想法吗?
答案 0 :(得分:3)
不在服务器端使用实时查询。 Live Query使用Web套接字与您的客户实时交互。 但是,当你的应用程序关闭时,套接字也会关闭...所以你需要的是推送通知
如果您想制作一个实时的消息传递应用程序,请解析您的需求: