Using Parse as cloud database now I have button in Android app. On button click I want to send push notification to more than one user (using username). it's sending the notification successfully but failed to receive in target devices. Here is the code I am using to send successfully but here I do not specify username or multiple users as target just set Channel as "".
WORKING CODE WITHOUT SPECIFY USERNAME:
pushNotifcationBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ParsePush parsePush = new ParsePush();
ParseQuery query = ParseInstallation.getQuery();
ParseQuery userQuery = ParseUser.getQuery();
userQuery.whereEqualTo("username","aamir");
query.whereMatchesQuery("user",userQuery);
parsePush.setChannel("");
parsePush.setQuery(query);
parsePush.setMessage("First Message");
parsePush.sendInBackground(new SendCallback() {
@Override
public void done(ParseException arg0) {
// TODO Auto-generated method stub
Log.d(TAG, "SendCallback success:");
if(arg0 == null)
{
Log.d(TAG,
"suceess push notification :");
}
else
{
Log.d(TAG,
"failed push notification :"
+ arg0.getMessage());
}
}
});
}
});
But I have to set "username" lets say "a" "b" "c". How will I set multiple username? and how will I resolve issue as it is failed to send notification LOGCAT :
05-19 13:09:28.833: I/System.out(13982): [CDS]close[37294]
05-19 13:09:28.834: I/System.out(13982): close [socket][/0.0.0.0:37294]
05-19 13:09:28.836: I/System.out(13982): ex:org.apache.http.NoHttpResponseException: The target server failed to respond
05-19 13:09:28.836: I/System.out(13982): retry1
05-19 13:09:28.853: D/libc-netbsd(13982): getaddrinfo: api.parse.com get result from proxy >>
User user = new User()to "create" a new user. Even via this way what you did is not correct. You should useParseUser. I think Parse.com documentation suggest you use query to locate the user, could you try that?whereMatchesQueryline, you should use lower case "user" other than the uppercase. Should be something like this:query.whereMatchesQuery("user", userQuery);