upgrading apn_on_rails from version 0.3.0 to 0.3.1

We’ve been using apn_on_rails successfully for our HoneyDo API as a push messaging library for the apple push notification service. Recently, a change they made to the trunk allowed for easily adding custom_properties to the payload message.

We were really missing this in v0.3.0 and when they added it, they just tweaked the existing migration which can cause havoc when you have a deployed system containing data for 1000s of users. This is so trivial that blogging about it is strange: but, we just wanted to let people know that adding a new migration to your apn_notifications and then using 0.3.1 works like a charm.

Sending custom properties is a breeze and a new attribute to the apn_notification model makes adding the hash of values very very easy.

Here are the steps:
if you’re in 0.3.0 and upgrading:
1. add a migration to support custom_properties for apn_notifications
2. upgrade your gem to 0.3.1 (delete the old gem)
3. run the migration against the servers
4. test using script/console
5. on the device in your didFinishLaunchingWithOptions method, play with launchOptions and you now have the dictionary you sent attached to the aps payload:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
NSLog([NSString stringWithFormat:@"%@", launchOptions]);

NOTE: keep the additional dictionary you send as tight as possible since you only have 256bytes available for the entire payload.

Comments are closed.