flutterparse-platformparse-serverback4appparse-live-query

Terminal showing ReSubScription:{} when using LiveQuery in parse_server_sdk_flutter


I followed all steps in documentation, but this function never gets called:

subscription.on(LiveQueryEvent.create,
        (value) {});

All I receive in terminal is this: "ReSubScription:{}".
I am trying to capture the event when one of my classes in the database gets a new record/entry. If requested, I can arrange a demo codebase, but please help me get through this.

PS: I am calling this subscription.on() method in initState() method of a stateful widget, not in main().

UPDATE
I am sharing link of git repo of a minimal app to demonstrate what I did. Here is the link

Please see what have I done incorrect with livequery. Would be grateful for any pointers/guidance.

UPDATE 2nd
Please note, I've hardcoded adminId (objectId of admin logged in). Check TODO plz.

My Testing procedure:

  1. Create a user from backend database manually using Parse Dashboard. Plz Keep username = email.
  2. Open app. Click admin button. Go to AdminLogin page and enter your email and password.
  3. If you are successful, app will navigate to next white screen. This confirms that auth was done successfully.
  4. Open the app again. Click user button. Go to UserForm.
  5. Enter name and hit subscriber button. This will create a new class in Database by the name "Subscribers" and add columns "adminId" and "name" (plz hardcode the adminId in code bcoz you already know it)
  6. Now open the app again and go to admin and login again to move to control panel (white screen).
  7. Wait for the back4app to send trigger/callback. (which shows ReSubScription:{}).

Solution

  • The problem is related to the code below:

        final ParseObject object = ParseObject('Subscribers');
        final response = await object.create();
        if (response.success && response.count > 0) {
          final ParseObject record = response.results[0];
          record.set('name', name);
          record.set('adminId', adminId);
          await record.save();
        }
    

    Note that first you create the object with no adminId and that's why your event is not triggered. You then set the adminId and update the object. In that moment, your enter event should be triggered. Please listen to all different events (create, enter, update, leave, delete) and you will see it happening.