I'm trying to build a mobile chat application using quickblox sdk. Everything is working fine only for the push message. I want a scenerio where users offline can read messages sent to them when they come online, so i stumbled on quickblox push message which uses Google Cloud Messaging. I have done the registration on Google APIs Console. If i send an offline message I can see it on my quickblox account but the notification doesn't show on my mobile device.
When I was doing the Google Cloud Messaging I noticed I was asked for IP address in which I submited the IP of my server. I thinking this is the cause of not seeing the notification on my device. Please I like to know if I am to submit my server IP or quickblox IP. Thanks
I finally got the solution to the problem what I did was to check if user was online if yes use the standard sendMessage method else use quickblox push. That solved it. Bellow is the code used
@Override
public void sendMessage(String message) throws XMPPException {
//Check if user is online or offline
if (isOnline()) {
chat.sendMessage(companionId, message);
}else {
StringifyArrayList<Integer> userId = new StringifyArrayList<>();
userId.add(companionId);
//Using PUSH notification
QBEvent event = new QBEvent();
event.setUserIds(userId);
event.setEnvironment(QBEnvironment.PRODUCTION);
event.setNotificationType(QBNotificationType.PUSH);
event.setMessage(message);
QBMessages.createEvent(event, new QBCallbackImpl() {
@Override
public void onComplete(Result result) {
// TODO Auto-generated method stub
super.onComplete(result);
if(result.isSuccess()) {
//Message sent
}
}
});
}
}