1

Racking my brains over this.

I cannot get past this issue, my code is producing this error:

LiveQuery does not work, if there is no ParseConnectivityProvider provided.

I tried playing around with the liveQueryURL and no luck. The flutter docs have no concrete example on how to implement this url from the server. I assume from the javaScript video and docs that it's my custom subdomain I created such as customdomain.b4a.io which makes the final url 'wss://customdomain.b4a.io'.

I looked into "connectivityProvider:" arg for the Parse().initialize but found nothing concrete on implementing this.

This is a dart demo project only. Any help or ideas much appreciated!

EDIT: This post does not solve my problem at all. It's also very old.

Is it possible this isn't working because this is a dart program rather than flutter? Wouldn't imagine this being the case...

Code:

import 'package:parse_server_sdk/parse_server_sdk.dart';

Future<void> main(List<String> arguments) async {
  final keyApplicationId = 'XXX';
  final keyClientKey = 'XXX';
  final keyParseServerUrl = 'https://parseapi.back4app.com';
  final liveQueryURL = 'wss://XXX.b4a.io';

  await Parse().initialize(
    keyApplicationId,
    keyParseServerUrl,
    clientKey: keyClientKey,
    liveQueryUrl: liveQueryURL,
    autoSendSessionId: true,
    debug: true,
  );

  final LiveQuery liveQuery = LiveQuery();
  QueryBuilder<ParseObject> query = QueryBuilder<ParseObject>(ParseObject('Color'));
  Subscription subscription = await liveQuery.client.subscribe(query);

  subscription.on(LiveQueryEvent.create, (value) {
    print('Object: ' + value['color']);
    print((value as ParseObject).get('color'));
  });
}
RobbB
  • 1,214
  • 11
  • 39

2 Answers2

2

From https://github.com/parse-community/Parse-SDK-Flutter/issues/543#issuecomment-912783019

please provide a custom ParseConnectivityProvider (connectivityProvider in Parse().initialize). In case you can assume your device has always internet access, the implementation should be as simple as this:

class CustomParseConnectivityProvider extends ParseConnectivityProvider{

Future<ParseConnectivityResult> checkConnectivity() => ParseConnectivityResult.wifi;

Stream<ParseConnectivityResult> get connectivityStream => Stream<ParseConnectivityResult>.empty();

}

(Not tested and typed on a smartphone.)

Maximilian
  • 491
  • 3
  • 11
  • This is in fact the correct solution for a pure dart program & you get to keep HTTPS & WSS. Thank you again! – RobbB Sep 04 '21 at 01:47
1

Unfortunately parse live query in flutter dose not work with https server url. I faced this problem before and it mades me crazy! What I did was in the backend side of parse server, provide both http and https servers. And In client side in flutter just connect to the http server for live queries! And that works fine

  • I’ll be looking into this tonight, thanks for the input! This could easily make one go crazy because it’s so simple looking but such a necessary feature and it’s not working. I do have a concern about loosing https and wss. Is there more security behind the scenes I don’t know about? I’m working with support at back4app also. Hopefully I can get this working or find a better way. – RobbB Sep 03 '21 at 17:16
  • Are you sure? I am prety sure it works on an encrypted channel. Did you use a self signed certificate? – Maximilian Sep 03 '21 at 20:22