我正在尝试使用Parse LiveQueries.我使用这个Parse"Bootstrap":" https://github.com/parse-community/parse-server ",
我可以看到日志:info: Create new client: 1,
但我只是在查询中没有获得更新,尽管我订阅了它.它甚至没有到达的处理程序subscription.handle.
config.json:
{
"appId": "",
"masterKey": "",
"appName": "",
"cloud": "./cloud/main",
"databaseURI": "",
"publicServerURL": "",
// Relevant
"startLiveQueryServer": true,
"liveQuery": {
"classNames": ["Channel"]
},
}
Run Code Online (Sandbox Code Playgroud)
AppDelegate.swift:
// Initialize Parse.
let configuration = ParseClientConfiguration {
$0.applicationId = self.PARSE_APP_ID
$0.server = self.PARSE_SERVER
}
Parse.initialize(with: configuration)
AppDelegate.liveQueryClient = ParseLiveQuery.Client()
Run Code Online (Sandbox Code Playgroud)
The Subscription Code (iOS Swift):
public static func listenSubscribedChannels(handler: @escaping (_ channel: Channel) -> Void) {
var subscription: Subscription<PFObject>? …Run Code Online (Sandbox Code Playgroud) 我正在尝试从iOS客户端调用解析云函数,但response.success()函数似乎为空。我收到一条错误消息,说response.success不是服务器上的函数。
这是我的解析云函数:
Parse.Cloud.define("pruebaQuery", function(request, response) {
const query = new Parse.Query("grupo");
query.equalTo("name", request.params.grupoName);
query.find()
.then((results) => {
for (let i = 0; i < results.length; ++i) {
var grupoId = results[i].get("grupoId");
console.log("GrupoId: " + grupoId);
}
response.success("Success pruebaQuery");
})
.catch(() => {
response.error("grupo lookup failed");
});
});
Run Code Online (Sandbox Code Playgroud)
这是我从iOS客户端调用的方式:
[PFCloud callFunctionInBackground:@"pruebaQuery" withParameters:@{@"grupoName": @"Kinder 3"}
block:^(NSString *object, NSError *error) {
if (!error) {
NSLog(@"CLOUDCode/SUCCESS: %@", object);
}
else {
NSLog(@"CLOUDCode/ERROR %@ code: %ld", error, (long)[error code]);
}
}];
Run Code Online (Sandbox Code Playgroud)
有什么线索为什么response.success()函数不起作用?