ParseLiveQuery
ParseLiveQuery copied to clipboard
Calling Subscription more than one time
Works fine
When I subscribe first time its work fine
Not working
when i move back from current screen after unsubscribing and come back to same screen it invoking more than one time
isSubscribed = false;
if(!isSubscribed) {
isSubscribed = true;
sub = new BaseQuery.Builder("Message")
.addField("message")
.addField(MSG_RECEIVER_USER_ID)
.addField(MSG_SENDER_USER_ID)
.build()
.subscribe();
sub.on(LiveQueryEvent.CREATE, new OnListener() {
@Override
public void on(JSONObject object) {
Log.e(TAG, "on: " + object);
// Action to be executed here when an object that matches
// The filter you set up
}
});
}else{
if(sub != null){
if(sub.isSubscribed()){
sub.unsubscribe();
isSubscribed = false;
}
}
}
}
output (invoking more than one times)
on: {"op":"create","clientId":22,"requestId":2,"object":{"className":"Message",
"objectId":"MoItqxnFGC","updatedAt":"2017-02-27T10:37:08.679Z","createdAt":"2017-02-27T10:37:08.679Z","message":"dhjjf",
"receiver_user_id":"Rb4bg9Nv5z","sender_user_id":"ewaCQ6Y2I4"}}
on: {"op":"create","clientId":22,"requestId":2,"object":{"className":"Message",
"objectId":"MoItqxnFGC","updatedAt":"2017-02-27T10:37:08.679Z","createdAt":"2017-02-27T10:37:08.679Z","message":"dhjjf",
"receiver_user_id":"Rb4bg9Nv5z","sender_user_id":"ewaCQ6Y2I4"}}
hi facing same issue here @TGIO would appreciate some information and how to solve
for anyone facing this issue, add the actual project as library module , instead of compile "xxxxxx" that solve my problem