Reputation: 493
Can I send a push-message within my android app to only one certain device (probably with the device id ?) instead of to every device?
a simple "yes, that's possible with parse" or "no, you can't use parse for that" will be enough!
if ans is yes then I need to know how.....
Upvotes: 5
Views: 4929
Reputation: 1411
Device Id is the way to go. If you want to send to a specific user, create an additional field in your pasrse installation and save the userid on this field. So that you can send to the specific user by filtering with userid and setting the query to get that specific user in the code for sending push.
ParseQuery query = ParseInstallation.getQuery();
query.whereEqualTo("device_id", "1234567890");
query.equalTo("user_obj","your_user_object_here");
ParsePush push = new ParsePush();
push.setQuery(query);
push.sendPushInBackground();
Upvotes: 0
Reputation: 5020
You can save a device id in ParseInstallation
and then target this installation:
Receiver:
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("device_id", "1234567890");
installation.saveInBackground();
Sender:
ParseQuery query = ParseInstallation.getQuery();
query.whereEqualTo("device_id", "1234567890");
ParsePush push = new ParsePush();
push.setQuery(query);
push.sendPushInBackground();
Upvotes: 9
Reputation: 3806
AFAIK you will need to add the IP of the sending device/server in google console as trusted - so no, you usually do not use the client to send push to other devices. Instead, send the message to your server, which has all the registered devices to your GCM token, and let the server push the message to the specific client.
You should read the documentation http://developer.android.com/google/gcm/index.html
Upvotes: 0