解析Android上的推送JSON数据问题

解析Android上的推送JSON数据问题,第1张

概述我对 Android很新,我真的希望这对你们来说很容易解决! 我想让用户在我的应用程序上按下按钮后向其他用户发送推送. 它确实在我的按钮单击侦听器上配置了ParsePush,因为这样可以正常工作: // Create our Installation query ParseQuery pushQuery = ParseInstallation.getQuery(); 我对 Android很新,我真的希望这对你们来说很容易解决!

我想让用户在我的应用程序上按下按钮后向其他用户发送推送.
它确实在我的按钮单击侦听器上配置了ParsePush,因为这样可以正常工作:

// 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 Manifest中,我有一个有针对性的Activity:

<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>

但由于某种原因,这是行不通的.推送永远不会落在我的目标设备上.
你能帮我做这个吗?
谢谢

解决方法 回答你的问题

遗憾的是,出于安全原因,您无法使用来自客户端的解析推送的“uri”选项.

资料来源:

>此博客文章http://blog.parse.com/learn/android-push-gets-major-refresh/:

As a security precaution,the uri option may not be used when a push is sent from a clIEnt.

>并从解析文档https://www.parse.com/docs/android/guide#errors-push-related-errors中的错误部分:

ClIEntPushWithURI 115 ClIEnt-initiated push cannot use the “uri”
option.

建议解决方案

我看到两个可能的解决方案:

>从您从AndroID客户端调用的云代码功能(https://www.parse.com/docs/cloudcode/guide#cloud-code-cloud-functions)发送推送.
>使用uri以外的名称并实现自己的逻辑来处理它(覆盖ParsePushbroadcastReceiver,例如:http://www.androidhive.info/2015/06/android-push-notifications-using-parse-com/)

用于学习目的

您可以通过实现sendInBackground() *** 作的回调来看到此错误,以查看 *** 作的实际结果,如下所示:

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
总结

以上是内存溢出为你收集整理的解析Android上的推送JSON数据问题全部内容,希望文章能够帮你解决解析Android上的推送JSON数据问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1125711.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存