Custom Push Notification Server

My mobile app control server is turning into a bit of a powerhouse.  The latest and perhaps most exciting addition to the server has been support for sending Apple Push Notifications and registering devices for those notifications.

The goal of this is to make use of the push notifications for updating the apps, and cross promoting new apps to help build bigger and bigger launches.

One of the things that’s possible to do (but which I have not seen very many examples of yet) is having an alert open a link.  It’s a very powerful feature when you consider how easy it is to link directly to the App Store, – With a LinkShare affiliate link (aff link).  So when I find out about any hot new game release, or sale event I can let my users know about it.

It took a while to figure out how to handle the notification payload so here’s the code snippet:

- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSString *link = [[launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"] objectForKey:@"link"];
    if (link != nil) {
        //abort app startup and goto link
        NSURL *url = [NSURL URLWithString:link];
        [[UIApplication sharedApplication] openURL:url];
    }
...

With that bit of code in the App Delegate I can send a notification with a {“link”:”http://halotis.com”} custom payload and when the user clicks the alert it will direct the user to the website. Because the openURL call can handle lots of custom URL types it becomes possible to link directly into the Facebook App (if it is installed), or link to the app rating page to ask for the user to rate the app in iTunes, open a map location, or even dial a phone number.

Why not use something like urban airship to do all this? Well mostly because I want to consolidate app management as much as possible. The more features I put into my custom server the more likely I will leave it open and make use of it.