Skip to content

Livequery not working #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jiya1 opened this issue Apr 29, 2019 · 4 comments
Closed

Livequery not working #165

jiya1 opened this issue Apr 29, 2019 · 4 comments

Comments

@jiya1
Copy link

jiya1 commented Apr 29, 2019

Hello ,
livequery not working, the subscription events returns null;

I/flutter (32224): LiveQuery: : Socket opened
I/flutter (32224): LiveQuery: : ConnectMessage: {op: connect, applicationId: **********, clientKey: }
I/flutter (32224): LiveQuery: : SubscribeMessage: {op: subscribe, requestId: 1, query: {className: posts, where: {name: test}}}
I/flutter (32224): Closure: (dynamic) => Null
I/flutter (32224): LiveQuery: : Listen: {"op":"connected","clientId":"bd62e6c5-615f-4156-8e63-ebf17b1a199e"}
I/flutter (32224): {delete: Closure: (dynamic) => Null}
I/flutter (32224): LiveQuery: : Listen: {"op":"subscribed","clientId":"bd62e6c5-615f-4156-8e63-ebf17b1a199e","requestId":1}
I/flutter (32224): {delete: Closure: (dynamic) => Null}

Thanks in advance

@RodrigoSMarques
Copy link
Contributor

RodrigoSMarques commented Apr 29, 2019

Hi @jiya1

Can you post your app code for me to rate?

Is the server configured for Livequery in the "post" class?

The code below is an example and is working:

    QueryBuilder<ParseObject> query =
        QueryBuilder<ParseObject>(ParseObject('TestAPI'))
          ..whereEqualTo('intNumber', 1);

    //LiveQuery liveQuery = LiveQuery();
    await liveQuery.subscribe(query);

    liveQuery.on(LiveQueryEvent.update, (value) {
      print('*** UPDATE ***: ${DateTime.now().toString()}\n $value');
      print((value as ParseObject).objectId);
      print((value as ParseObject).updatedAt);
      print((value as ParseObject).createdAt);
      print((value as ParseObject).get('objectId'));
      print((value as ParseObject).get('updatedAt'));
      print((value as ParseObject).get('createdAt'));
    });

    liveQuery.on(LiveQueryEvent.delete, (value) {
      print('*** DELETE ***: ${DateTime.now().toString()}\n $value');
      print((value as ParseObject).objectId);
      print((value as ParseObject).updatedAt);
      print((value as ParseObject).createdAt);
      print((value as ParseObject).get('objectId'));
      print((value as ParseObject).get('updatedAt'));
      print((value as ParseObject).get('createdAt'));
    });

    liveQuery.on(LiveQueryEvent.create, (value) {
      print('*** CREATE ***: ${DateTime.now().toString()}\n $value ');
      print((value as ParseObject).objectId);
      print((value as ParseObject).updatedAt);
      print((value as ParseObject).createdAt);
      print((value as ParseObject).get('objectId'));
      print((value as ParseObject).get('updatedAt'));
      print((value as ParseObject).get('createdAt'));
    });

    liveQuery.on(LiveQueryEvent.leave, (value) {
      print('*** LEAVE ***: ${DateTime.now().toString()}\n $value ');
      print((value as ParseObject).objectId);
      print((value as ParseObject).updatedAt);
      print((value as ParseObject).createdAt);
      print((value as ParseObject).get('objectId'));
      print((value as ParseObject).get('updatedAt'));
      print((value as ParseObject).get('createdAt'));
    });

    liveQuery.on(LiveQueryEvent.enter, (value) {
      print('*** LEAVE ***: ${DateTime.now().toString()}\n $value ');
      print((value as ParseObject).objectId);
      print((value as ParseObject).updatedAt);
      print((value as ParseObject).createdAt);
      print((value as ParseObject).get('objectId'));
      print((value as ParseObject).get('updatedAt'));
      print((value as ParseObject).get('createdAt'));
    });

    liveQuery.on(LiveQueryEvent.error, (value) {
      print('*** ERROR ***: ${DateTime.now().toString()}\n $value ');
      if (value is ParseObject) {
        print((value as ParseObject).objectId);
        print((value as ParseObject).updatedAt);
        print((value as ParseObject).createdAt);
        print((value as ParseObject).get('objectId'));
        print((value as ParseObject).get('updatedAt'));
        print((value as ParseObject).get('createdAt'));
      }
    });

@jiya1
Copy link
Author

jiya1 commented Apr 29, 2019

hello @RodrigoSMarques
`
Future initData() async {

Parse().initialize(keyParseApplicationId, keyParseServerUrl,
    masterKey: keyParseMasterKey,
    liveQueryUrl: keyParseServerUrl,
    debug: true);

// Check server is healthy and live - Debug is on in this instance so check logs for result
final ParseResponse response = await Parse().healthCheck();
if (response.success) {
  print(
      "--------------------------------------------------------------------------------------");

  QueryBuilder<ParseObject> query =
      QueryBuilder<ParseObject>(ParseObject('posts'))
        ..whereEqualTo("name", "test");
  LiveQuery liveQuery = LiveQuery();

  await liveQuery.subscribe(query);

  liveQuery.on(LiveQueryEvent.delete, (value) {
    print('*** CREATE ***: ${DateTime.now().toString()}\n $value ');
    print((value as ParseObject).objectId);
    print((value as ParseObject).updatedAt);
    print((value as ParseObject).createdAt);
    print((value as ParseObject).get('objectId'));
    print((value as ParseObject).get('updatedAt'));
    print((value as ParseObject).get('createdAt'));
  });

 
} else {
  print('Server health check failed');
}

}
`

@jiya1
Copy link
Author

jiya1 commented Apr 29, 2019

Sorry .. it was an issue from the server side ..

@jiya1 jiya1 closed this as completed Apr 29, 2019
@zenz
Copy link
Contributor

zenz commented May 28, 2019

It dosn't work.
While I use :
LiveQuery liveQuery = LiveQuery();
await liveQuery.subscribe(query);

It will bring me this error:
NoSuchMethodError (NoSuchMethodError: The method 'contains' was called on null.

in the parse_live_query.dart file, it seems the object was not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants