Skip to content

Incrementing a push notification badge number support coming soon? #723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
taufiq-husain opened this issue Feb 29, 2016 · 33 comments
Closed

Comments

@taufiq-husain
Copy link

How can I tell whether the open source server will support something or whether I should implement a solution myself? I noticed that on the detailed docs, it said that Parse server doesn't support iOS badge numbers yet. Does this mean it's coming soon? Could I please know when/how I can help to speed this particular part? My project needs to be live on the app store within a week and this part is the only broken part.

I've successfully set up cloud code and fixed up my iOS front-end codes to use the Parse server. Thank you guys so much for everything you're doing with this. Highly appreciate it!

@flovilmart
Copy link
Contributor

As per the documentation it seems that the badge is supported: https://github.com/ParsePlatform/parse-server/wiki/Push#api

@anatolydwnld
Copy link

I think this ticket was about supporting Increment as the badge value(https://parse.com/docs/rest/guide#push-notifications-sending-options). Please, re-open.

@flovilmart
Copy link
Contributor

Did you try badge: "increment" ? It should to the job

@taufiq-husain
Copy link
Author

You can see in Parse's Push wiki, it says that this hasn't been implemented "yet". Link: https://github.com/ParsePlatform/parse-server/wiki/Push. That's why I was asking if/when/whether it'll ever be implemented...

@flovilmart flovilmart reopened this Mar 1, 2016
@flovilmart
Copy link
Contributor

Right.

@anatolydwnld
Copy link

Just to double check, I tested badge: "increment". Didn't work. There doesn't seem to be any mention of this in the source either. The wiki is correct in stating that this feature is not yet implemented.

@flovilmart
Copy link
Contributor

PR is pending review

@taufiq-husain
Copy link
Author

Hi,

I've updated my package.json file to "parse-server": "~2.1.4" but the "Increment" push notification feature doesn't seem to work still. I'm using the standard iOS APN system explained here: https://github.com/ParsePlatform/parse-server/wiki/Push. I deployed my code to my Heroku server by updating the package number but the push notification feature still doesn't increment. When I use the badge: 1 feature which works well but the increment feature doesn't. In fact, if I put the badge as "Increment", the badge doesn't update at all. What am I doing wrong? Did I not update the Parse server properly on Heroku? Do I need to do something more?

Thanks.

@taufiq-husain
Copy link
Author

I've also updated using the instructions given here: #879

Any ideas why it's not working still @flovilmart ?

@flovilmart
Copy link
Contributor

Can you run a query on _Installation to see if the badge value increments correctly? The badge increment is only for iOS devices, (deviceType=ios should be set on _Installation).

Also when you say not working at all, what do you mean?

@taufiq-husain
Copy link
Author

I did. The badge is still showing zero.

Here is my package.json:

{
  "name": "parse-server-example",
  "version": "1.1.0",
  "description": "An example Parse API server using the parse-server module",
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/ParsePlatform/parse-server-example"
  },
  "license": "MIT",
  "dependencies": {
    "express": "~4.2.x",
    "kerberos": "~0.0.x",
    "parse": "~1.6.12",
    "parse-server": "~2.1.4"
  },
  "scripts": {
    "start": "node index.js"
  },
  "engines": {
    "node": ">=4.3"
  }
}

I'm using cloud code to send push notifications. As soon as I change the badge value to "1", it works. As soon as I change it "Increment", it stops showing any numbers. It just shows 0 for the receiving user's badge in the _Installation row.

Here is me updating my Parse Server:

Taufiqs-MBP:getlolapp Taufiq$ cd parse-server
Taufiqs-MBP:parse-server Taufiq$ git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.
Taufiqs-MBP:parse-server Taufiq$ git pull
Already up-to-date.
Taufiqs-MBP:parse-server Taufiq$ cd ..
Taufiqs-MBP:getlolapp Taufiq$ git commit -am "Testing"
[master d911f50] Testing
 1 file changed, 1 insertion(+), 1 deletion(-)
