如何使用解析从一个Android设备发送推送通知到另一个Android设备?

时间:2015-04-14 10:07:06

标签: android parse-platform

ParseQuery<ParseInstallation> pushQuery = ParseInstallation.getQuery();
                 pushQuery.whereEqualTo("channels", "Done"); // Set the channel,Done is channel name
                    pushQuery.whereEqualTo("user","tab");//tab is user name

// Send push notification to query
ParsePush push1 = new ParsePush();
push1.setQuery(pushQuery); // Set our Installation query
push1.setMessage("Hello Mr "+pushmsg.getText().toString());
push1.sendInBackground();

1 个答案:

答案 0 :(得分:0)

这是答案。试试这个。

            ParseQuery<ParseInstallation> query = ParseInstallation.getQuery();
            query.whereEqualTo("PhoneNumber", destNumber);  //Checks whether the receiver has registered his phone number on parse.com. you need to store the users phone number while he installs the app.

            JSONObject jSonobj;
            try {
                jSonobj = new JSONObject();
                jSonobj.put("action", "com.thoughtrix.introduce.UPDATE_STATUS");
                jSonobj.put("from", senderPhoneNumber);
                jSonobj.put("name", infoName);
                jSonobj.put("number", infoNumber);
                jSonobj.put("title", "Introduce");
                jSonobj.put("message", message);
                ParsePush push = new ParsePush();
                push.setQuery(query);
                push.setData(jSonobj);
                push.sendInBackground();
            } catch (JSONException e) {
                e.printStackTrace();
            }