我一直在尝试使用解析从一个设备向另一个设备发送简单的推送通知,但我没有运气。
假设我有一个具有跟随/取消关注功能的推文克隆,如果例如User-A开始关注User-A,我试图做的就是通知用户-A他现在正在跟随User-B
这是我正在运行的简单代码
ParseQuery query = ParseInstallation.getQuery();
query.whereEqualTo("userId", "0VZF1l5qyA");
// Notification for Android users
ParsePush androidPush = new ParsePush();
androidPush.setMessage("Your suitcase has been filled with tiny robots!");
androidPush.setQuery(query);
androidPush.sendInBackground();
为了确保它能够正常工作,我对该值进行了硬编码,但仍未发送任何内容。它也不像我试图定位的用户不在服务器上。
这是我的安装表的样子
我觉得这个简单的东西应该可行。或许我错过了推送通知的工作原理。 顺便说一句,我能够从Parse Web应用程序发送推送通知。 仅供参考 - 我已经阅读了this的整个部分,仍然无法使其发挥作用。
附录:我在我的主要活动中有这段代码,并将我的清单修改为this.
// Associate the device with a user
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("user",ParseUser.getCurrentUser());
installation.put("userId",ParseUser.getCurrentUser().getObjectId());
installation.saveInBackground();
答案 0 :(得分:2)
默认情况下,不允许客户端推送通知。你必须做以下其他你的应用程序不会工作!!