parse-platformparse-live-query

LiveQuery does not work, if there is no ParseConnectivityProvider provided


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'));
  });
}

Solution

  • 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.)