【发布时间】:2017-10-31 14:10:28
【问题描述】:
我正在尝试使用 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"]
},
}
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()
The Subscription Code(iOS Swift):
public static func listenSubscribedChannels(handler: @escaping (_ channel: Channel) -> Void) {
var subscription: Subscription<PFObject>?
let query: PFQuery<PFObject> = PFQuery(className: "Channel").whereKey("subscribers", containedIn: [PFUser.current()!.objectId])
subscription = AppDelegate.liveQueryClient!.subscribe(query).handle(Event.updated) { _, channel in
handler(channel)
}
}
【问题讨论】:
标签: ios swift parse-platform livequery parse-cloud-code