I am testing the push notification such that when I press a button on the app, all the others who have the same application installed gets a push notification. The one who is sending the notification won't get any.
I been looking around similar queries here but not able to get it to work. In terms of the push itself, my log shows that "Parse push is sent". But I do not get any notification on any of my physical devices nor emulator.
Note that I am using Parse and the setup is done correctly and able to send notifications from the Parse.com site. Only having trouble when trying to send it from a client's device.
Am I supposed to explicitly create a channel and user for this? I tried but only had options to create audience with conditions.
public void sendParse(View view){
try {
// Associate the device with a user
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("user", ParseUser.getCurrentUser());
installation.saveInBackground();
ParseQuery pushQuery = ParseInstallation.getQuery();
pushQuery.whereEqualTo("channels", "Everyone");
pushQuery.whereNotEqualTo("user", ParseUser.getCurrentUser());
pushQuery.whereEqualTo("user", ParseUser.getCurrentUser());
ParsePush push = new ParsePush();
push.setQuery(pushQuery);
push.setMessage("Testing 1 2 3...");
push.sendInBackground(new SendCallback() {
@Override
public void done(ParseException e) {
Log.i("zx", "Push is sent!");
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
In your code
pushQuery.whereNotEqualTo("user", ParseUser.getCurrentUser());
pushQuery.whereEqualTo("user", ParseUser.getCurrentUser());
These two lines are incompatible, you should remove the "whereEqualTo" line.
Another thing you can do is in the callback:
...
public void done(ParseException e){
if(e!=null)
e.printStackTrace();
...
}
To check if there were errors
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.