0

I am trying to get live queries working with iOS and Parse-Server. The following is my setup for my Parse-Server:

...

let api = new ParseServer({
    databaseURI: databaseUri || constants.DATABASE_URI,
    cloud: process.env.CLOUD_CODE_MAIN || constants.CLOUD_CODE_MAIN,
    appId: process.env.APP_ID || constants.APP_ID,
    masterKey: process.env.MASTER_KEY || constants.MASTER_KEY,
    serverURL: process.env.SERVER_URL || constants.LOCAL_SERVER_URL,
    fileKey: process.env.FILE_KEY || constants.FILE_KEY,
    appName: process.env.APP_NAME || constants.APP_NAME,
    publicServerURL: process.env.SERVER_URL || constants.LOCAL_SERVER_URL,
    liveQuery: {
        classNames: [Parse.User]
    }
});

...

let port = process.env.PORT || 1337;

let httpServer = require('http').createServer(app);
httpServer.listen(port, function () {
    console.log('parse_server running on port ' + port + '.');
});

ParseServer.createLiveQueryServer(httpServer, {logLevel: 'VERBOSE'});

...

And this is my code in the iOS app:

let liveQueryClient = ParseLiveQuery.Client(server: "ws://serverurl/", applicationId: "appID", clientKey: "clientKey")

let query = PFUser.query()?.whereKey("objectId", equalTo: "ABC123") as! PFQuery<PFUser>

let subscription = self.liveQueryClient.subscribe(query).handle(Event.updated) { _, user in
    debugprint("\(user)")
}

Debugging on local, I can see the user is connecting using the socket because the server logs:

info: Create new client: 0

and when I disconnect, the server logs:

info: Client disconnect: 0

My problem is that whenever I modify the User object in Parse Dashboard, nothings logs on the server side, and the client doesn't receive any events.

Is there another way to set this up?

Can the User class not be used in live queries?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
RPK
  • 1,830
  • 14
  • 30
  • I'm also struggling with your problem... Tried everything, waiting for a solution. – Etgar May 31 '17 at 14:31
  • Hi, Look at this answer https://stackoverflow.com/a/44721816/5928180, it might help you with your problem. – Zonily Jame Aug 18 '17 at 00:14
  • Hi, the "User" class in Parse is actually represented on the database as "_User", so wherever you have to specify the class of ParseObject you are trying to receive, make sure to include the underscore. – Alex Fanat Aug 29 '17 at 23:47

1 Answers1

0

I am not sure about IOS code however this part e.g:

liveQuery: {
    classNames: ["YourColumnNameInDatabase","AnotherColumnName"]
}

Make sure to check that you are subscribing to the correct ClassName(ColumnName in Db) Hope this helps a little...

Lyon
  • 272
  • 1
  • 12
  • I checked it and it's all good. Even tried changing it from `"Parse.User"` to `"User"` and that didn't work either. Thanks for the suggestion though. – RPK Apr 21 '17 at 02:54