我能否通过我的Android应用程序向仅特定设备发送推送消息(可能使用设备ID?)而不是发送到每个设备?
一个简单的“是的,可以使用Parse实现”或“不,您不能使用Parse实现”就足够了!如果答案是肯定的,那么我需要知道如何实现.....
我能否通过我的Android应用程序向仅特定设备发送推送消息(可能使用设备ID?)而不是发送到每个设备?
一个简单的“是的,可以使用Parse实现”或“不,您不能使用Parse实现”就足够了!如果答案是肯定的,那么我需要知道如何实现.....
ParseInstallation
中保存设备ID,然后针对此安装进行目标定位。
接收器:
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("device_id", "1234567890");
installation.saveInBackground();
发送者:
ParseQuery query = ParseInstallation.getQuery();
query.whereEqualTo("device_id", "1234567890");
ParsePush push = new ParsePush();
push.setQuery(query);
push.sendPushInBackground();
设备 ID 是最佳选择。如果您想要向特定用户发送消息,请在 Parse 安装中创建一个附加字段,并将用户 ID 保存在此字段中,这样您就可以通过筛选 UserID 并设置查询以获取该特定用户的推送代码来向该特定用户发送消息。
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();