Android上解析推送JSON数据问题
我对安卓非常陌生,我真的希望这对你们来说很容易解决 我想让用户在按下我的应用程序上的按钮后向其他用户发送推送。 它没有正确配置ParsePush on my button click listener,因为它工作正常:Android上解析推送JSON数据问题,android,json,parse-platform,push-notification,Android,Json,Parse Platform,Push Notification,我对安卓非常陌生,我真的希望这对你们来说很容易解决 我想让用户在按下我的应用程序上的按钮后向其他用户发送推送。 它没有正确配置ParsePush on my button click listener,因为它工作正常: // Create our Installation query ParseQuery pushQuery = ParseInstallation.getQuery(); pushQuery.whereEqu
// Create our Installation query
ParseQuery pushQuery = ParseInstallation.getQuery();
pushQuery.whereEqualTo("installationId", installationId); //Send to targeted user
// Send push notification to query
ParsePush push = new ParsePush();
push.setQuery(pushQuery); // Set our Installation query
push.setMessage("HEY YOU");
push.sendInBackground();
但是我想在推送中添加一个URI,所以我做到了:
// Create our Installation query
ParseQuery pushQuery = ParseInstallation.getQuery();
pushQuery.whereEqualTo("installationId", installationId);
// Send push notification to query
ParsePush push = new ParsePush();
push.setQuery(pushQuery); // Set our Installation query
String string = "{\"title\" : \"my title\",\"alert\" : \"my alert text\",\"uri\" : \"myapp://host/path\"}";
try {
JSONObject data = new JSONObject(string);
push.setData(data);
} catch (JSONException e) {
Log.e("MYAPP", "unexpected JSON exception", e);
}
push.sendInBackground();
在我的Android清单中,我有目标活动:
<activity android:name=".Accept_Action">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" android:host="host" android:path="/path" />
</intent-filter>
</activity>
但出于某种原因,这是行不通的。推送从未到达我的目标设备。
你能帮我做这件事吗?
谢谢你回答你的问题 遗憾的是,出于安全原因,您不能从客户端使用parse push的“uri”选项 资料来源:
- 此博客帖子: 作为安全预防措施,当从客户端发送推送时,可能不使用uri选项
- 从解析文档中的错误部分: ClientPushWithURI 115客户端启动的推送无法使用“uri” 选择权
- 从Android客户端调用的云代码函数()发送推送李>
- 使用非
的名称,并实现自己的逻辑来处理它(覆盖uri
,示例:)ParsePushBroadcastReceiver
push.sendInBackground(new SendCallback() {
@Override
public void done(ParseException e) {
if (e != null) {
e.printStackTrace();
} else {
Log.e("MYAPP", "Push sent.");
}
}
});
因此,e.printStackTrace()代码>将向您打印上述错误115:
com.parse.ParseRequest$ParseRequestException: Client-initiated push cannot use the "uri" option
是的,我知道,谢谢你的关心。但我开始解析,我的MVP几乎完成了,所以我想解锁最后一部分。另外,这实际上提高了我对Java和Android devDo的全面了解。您在日志中看到任何错误吗?您看到在解析界面中发送的推送了吗?我的日志中没有错误,解析界面中没有通知:/@meynety非常感谢您的帮助。让我测试一下,然后再给你回复!嘿@meynety,很抱歉花了这么长时间才回复你。我现在正在按照建议开发一个云代码函数!谢谢你的帮助!