Have a look at can we show badge number on android app icon like iphone? for implementing the badge on the app icon. There is an open source library mentioned there that shows the badges on various devices.
The actual library is https://github.com/leolin310148/ShortcutBadger
With regards to getting an accurate counter, it's a bit more complex since some notifications can go missing.
- If you don't care about that (notifications missing), it's simple enough. Every time there's a notification, in your service, increment some counter using shared preferences/database row (or whatever else where you can persist a number) and use that number to show the badge. Every time the user opens the app, clear that value and clear the badge.
- If you do however care about missing notifications, you need to implement the mechanism on your server. Basically, you want to send an acknowledgement request every time the content is seen and when a new notification arrives, ask the server to tell you how many "unseen" contents there are (you call the server in the same service your GCM is using) and use that number as a badge.
The second solution assumes that (a) you have a server that's serving contents and (b) the server can determine when something is seen/new. If you don't have such a service, option 1 is probably the only way you can go about doing this.