Dang Luu
Dang Luu

Reputation: 3

Send push notification to other user in publish chat group quickblox

i'm using quickblox SDK in my project . And i have a question about that.

Plz advise

I want to send push notification to other user in PUBLIC chat group. I can do it with private chat by creating an event and sent to friend like this

    public void createEvent(String message, List<Integer> userIds) {
        StringifyArrayList<Integer> userIds_ = new StringifyArrayList<Integer>(userIds);
        QBEvent event = new QBEvent();
        event.setUserIds(userIds_);
        event.setEnvironment(QBEnvironment.PRODUCTION);
        event.setNotificationType(QBNotificationType.PUSH);
        HashMap<String, Object> messageData = new HashMap<>();
        messageData.put("message", message);
        messageData.put("firID", KApp.getInstance().getCurrentUser().getId());
        messageData.put("name", KApp.getInstance().getCurrentUser().getName());
        event.setMessage(messageData);
QBPushNotifications.createEvent(event).performAsync(new QBEntityCallback<QBEvent>() {
            @Override
            public void onSuccess(QBEvent qbEvent, Bundle bundle) {
                System.out.print("Create event success");
                System.out.print(qbEvent.toString());
            }
  @Override
            public void onError(QBResponseException e) {
                System.out.print("Create event error : " + e.getLocalizedMessage());
            }
        });
    }

But with PUBLIC chat dialog , i can't get list user id, it alway return empty.

How can i send push notification to other member in PUBLIC group ?

Upvotes: 0

Views: 322

Answers (2)

Nir Patel
Nir Patel

Reputation: 367

PUBLIC_GROUPS are open group. The difference between GROUP and PUBLIC_GROUP is that it does not keep associated participant's records like user_ids or unread_count . You have to store your participants data in your own backend server or else locally.

Upvotes: 0

Valentyn Tereshchenko
Valentyn Tereshchenko

Reputation: 636

There is no sense in sending pushes to PUBLIC_GROUP because all users can chatting in public group chat. If you need notify occupants of dialog, use GROUP dialog. Note: in PUBLIC_GROUP you will also not receive pushes about messages when user is offline because PUBLIC_GROUP dialog not contain occupants_ids.

Upvotes: 1

Related Questions