Keeping Your Users Updated through Counter Notifications
As you build your application, you need a way to notify users when they have new data. For instance, consider that a user's friend adds a quote to your application and you need to let the user know that he or she has new quotes to look at. How does that user know to go look? How do you notify the user?
Facebook has provided a way to increment a counter for your application that resides in the sidebar of Facebook for that user.
Remember the Add Bookmark button that I mention earlier in the chapter? Assuming that your user has bookmarked the application, your application should appear prominently in the left sidebar (under Applications) of Facebook for the user, where you can send these updates.
So how does the increment counter work? Here's how:
- Your user's friend submits a new quote to the Inspirations application.
I'll let you write the code for this. Basically, in your preferred language, you need to write code that takes the quote and submits it to the database and marks which user submitted that quote.
- Your application notices this and sends an API call to Facebook, notifying it to increment your counter.
You do this through the dashboard.incrementCount method (part of Facebook's old REST APIs, something which may be replaced by a Graph API method in the future, so be sure to check the Facebook Developer documentation!). ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access