a.k.a devgeeks

Software development in the minutes a day I have spare

One of the developers working on the new PhoneGap-based Wikipedia Mobile was having some annoying issues with the PhoneGap ShareKit plugin and decided he’d rather just put the Facebook and Twitter sharing in with their individual plugins. 

He was happy with the decision where Facebook and Twitter were concerned, but lamented that the decision would mean there would no longer be support for Read it Later (http://readitlaterlist.com).

I had a look at Read it Later’s API and iOS SDK and it looked fairly straight forward, so when he asked if I would like to write a plugin for it I took on the challenge.

Just two hours later I had a shiny new PhoneGap plugin!

https://github.com/devgeeks/ReadItLaterPlugin

If you wanna be as cool as Wikipedia, run over to GitHub and clone it into your app now! 

Installation

This plugin allows you to save a URL to Read It Later from your app.

Add the plugin much like any other:

  1. Add the ReadItLaterPlugin.h and VolumeSlider.m classes to your Plugins folder in Xcode (use “Create groups for any added folders”)
  2. Add the ReadItLaterPlugin.js file to your www folder
  3. Add the ReadItLaterPlugin.js to your html file. eg:<script type="text/javascript" charset="utf-8" src="ReadItLaterPlugin.js"></script>
  4. Add the plugin to the PhoneGap.plist under Plugins (key: “ReadItLaterPlugin” value: “ReadItLaterPlugin”)

Next, get the Read It Later API iPhone Library and add it to your project:

  1. Download the library from Read It Later
  2. Unzip the library and examples
  3. Copy these four files into your Xcode project under the Plugins folder (again, use “Create groups for any added folders”)
    • ReadItLaterLite.h
    • ReadItLaterLite.m
    • ReadItLaterFull.h
    • ReadItLaterFull.m
  4. Get an API Key from Read It Later for your app
  5. Add your shiny new API key to the top of the ReadItLaterLite.m file you copied in above
    • static NSString *apikey = @"<api key here>";
  6. Add the name of your app (as you entered it to get your API key above) as well
    • static NSString *nameOfYourApp = @"<name of your app here>";

Finally, call the saveToReadItLater() method using a success callback and an object containing a url and a title:

Example

function onDeviceReady()
{
    var readItLaterPlugin = window.plugins.readItLaterPlugin;
    readItLaterPlugin.saveToReadItLater(
        function(){
            console.log("Successfully saved to Read It Later");
        }, 
        { 
            url: "http://github.com/devgeeks", 
            title: "Devgeeks on GitHub"
        }
    );
}

The PhoneGap installer for iOS overwrites the old version when you run it. It puts itself in over the top of your previous version.

However, when you have shipped an app with PhoneGap and it’s happily in the App Store, the last thing you want to do is have to deal with changes in the PhoneGap API between versions if you need to make small maintenance tweaks down the track. 

Here’s what I do in this instance.

  1. Before upgrading PhoneGap (running the installer) I back up the previous version of the framework. I copy ‘/Users/Shared/PhoneGap’ to ‘/Users/Shared/PhoneGap-<version>’ (such as ‘/Users/Shared/PhoneGap-1.2’).
  2. Next I go into the projects that I want to keep running that version, and I delete the PhoneGap.framework from the project (remove reference only). 
  3. Then I add the framework from the copied versioned folder I made in step #1. Select the target in Xcode, choose the “Build Phases” tab, open the “Link Binary With Libraries” section and click the + and choose “Add Other…”, browse to where you backed up your old PhoneGap.framework and add it in.
  4. Upgrade PhoneGap to latest version.

You now not only have a back up you can keep old projects maintained against, but you have a version you can use if the new PhoneGap changes something you want to use or breaks a plugin you need for your project. In fact, inside the ‘/Users/Shared/PhoneGap-1.2/Frameworks/PhoneGap.framework/www’ folder is the version-specific PhoneGap iOS JavaScript file if you need to downgrade a project.

The main reason it took so long to port the 4ZzZfm app from Objective-C to PhoneGap had nothing to do with PhoneGap, really. It had to do with adding new functionality at the same time that I had been wanting to add in for some time.

4ZzZfm has a program schedule that changes at the very least every quarter or so. There are also small things that change from time to time for various reasons. Up until this version of the app, changing that program information in the app has meant my updating the schedule manually, then updating the app and submitting a new version to the App Store.

Needless to say, this didn’t happen as frequently as it should have.

So for this version, it was important to me to have the guide be updated from within the app with no updates to the code required. Though getting there was a bit of a challenge, the current version of the app does indeed include that functionality. However, it had not actually been tested in a “live” environment… until today. :)

Today I pushed an updated version of the guide to the server and the app should automatically use that version the next time it starts up (though the background behaviour of iOS and Android mean that this might not happen unless you close it all the way or don’t use it for a given period of time… not entirely sure what all triggers the app having to start from scratch).

Anyway, it seems to have worked. If you or anyone you know has trouble with the app updating the guide, please let me know, but for now I am calling it a success.