Taufiqs-MBP:getlolapp Taufiq$ git push heroku master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 287 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 1 (delta 1)
remote: Git submodules detected, installing:
remote: Synchronizing submodule url for 'parse-server'
remote: Submodule path 'parse-server': checked out '75ae95815d30c99f67119301ef8619cbf0606cfe'
remote: 
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Using set buildpack heroku/nodejs
remote: -----> Node.js app detected
remote: 
remote: -----> Creating runtime environment
remote:        
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote: 
remote: -----> Installing binaries
remote:        engines.node (package.json):  >=4.3
remote:        engines.npm (package.json):   unspecified (use default)
remote:        
remote:        Resolving node version >=4.3 via semver.io...
remote:        Downloading and installing node 5.7.1...
remote:        Using default npm version: 3.6.0
remote: 
remote: -----> Restoring cache
remote:        Loading 2 from cacheDirectories (default):
remote:        - node_modules
remote:        - bower_components (not cached - skipping)
remote: 
remote: -----> Building dependencies
remote:        Pruning any extraneous modules
remote:        Installing node modules (package.json)
remote: 
remote: -----> Caching build
remote:        Clearing previous node cache
remote:        Saving 2 cacheDirectories (default):
remote:        - node_modules
remote:        - bower_components (nothing to cache)
remote: 
remote: -----> Build succeeded!
remote:        ├── [email protected]
remote:        ├── [email protected]
remote:        ├── [email protected]
remote:        └── [email protected]
remote:        
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> web
remote: 
remote: -----> Compressing...
remote:        Done: 20.5M
remote: -----> Launching...
remote:        Released v67
remote:        https://getlolapp.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/getlolapp.git
   e066c75..d911f50  master -> master

@flovilmart
Copy link
Contributor

what is the deviceType for your _Installation?

@taufiq-husain
Copy link
Author

Oh they are all iOS. I updated my previous comment with more info.

@flovilmart
Copy link
Contributor

is it iOS or all lowercase string? Could you dump an excerpt of the query result?

@taufiq-husain
Copy link
Author

Sure:

{
    "_id": "ZsLYArrz0e",
    "parseVersion": "1.12.0",
    "deviceToken": "b64e82cfc37f13ccd3e8709473576a8d49e6964f10b11b46179e04935b3af751",
    "badge": 0,
    "deviceType": "ios",
    "installationId": "7d7984e0-ccfe-4f53-b112-2b6bc0b9eeb6",
    "localeIdentifier": "en-US",
    "appIdentifier": "com.polarhills.LOL",
    "timeZone": "America/Los_Angeles",
    "enabled": false,
    "appName": "LOL",
    "username": "[REDACTED]",
    "appVersion": "1.5",
    "_updated_at": {
        "$date": "2016-03-02T06:01:01.268Z"
    },
    "_created_at": {
        "$date": "2016-02-29T22:52:45.274Z"
    }
}

@flovilmart
Copy link
Contributor

nothing logged ? when you try sending the push?

@taufiq-husain
Copy link
Author

I got something:

Taufiqs-MBP:getlolapp Taufiq$ heroku logs --tail -n 50
2016-03-07T18:56:38.132467+00:00 app[web.1]: APNS Connection 0 Notification transmitted to 3d8591f34b26c9bc3ba49cea14f6512224ab4201c9a4481092f6c1991e7b6a1f
2016-03-07T18:56:38.236110+00:00 app[web.1]:   connIndex: 0,
2016-03-07T18:56:38.236112+00:00 app[web.1]:    { aps: 
2016-03-07T18:56:38.236112+00:00 app[web.1]:       { badge: undefined,
2016-03-07T18:56:38.236096+00:00 app[web.1]: APNS Notification caused error: 8 for device  Device {
2016-03-07T18:56:38.236113+00:00 app[web.1]:         sound: undefined,
2016-03-07T18:56:38.236109+00:00 app[web.1]:   token: <Buffer bf e9 20 3e de a8 3f 25 e4 51 6c e3 16 75 47 c3 89 8f c3 b1 35 7e 5f e8 bf bf 42 3b f3 75 8f 82>,
2016-03-07T18:56:38.236110+00:00 app[web.1]:   appIdentifier: 'com.polarhills.LOL' } { encoding: 'utf8',
2016-03-07T18:56:38.236114+00:00 app[web.1]:         'url-args': undefined,
2016-03-07T18:56:38.236111+00:00 app[web.1]:   payload: 
2016-03-07T18:56:38.236114+00:00 app[web.1]:         alert: 'Message from Taufiq Husain 😋',
2016-03-07T18:56:38.236117+00:00 app[web.1]:   retryLimit: -1,
2016-03-07T18:56:38.236118+00:00 app[web.1]:   device: undefined,
2016-03-07T18:56:38.236115+00:00 app[web.1]:         category: undefined } },
2016-03-07T18:56:38.236116+00:00 app[web.1]:   expiry: undefined,
2016-03-07T18:56:38.236117+00:00 app[web.1]:   priority: 10,
2016-03-07T18:56:38.236119+00:00 app[web.1]:   compiled: '{"aps":{"alert":"Message from Taufiq Husain 😋"}}',
2016-03-07T18:56:38.236119+00:00 app[web.1]:   truncateAtWordEnd: false,
2016-03-07T18:56:38.236120+00:00 app[web.1]:   _alert: 'Message from Taufiq Husain 😋' }

