Skip to content

showing push error #1394

Closed
Closed

Description

@apurvaaggarwal

Android Code:
final Map<String, Object> params = new HashMap<>();
params.put("message", message);
params.put("userId", ParseUser.getCurrentUser().getObjectId());

ParseCloud.callFunctionInBackground("sendPush", params,
        new FunctionCallback<String>() {
            @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());
                }
            }
        });

///////////////////////////////////////////////
main.js
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({
        where: 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
});

});
But not getting push
Here is the verbose //////
verbose: sending push to 1 installations
verbose: sent push! 0 success, 0 failures

Activity

  1. flovilmart commented on Apr 6, 2016

    @flovilmart
    Contributor

    What adapter are you using? Which devices are you sending to? Android, iOS? Can you get the _PushStatus object?

  2. apurvaaggarwal commented on Apr 6, 2016

    @apurvaaggarwal
    Author

    I am using parse push adapter; sending to android devices

    _PushStatus

    {
    "_id" : ObjectId("5704f607c87f874d22157520"),
    "objectId" : "AJDiHp7HRu",
    "pushTime" : "2016-04-06T11:41:59.478Z",
    "_created_at" : ISODate("2016-04-06T11:41:59.478+0000"),
    "query" : "{"objectId":"rJvrh1s0BH"}",
    "payload" : {
    "alert" : "4",
    "sound" : "default"
    },
    "source" : "rest",
    "title" : null,
    "expiry" : null,
    "status" : "succeeded",
    "numSent" : NumberInt(0),
    "pushHash" : "01538e1dfb45c0adc1c4bd63365cf403",
    "_wperm" : [

    ], 
    "_rperm" : [
    
    ], 
    "numFailed" : NumberInt(0)
    

    }

  3. flovilmart commented on Apr 6, 2016

    @flovilmart
    Contributor

    I'll have a look. what version of parse-server are you using?

  4. apurvaaggarwal commented on Apr 6, 2016

    @apurvaaggarwal
    Author

    2.2.6

  5. flovilmart commented on Apr 6, 2016

    @flovilmart
    Contributor

    thanks. It seems to be the parse-server-push-adapter that is not reporting correctly the statuses of the pushes.

  6. flovilmart commented on Apr 6, 2016

    @flovilmart
    Contributor

    When running with VERBOSE=1, you should have that kind of logs:

    verb parse-server-push-adapter GCM sending to 1 device
    verb parse-server-push-adapter GCM GCM Response: {
    verb parse-server-push-adapter GCM     "multicast_id": 8389764779291095000,
    verb parse-server-push-adapter GCM     "success": 0,
    verb parse-server-push-adapter GCM     "failure": 1,
    verb parse-server-push-adapter GCM     "canonical_ids": 0,
    verb parse-server-push-adapter GCM     "results": [
    verb parse-server-push-adapter GCM         {
    verb parse-server-push-adapter GCM             "error": "InvalidRegistration"
    verb parse-server-push-adapter GCM         }
    verb parse-server-push-adapter GCM     ]
    verb parse-server-push-adapter GCM }
    

    Can you please provide them?

  7. apurvaaggarwal commented on Apr 6, 2016

    @apurvaaggarwal
    Author

    verbose: POST /parse/push { 'user-agent': 'node-XMLHttpRequest, Parse/js1.8.1 (NodeJS 5.3.0)',
    accept: '/',
    'content-type': 'text/plain',
    host: '166.62.82.202:1337',
    'content-length': '278',
    connection: 'close' } {
    "where": {
    "objectId": "KQPONXtIjb"
    },
    "data": {
    "alert": "Hello",
    "sound": "default"
    }
    }
    verbose: {
    "response": {
    "result": true
    }
    }
    success
    verbose: {
    "response": {
    "result": "Push sent "
    }
    }
    verbose: sending push to 1 installations
    verbose: sent push! 0 success, 0 failures

    i am getting this when i run using VERBOSE

  8. flovilmart commented on Apr 6, 2016

    @flovilmart
    Contributor

    Seems to be a misconfiguration in parse-server-push adapter, how did you set it up?

  9. apurvaaggarwal commented on Apr 6, 2016

    @apurvaaggarwal
    Author

    i have set it up in index.js using google project number and sender api key

  10. flovilmart commented on Apr 6, 2016

    @flovilmart
    Contributor

    Would you care to show it?

  11. apurvaaggarwal commented on Apr 6, 2016

    @apurvaaggarwal
    Author

    untitlednew

  12. flovilmart commented on Apr 6, 2016

    @flovilmart
    Contributor

    what's the version of parse-server-push-adapter? in node_modules/parse-server-push-adapter/package.json

  13. apurvaaggarwal commented on Apr 6, 2016

    @apurvaaggarwal
    Author

    1.0.4

  14. apurvaaggarwal commented on Apr 7, 2016

    @apurvaaggarwal
    Author

    @estylehq elborate please

  15. 6 remaining items

  16. apurvaaggarwal commented on Apr 7, 2016

    @apurvaaggarwal
    Author

    Updated index.js but the error is still same

  17. flovilmart commented on Apr 7, 2016

    @flovilmart
    Contributor

    can you please format correctly your index.js configuration? It's impossible to see where your error is.... Also we have many users having a functional push setup.

  18. apurvaaggarwal commented on Apr 7, 2016

    @apurvaaggarwal
    Author

    i have reformated the code of index.js and can you tell me that if want to send push to a specfic user using the object id of that users

  19. flovilmart commented on Apr 7, 2016

    @flovilmart
    Contributor

    That question should be asked over stackoverlow, or any other forum. We're not here to provide support for your implementations.

  20. apurvaaggarwal commented on Apr 7, 2016

    @apurvaaggarwal
    Author

    ok will the client push enable in future use

  21. flovilmart commented on Apr 7, 2016

    @flovilmart
    Contributor

    I don't believe it will ever be enable as this is a very important security problem. Also, many users have worked around it by creating a cloud code function. Look through the issues, and other references, and you should be good to go.

    Coming back to your issue, can we have a properly formatted index.js?

  22. apurvaaggarwal commented on Apr 7, 2016

    @apurvaaggarwal
    Author

    yes i have formatted it here it is
    var api = new ParseServer({
    databaseURI: databaseUri || 'mongodb',
    cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
    appId: process.env.APP_ID ||'',
    masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
    serverURL: process.env.SERVER_URL || 'http', // Don't forget to change to https if needed

    verifyUserEmails:true,
    publicServerURL:'http:',
    appName: 'Trakie',
    emailAdapter:{
    module: 'parse-server-simple-mailgun-adapter',
    options:{
    fromAddress:'@gmail.com',
    domain:'.mailgun.org',
    apiKey:'key-',}},
    push: {
    android: {
    senderId:'',
    apiKey:''
    }
    }
    });

  23. flovilmart commented on Apr 7, 2016

    @flovilmart
    Contributor

    this is not formatted....

    formatted is:

    var api = new ParseServer({
      databaseURI: databaseUri || 'mongodb',
      emailAdapter:{
        module: 'parse-server-simple-mailgun-adapter',
        options:{
          fromAddress:'@gmail.com',
          domain:'.mailgun.org',
          apiKey:'key-'
        }
      }
    })
    
  24. apurvaaggarwal commented on Apr 7, 2016

    @apurvaaggarwal
    Author

    then what about push notification adapter

  25. flovilmart commented on Apr 7, 2016

    @flovilmart
    Contributor

    what do you mean?

  26. apurvaaggarwal commented on Apr 7, 2016

    @apurvaaggarwal
    Author

    in index,js we have to declare both push adapter , email adapter and server info(master key,app id,mongo db connection string) then the formateed code that have been provided in that where i would add push adapter

  27. flovilmart commented on Apr 7, 2016

    @flovilmart
    Contributor

    this was just an example, to show you how to properly format the code when you share it. Your shared file appear all flat, with multiple } on certain lines... I can't really say what's wrong in your configuration because it's just plain ugly and not readable

  28. apurvaaggarwal commented on Apr 8, 2016

    @apurvaaggarwal
    Author

    i have checked everything again but the problem is steill there
    here is my main,js file
    Parse.Cloud.define("sendPush2", function(request, response) {

    var sendUserId = request.params.userId;
        var msg = request.params.message;
    

    var query = new Parse.Query(Parse.User);
    query.equalTo("ObjectId", id);

        Parse.Push.send({
           where : query,
                data: {
    
                        alert: "msg"
    
                }
        }, {
    

    useMasterKey:true,
    success: function() {
    // Push was successful
    console.log("success");
    response.success("Push sent ");
    },
    error: function(error) {
    // Handle error
    console.log("failed");
    response.error(error);
    }

        });
    

    });

  29. flovilmart commented on Apr 8, 2016

    @flovilmart
    Contributor

    the query on push should be on Parse.Installation not on Parse.User... That's why you're not getting anything...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions