parse-server: getting an error when sending push to multiple recipientIds
Parse.Cloud.define(“sendPush”, function(request, response) {
var sendUserId = request.params.userId;
var msg = request.params.message;
var query = new Parse.Query(Parse.Installation);
query.equalTo('userId', sendUserId);
Parse.Push.send({
query: query,
data: {
alert: msg,
sound: 'default'
}
}, {
success: function() {
// Push was successful
response.success("Push sent");
},
error: function(error) {
// Handle error
response.error(error);
},
useMasterKey: true
});
});
/////// Android Code
public static void sendPush(final Context context, String message, String senderId) {
// String channel = “parse_user_channel_”; final Map<String, Object> params = new HashMap<>(); // params.put(“accountId”, channel); params.put(“message”, message); // params.put(“senderName”, senderName); params.put(“userId”, senderId); // params.put(“useMasterKey”, true);//Must have this line
ParseCloud.callFunctionInBackground("sendPush", params, new FunctionCallback<String>() {
// public void done(String result, ParseException e) {
// if (e == null) {
// Toast.makeText(context, “HEHE”, Toast.LENGTH_SHORT).show();
// Log.d(“ANNOUNCEMENT” ,“SUCCESS”);
// } else {
// Toast.makeText(context, "FAilure "+e.toString(), Toast.LENGTH_SHORT).show();
//
// Log.d(“ANNOUNCEMENT”,“FAILURE”+e.toString());
// }
// }
@Override
public void done(String result, com.parse.ParseException e) {
// TODO Auto-generated method stub
if (e == null) {
Toast.makeText(context, "HEHE", Toast.LENGTH_SHORT).show();
Log.d("ANNOUNCEMENT" ,"SUCCESS");
} else {
Toast.makeText(context, "FAilure "+e.toString(), Toast.LENGTH_SHORT).show();
Log.d("ANNOUNCEMENT","FAILURE"+e.toString());
}
}
});
} //////Errorr
FAILUREcom.parse.ParseRequest$ParseRequestException: {“code”:115,“message”:“Channels and query should be set at least one.”}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 31 (9 by maintainers)
What is the way of using it with " querying with array"?
@Heman6886 ask over http://stackoverflow.com/ please as this is an implementation issue on your side and not an issue on parse-server. Thanks.
{ “_id” : ObjectId(“5703a8a90ac1a5882c3b4008”), “objectId” : “di4FL8PPCv”, “pushTime” : “2016-04-05T11:59:37.354Z”, “_created_at” : ISODate(“2016-04-05T11:59:37.354+0000”), “query” : “{"userId":"4tKMN1HctW"}”, “payload” : { “alert” : “5”, “sound” : “default” }, “source” : “rest”, “title” : null, “expiry” : null, “status” : “running”, “numSent” : NumberInt(0), “pushHash” : “6e4b2efabbfd5b883b9baf5ac78faf5b”, “_wperm” : [
}
ok thanks for helping me out
Oops. It’s not supported that. Sorry.
Using promise is best solution, for now (or for me).