If you haven’t already checked out 4ZzZfm and / or the app, it’s available for iPhone and Android now.

Dear 4ZzZfm and lovers of the best community radio station ever

The 4ZzZfm iPhone app has been updated to version 3.0. This new version should always have an up to date Program Guide. It can now update the guide over the internet so it will no longer need an updated version to have a correct guide.

http://devgeeks.org/iphone-apps/4zzzfm-iphone

or on iTunes:

http://itunes.apple.com/au/app/4zzzfm/id359090535?mt=8

oh… and for those that have brought it up whenever the 4ZzZfm iPhone app is mentioned…

Meet the 4ZzZfm Android app!:

http://devgeeks.org/android-apps/4zzzfm-android-app

or on the Android Market:

https://market.android.com/details?id=org.devgeeks.fourzzzfm

So here we are. Almost four months to the day since I last posted about porting the 4ZzZfm iPhone app to PhoneGap, it’s finally awaiting review in the App Store.

A lot has changed from starting out to getting to this point. I’ll be writing a much bigger post about the whole experience (including my new-found hate for timezones and date math), but till then… I am just happy to see the back end of it. :)

Now let’s see if we can get past the approval process OK.

So for all my bemoaning about not having enough time to work on devgeeks work and mobile stuff in particular, I have had a career change of sorts and I am now going to pursue devgeeks as my full-time job.

This means I will be able to take on work as a mobile developer (as well as my more traditional web applications work).

I have set up the new devgeeks.com to this end. I will also continue with the open source plugin development that I talked about in my previous post. I am pretty excited about this change. Feel free to throw work my way so I can keep doing it ;)

It’s that time again. Time to update the 4ZzZfm iPhone app. Actually, it’s way past due… but this is the way things go sometimes.

Early on I attempted to use some of the “write your app in HTML/Javascript/CSS and deploy to iPhone” technologies, but at the time their acceptability by Apple for App Store distribution was in doubt, and I couldn’t get them to do what I wanted anyway. This meant I had to actually learn Objetive-C. Now let me just say that I really like Objective-C. The problem is that I am primarily a PHP developer so HTML/JavaScript/CSS feels more natural to me.

This has lead me to revisit the above-mentioned web technology options for iPhone app development. PhoneGap in particular seems to be both quite mature, used a great deal in apps in the App Store and quite extendable via plugins. This last part is the bit that has tipped it for me. Not only are there some great plugins available for PhoneGap, but it is quite easy to write your own plugins.

What this all comes down to is that I am going to try and re-write the 4ZzZfm iPhone app using PhoneGap and write whatever plugins I need along the way that aren’t catered for in PhoneGap’s core or plugins written by others.

I have already started on this process and I have the Audio Streaming classes written by the amazing Matt Gallagher (cocoawithlove.com) that I used in the original Objective-C version of the app (mostly) working as a PhoneGap plugin. The remote control events don’t work yet, and I am not sure that will be possible from a plugin anyway… that might require some hacking of the PhoneGap core. We’ll see. It needs some more work update: I have had the remote control events working fine. No core hacking needed. Then between updating PhoneGap and iOS something went wrong.

Another piece of functionality I need for the 4ZzZfm iPhone app is a volume control slider. In the Objective-C iPhone SDK that is implemented using an MPVolumeView (from the MediaPlayer framework).  This turned out to be a very easy to make into a PhoneGap plugin. Now one of the best things about PhoneGap is that it and its plugins are open source. PhoneGap and its plugins are developed by the PhoneGap community and available on GitHub. So I have decided to join GitHub myself and submit any plugins I create for this project that I think others might find useful. The first of these that have been added to the main PhoneGap plugins repository is the aforementioned VolumeSlider plugin. I am pleased as punch about this as it is my first real contribution to a modern open source project. Hopefully it is just the first of many more such contributions.

Wish me luck. Worst case I can always just stick with Objective-C.

Apple say they are getting through 83% of new app submissions in 7 days… I guess Brisbanesounds falls in the other 17%

I guess all I can do is wait. I have probably been abnormally lucky with my quick turnarounds on the 4ZzZfm app so far. It’s probably just a lucky numbers game. I suppose I shouldn’t be worried. It would be much more serious if it was taking a long time once the review process actually STARTS… then I would be worried.

I have finally gotten my second app into the review process on the App Store.

It’s an app for the Brisbane Sounds project – http://www.brisbanesounds.com/

Hooray! My latest update to my 4ZzZfm iPhone app is live on the Apple App Store.

Took a bit longer to get approved than the original submission… I guess due to all the iPad app submissions that must be going on at the moment.

What’s new in version 2.0:

  • 4ZzZfm Program Guide navigable by day and time
  • “Now Playing” program listing in stream player view
  • Program Guide displayable in either QLD (Brisbane) time or your local timezone (especially helpful for overseas listeners)
  • Settings bundle for switching between local and QLD time in the Program Guide