In this series I'll cover more in depth about the different use cases and how to archive them in your app. The first one deals with the situation where you do not want to run your own servers and want to reach all your customers with the same message at the same time. You can easily archive this with HTTPush. With some Google App Engine trickery you might not need to run a server at all. I want to show you on a high level, how you would implement this using the HTTPush web service.
An application that wants to reach all users at the same time
Say you are building an app for a local band. Your app shows news from the band and mixes that up with tour dates and behind-the-scene pictures. Whenever there is news from the group itself or they have a new gig, you want to send out a notification to the users, letting them know that something is new and they should launch the app to be up-to-date. The primary source for news are a bunch of rss feeds that get called every time the app launches.
Registering a recipient
Your users launch your app for the first time and they register for the device token (more about how this works after the NDA is lifted). The device token is a unique identifier for the device similar to a phone number, which enables Apple to reach that phone.
With the received token, you call the api method
http://push.squidshot.com/:account/v2/recipient/registration.jsonwith the HTTP verb POST, to add that user to the general recipient pool of the application.
Call this method every time, the app is launched because you can not be sure if the token changed or not. You SHOULD NOT however store the token somewhere on the device. Just call the method.
Send notifications
To gather the news, pictures and tour dates for your app, you call several rss feeds from within the app. You'll need to outsource this logic to a server machine in order to know when somethings has changed in the feeds and you want to send out a notification.
Have a look at Google App Engine for running your script. The limits should be sufficient for a small script like this and you can HTTPush from there. Use App Engines cron feature to call your script periodically and send a notification from there to the api.
Call
http://push.squidshot.com/:account/v2/recipient/notification.jsonwith the HTTP verb POST, to reach all users in your app.
No notifications anymore please!
If a user chooses to opt-out of notifications, simply call
http://push.squidshot.com/:account/v2/recipient/registration.jsonwith the HTTP verb DELETE, to get him out of the recipient pool.
As you can see it is very simple to use the api and with a little trickery you do not need to run a server on your own to make use of push notifications. If you have more complicated needs for your server script, contact Bigcurl. We do all things server side for a living and are happy to work with you on your app.

0 Kommentare:
Post a Comment