1

Using Parse as cloud database now I have button in Android app. On button click I want to send push notification to more than one user (using username). it's sending the notification successfully but failed to receive in target devices. Here is the code I am using to send successfully but here I do not specify username or multiple users as target just set Channel as "".

WORKING CODE WITHOUT SPECIFY USERNAME:

pushNotifcationBtn.setOnClickListener(new View.OnClickListener() {              
    @Override
    public void onClick(View v) {
       ParsePush parsePush = new ParsePush();
            ParseQuery query = ParseInstallation.getQuery();
            ParseQuery userQuery = ParseUser.getQuery();
            userQuery.whereEqualTo("username","aamir");
            query.whereMatchesQuery("user",userQuery);
            parsePush.setChannel("");
            parsePush.setQuery(query);
            parsePush.setMessage("First Message");
            parsePush.sendInBackground(new SendCallback() {
                
                @Override
                public void done(ParseException arg0) {
                    // TODO Auto-generated method stub
                    Log.d(TAG, "SendCallback success:");
                    if(arg0 == null)
                    {
                            Log.d(TAG,
                                    "suceess push notification :");
                    }
                    else
                    {
                            Log.d(TAG,
                                    "failed push notification  :"
                                            + arg0.getMessage());
                    }
                }
            });
            
    }
}); 

But I have to set "username" lets say "a" "b" "c". How will I set multiple username? and how will I resolve issue as it is failed to send notification LOGCAT :

05-19 13:09:28.833: I/System.out(13982): [CDS]close[37294]
05-19 13:09:28.834: I/System.out(13982): close [socket][/0.0.0.0:37294]
05-19 13:09:28.836: I/System.out(13982): ex:org.apache.http.NoHttpResponseException: The target server failed to respond
05-19 13:09:28.836: I/System.out(13982): retry1
05-19 13:09:28.853: D/libc-netbsd(13982): getaddrinfo: api.parse.com get result from proxy >>
15
  • I would suggest you not use User user = new User() to "create" a new user. Even via this way what you did is not correct. You should use ParseUser. I think Parse.com documentation suggest you use query to locate the user, could you try that? Commented May 19, 2015 at 8:36
  • kindly check my edit question i am using this code i m not using user user = new User(); !@ss1271 Commented May 19, 2015 at 10:23
  • this whereMatchesQuery line, you should use lower case "user" other than the uppercase. Should be something like this:query.whereMatchesQuery("user", userQuery); Commented May 19, 2015 at 10:25
  • wait device is on charge let me check and if i want to pass array of users then ??? means i want to send multiple user name ? then how will i pass @ss1271 Commented May 19, 2015 at 10:30
  • Use parse query to perform a "OR" query. Please do check the parse documentation, they have a method to allow you do a "OR" Commented May 19, 2015 at 10:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.