我正在Heroku上运行我的parse-server,当我在iOS应用程序上订阅一个事件时,我得不到任何响应。该应用程序能够正确保存和查询服务器,但是当我创建一个新行时,我对Event.Created的订阅不会触发。
下面是我的index.js和我正在使用的Swift代码(删除了密钥和网址)
Index.js:
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || '',
masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'https://myserver.com/parse', // Don't forget to change to https if needed
oauth: {
twitter: {
consumer_key: "", // REQUIRED
consumer_secret: "" // REQUIRED
},
facebook: {
appIds: ""
}
},
liveQuery: {
classNames: ['Message']
}
});
...
var port = process.env.PORT || 1337;
// Initialize a LiveQuery server instance, app is the express app of your Parse Server
var httpServer = require('http').createServer(app);
httpServer.listen(port);
var parseLiveQueryServer = ParseServer.createLiveQueryServer(httpServer);
Swift Code:
let query = PFQuery(className: "Message").whereKey("gameId", equalTo: event!.objectId!)
let subscription = query.subscribe()
subscription.handle(Event.Created) { (query, object) in
print("it worked!")
}