Real-time database UpdateListener

When I synchronize data to Backless through restAPI in the background of the system, new, edit and delete can be seen result in the web page, but my Android device can trigger somtimes, At other times does not trigger the listener, check the statistics, RT service API calls are increased.
here is my call code:

 String queryClause = "mch_id = "+mch_id;
        EventHandler<Map> detailStore = Backendless.Data.of("item").rt();
        detailStore.addCreateListener(queryClause, new AsyncCallback<Map>() {
            @Override
            public void handleResponse(Map response) {
                Log.e("id","新增商品");
                GoodsDetailTable goodsDetail = (GoodsDetailTable) GsonUtils.stringToObject(
                        GsonUtils.mapToJson(response),GoodsDetailTable.class);
                BaseDatabase.getInstance().goodsDao().insertGoodsDetail(goodsDetail);
            }

            @Override
            public void handleFault(BackendlessFault fault) {

            }
        });

        detailStore.addUpdateListener(new AsyncCallback<Map>() {
            @Override
            public void handleResponse(Map response) {
                Log.e("tag","商品修改");
                GoodsDetailTable goodsDetail = (GoodsDetailTable) GsonUtils.stringToObject(
                        GsonUtils.mapToJson(response),GoodsDetailTable.class);

                int rowId = BaseDatabase.getInstance().goodsDao().queryDetailPrimaryKey(goodsDetail.id);
                goodsDetail.rowid = rowId;
                BaseDatabase.getInstance().goodsDao().updateDetailInfo(goodsDetail);
            }

            @Override
            public void handleFault(BackendlessFault fault) {

            }
        });
        detailStore.addDeleteListener(new AsyncCallback<Map>() {
            @Override
            public void handleResponse(Map response) {
                Log.e("tag","删除");

                GoodsDetailTable goodsDetail = (GoodsDetailTable) GsonUtils.stringToObject(
                        GsonUtils.mapToJson(response),GoodsDetailTable.class);
                BaseDatabase.getInstance().goodsDao().deleteGoodsDetail(goodsDetail.id);
            }

            @Override
            public void handleFault(BackendlessFault fault) {

            }
        });

Hello @user1!

Please check the internet connection on your phone, it may be the problem.

Regards,
Alexander

I tried to use a normal network or VPN, but I still could not receive the push

There is another problem, I add the listener can only obtain the data changes after the application installation, but I also need to download some data before the device installation, how should I operate?

I’m sorry, but it’s a little unclear to me exactly what the problem is.
Could you clarify your question, perhaps give an example of what you are trying to do?

Regards,
Alexander

My listeners don’t fire most of the time, even when the network is in good condition, and update listeners don’t fire, regardless of which table’s data changes

Hi, @user1

When you write that the “listeners don’t fire most of the time”, when exactly do they not work? Is the data always updated using the Rest API? Please note that the handler will not be triggered if the data has been updated using the Cloud Code API key. Please make sure you are not using this API key for the update operations.

Regards,
Marina

yes, i sure update date use the Rest API, and every table use same way to add listener,but listeners not be triggered,and then,they be triggered only sometimes

@user1,

please, provide the steps how we can reproduce the issue in your app? And what exactly is supposed to happen after the record is updated?

Regards

modified the data of the table in the website, but my mobile phone did not receive the notification, so THAT I could process the data on the mobile phone

Please, provide us with your AppID. What version of Android SDK are you using?
This will help us better understand the problem.

Regards,
Marina

APPID : 70AC760F-55C2-9C7E-FF8E-78BAFFE1F300;and the version of android SDK is com.backendless:backendless:6.3.2

Hello @user1

What does the mch_id variable look like?
Please note how Condition Syntax should look like.
For example:

String queryClause = "mch_id = '123'";

My code:

    String queryClause = "mch_id = '123'";
    EventHandler<Map> detailStore = Backendless.Data.of( "item" ).rt();
    detailStore.addCreateListener( queryClause, new AsyncCallback<Map>()
    {
      @Override
      public void handleResponse( Map response )
      {
        Log.e( "Create listener success: ", response );
      }

      @Override
      public void handleFault( BackendlessFault fault )
      {
        Log.e( "Create listener fault: ", fault );
      }
    });

    detailStore.addUpdateListener(new AsyncCallback<Map>()
    {
      @Override
      public void handleResponse( Map response )
      {
        Log.e( "Update listener success: ", response );
      }

      @Override
      public void handleFault( BackendlessFault fault )
      {
        Log.e( "Update listener fault: ", fault );
      }
    } );

    detailStore.addDeleteListener( new AsyncCallback<Map>()
    {
      @Override
      public void handleResponse( Map response )
      {
        Log.e( "Delete listener success: ", response );
      }

      @Override
      public void handleFault( BackendlessFault fault )
      {
        Log.e( "Delete listener fault: ", fault );
      }
    });

I created, updated and deleted - all three times the listener worked successfully.

Try with a modified queryClause and logs on failure.
If it does not work for you again, then provide error logs, if any.

Regards,
Vladimir

but if i remove “queryClause”,I have the same problem. My device cannot receive push notifications about the addition, modification and deletion of some data

Hello @user1

queryClause = "mch_id = "+mch_id;

Have you checked Condition Syntax.?
Perhaps it should be something like this queryClause = "mch_id = " + "'" + mch_id + "'"?
Can you show us one example of what queryClause is equal to?

Have you added logging to handleFault? Do you receive some errors here?

My device cannot receive push notifications

Perhaps you sealed yourself and meant listeners?

Please, provide us with your code. Tell us what do you specifically do when waiting for the RT notification in the listener?

Regards,
Viktor