@flovilmart
Copy link
Contributor

so badge is actually undefined.

@taufiq-husain
Copy link
Author

yeah, I wonder why? I was using the following function:

// Push Notifications
Parse.Cloud.define("send_push", function(request, response) {
    var query = new Parse.Query(Parse.User, {useMasterKey:true});
    query.containedIn("username", request.params.receivers);
    query.equalTo("enabled", true);
    Parse.Push.send({
        where: query,
        data: {
            alert: request.params.message,
            badge: "Increment"
        }
    }, 
    { 
        useMasterKey: true 
    }, 
    {
        success: function() {
            response.success("Push notification sent!");
        },
        error: function(e) {
            response.error("Push notification error! Code: " + e.code + ", Message: " + e.message);
        }
    });
});

Why is badge being sent as "undefined"?

@taufiq-husain
Copy link
Author

Maybe Parse server expects an integer instead of string for the badge value? I have no clue why this is not working but badge: 1 works. @flovilmart

@flovilmart
Copy link
Contributor

not sure, we have unit tests to make sure everything is functional, this part is heavily tested through he PushController.

I just noticed that your push query is on Parse.User, that is maybe the problem now.
It should be a query on _Installation

@taufiq-husain
Copy link
Author

I updated the cloud code to the following and it still isn't working (shows the same "undefined" badge error):

// Push Notifications
Parse.Cloud.define("send_push", function(request, response) {
    var Installation = Parse.Object.extend("_Installation");
    var query = new Parse.Query(Installation, {useMasterKey:true});
    query.containedIn("username", request.params.receivers);
    query.equalTo("enabled", true);
    Parse.Push.send({
        where: query,
        data: {
            alert: request.params.message,
            badge: "Increment"
        }
    }, 
    { 
        useMasterKey: true 
    }, 
    {
        success: function() {
            response.success("Push notification sent!");
        },
        error: function(e) {
            response.error("Push notification error! Code: " + e.code + ", Message: " + e.message);
        }
    });
});

Do you have any sample apps that you can test to see if "Increment" push notifications are working properly?

@camerona93
Copy link

I'm seeing the same behavior as taufiq in my heroku setup as well - all of my push notifications show up but the badge is never incremented despite having badge: "Increment" in the data parameter. My MongoDB entries for installations show badge count staying at 0. Is there any update on this?

@taufiq-husain
Copy link
Author

@cra5370 I don't know if you fixed this issue yet but my heroku server started working after updating to the most recent Parse server version. If you used git to set up heroku then follow these steps and it might start working properly:

heroku git:clone -a my_app
cd my_app
git submodule add https://github.com/ParsePlatform/parse-server.git
npm link parse-server ./parse-server
cd parse-server
git checkout master
git pull
cd ..
git commit -am “Testing”
git push heroku master

Other than that, you should look into the docs furthermore. Amazing guys like @flovilmart and the rest of the Parse team are doing a wonderful job keeping and making Parse great and open source.

@aliasad106
Copy link

aliasad106 commented May 14, 2016

@flovilmart
I am facing the same problem I update parse-server to latest and tested locally and it started showing badge for "increment" but when I deployed to AWS Elasticbeanstalk, It doesn't show badge.

P.S: I'm using Docker for AWS elasticbeanstalk deployment. It was also giving me error for mailgun adaptor file. Docker dose not seem to be updated with current parse-server directories.

@miighty
Copy link

miighty commented Oct 16, 2016

Hey any progress on this?
I seem to have the same problem badge: "Increment" doesn't work but I can set the badge via integer. Im super new to node.js and parse.

Is there a way to get the badge value so I can then count that up ?

@flovilmart
Copy link
Contributor

What version of parse-server are you running? The increment should be implemented for a while.

@miighty
Copy link

miighty commented Oct 16, 2016

I belive I am running 1.2.0, but It's a parse server for Microsoft Azure

@flovilmart
Copy link
Contributor

Parse server versions start from 2.0.0, the current version is 2.2.22.

@miighty
Copy link

miighty commented Oct 16, 2016

Whoops sorry, in that case the version is 2.1.4, which judging by the current version is very old...

@flovilmart
Copy link
Contributor

Yes syou should upgrade then!

@jeacott1
Copy link

jeacott1 commented Jul 4, 2017

someone should probably update the docs to reflect this sometime.
http://docs.parseplatform.org/parse-server/guide/#api

"Here is the list of sending options we do not support yet:
push_time for scheduled push
Increment badge under data for iOS badge number"

@flovilmart
Copy link
Contributor

Yes! Could you do it @jeacott1 ? Push schedule is saved but not run though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants