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 ?
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.
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.
Related
Developing a Chat APP Group function using MucLight XEP with smack library
,the problem is I m able to send the message to group successfully but when its come to message listening I get confused,in smack library we have
multiUserChatLight.addMessageListener (new MessageListener ( ) {
#Override
public void processMessage(Message message) {
}
});
But its group Specific listener , means Its only listen to multiuserchatlight reference group, which some how not what I need,because every time whenever I reconnected with the chat server I need to register this listener against every group in which I involved , which is not good in opinion .
the other approach is to register packetlistener which is also little problematic with some cases like as member of group I received the message which I send into the group ,
So there is any alternative?
Can some one tell me where i am wrong ?
whenever you connected with server and authenticated you need to register always message listener. i have done using StanzaListener to add MucLight listener.
public RegisterXmppListener registerXmppListener;
public void registerMessageListener(){
debugLog("registerMessageListener");
if(mStanzaListener !=null)
connection.removeSyncStanzaListener(mStanzaListener);
StanzaTypeFilter filter = new StanzaTypeFilter(Message.class);
mStanzaListener=new StanzaListener() {
#Override
public void processStanza(Stanza stanza) throws SmackException.NotConnectedException, InterruptedException {
if(registerXmppListener!=null) {
registerXmppListener.onMessageReceived(stanza);
}
}
};
connection.addSyncStanzaListener(mStanzaListener, filter);
}
registerMessageListener register when you have authenticated with server.
Basically I am retrieving QBUser list from quickblox server and I don't want Admin(application registered - account owner) name to be listed as QBUser.
Example :
I signup quickblox with name "A" to register "xyz" application.
Afterwards I add certain users ("B","C","D") to application "xyz".
Now when I request user list API for "xyz" application I want only ("B","C","D") in response, but the issue is user list contains all users ("A","B","C","D").
I doubt there's a query to exempt a particular user from the query but you can handle that in your code when the user list is returned.
QBPagedRequestBuilder pagedRequestBuilder = new QBPagedRequestBuilder();
pagedRequestBuilder.setPage(1);
pagedRequestBuilder.setPerPage(50);
QBUsers.getUsers(pagedRequestBuilder, new QBEntityCallback<ArrayList<QBUser>>() {
#Override
public void onSuccess(ArrayList<QBUser> users, Bundle params) {
for(QBUser user: users){
if(user.getFullName().equals("A"))
users.remove(user);
}
//go ahead to use users list without A
}
#Override
public void onError(QBResponseException errors) {
}
});
Hope it helps.
How to get incoming messages from specific user?
For example:
VKRequest requestOutMessages = VKApi.messages().get(VKParameters.from(VKApiConst.USER_ID, vkUserId));
VKRequest requestInMessages = VKApi.messages().get(VKParameters.from(VKApiConst.OUT, vkUserId));
Which is giving me all 40 last messages from all my last conversations.
EDIT
public class VKApiMessagesExtension extends VKApiMessages {
public VKRequest getHistory(VKParameters params) {
return prepareRequest("getHistory", params, new VKParser() {
#Override
public Object createModel(JSONObject object) {
return new VKApiGetMessagesResponse(object);
}
});
}
}
Messages in VK can only be accessed by the user involved in the conversation. If you use the VK API to get messages, they will be for the logged in user.
In other words, messages are private.
The documentation states that "Returns a list of the current user's incoming or outgoing private messages."
I am new to parse. I have created an android application in which I have to send the push notification by click on the send button. I have successfully stored data to its parse database like Object Id, device type, device token, push type (which is created by default under the installation class).
I have also add some custom column under installation class like age, friend id, gender and retrieve the correspondence Object id in the edit text.
But when I try to send push notification by click on send button, I usually get this error:
com.parse.Parse Exception: Clients aren't allowed to perform the find operation on the installation collection
The query which I am using to send push notification with object-id corresponding to the given Friend-id is:
sndpush.setOnClickListener(new OnClickListener() {
#SuppressWarnings("unchecked")
#Override
public void onClick(View v) {
JSONObject obj;
try {
obj =new JSONObject();
obj.put("alert","erwerwe");
obj.put("action","com.parse.pushnotifications.UPDATE_STATUS");
obj.put("customdata","My string");
ParsePush push = new ParsePush();
ParseQuery query = ParseInstallation.getQuery();
query.whereEqualTo("objectId",objectidEditText.getText().toString() );
push.setQuery(query);
push.setData(obj);
push.sendInBackground();
}
catch (JSONException e)
{
e.printStackTrace();
}
}
});
I do google and R&D and I get the idea that we have no permission to send push by get the object id from default class that is installation class.
I have created a new class in parse.com where I have insert some data like age, friend-id and also able to retrieve object-id corresponding to friend id. But when ever I tried to send push notification by supplying Object-id in it, I get the error:
java.lang.IllegalArgumentException: Can only push to a query for Installations
Here is the code:
// Get the user's Id from parse.com.
#SuppressWarnings({ "rawtypes", "unchecked" })
public void getObjectId() {
#SuppressWarnings("rawtypes")
ParseQuery query = new ParseQuery("_installation");
query.whereEqualTo("FriendId", FrndTextString);
query.getFirstInBackground(new GetCallback() {
public void done(ParseObject object, ParseException e) {
if (object == null) {
Log.d("objectId", "The getFirst request failed.");
} else {
String objectid = object.getObjectId();
objectidEditText.setText(objectid);
sndpush.setEnabled(true);
Log.d("objectId", "Retrieved the object.");
}
}
});
}
I have followed the link from stack overflow to send push notification to a specific user. But there is no proper result.
send push notification with parse to single device
Please tell me where I am wrong. My main question is how can I send a push notification from one device to another.
Here is my complete code:
http://piratepad.net/ep/pad/view/ro.WwZ9v6FX1a6/latest
I'm trying to add the feature of push notifications in my app and i did everything correctly according to many guides but the push is never being sent (i don't see it in the push list in parse). On the contrary, when i send a push from parse to a specific channel( which is exactly what i want to do from the device), i do get a message on devices which subscribed to that channel.
doneBtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
ParsePush push = new ParsePush();
push.setQuery(query);
push.setChannel(listId);
push.setMessage("Hey pal"+", it looks like "+cur_user.getUsername()+" added you to a new list."+" Log in to check it.");
push.sendInBackground(new SendCallback() {
#Override
public void done(ParseException e) {
if(e == null){
Log.d("DONE BUTTON","im here");
onBackPressed();
}else{
Log.d("PUSH ERROR",e.toString());
}
}
});
}
});
//update the list on the screen
updateData();
}
I literally have no idea why it doesn't work.
listId which sent to setChannel is a valid channel (I checked that) and it is included in the channels column in several installations in parse among other channels (i mean, i have installations with more than one channel and i want to send this message onlt to listId channel).