Published on

Building my first Phonegap iOS app and what I learned

5 min read
Authors
MideoMe on iOS

I hadn't used a Mac since 1995 and I decided to take it upon myself to program quite an advanced PhoneGap app, specifically the MideoMe iOS app. It wasn't so much that I wanted to, because I really didn't. MideoMe funding would’ve been depleted if a team had been hired. Not only did I have to learn how apps were built, I also had the joy of stumbling around OSX for a few days like it was my first time using a computer. I had previous experience with Ubuntu so basic things in Command Line weren't anything new to me. The rest of OSX and how it works were all things I had to learn pretty quickly.

Getting a running app on OSX is not too difficult. Cordova is setup in using more Command Line now then when I first got it running. It took me 3-4 hours the first time to have anything run successfully. A lot of that was probably just getting Xcode set up and downloading components needed. With Cordova being updated quite frequently, using Google when I got stumped was sometimes no help. Something that worked last year could very well have been changed, leading me to pull my hair out wondering why something doesn't work when it very well should.

The nice thing about OSX is that it’s fairly easy to get everything you need to get an iOS app running since the guts of it are built into the system. Downloading what you need for different iPhones and iPads is all done through Xcode.

Compiling is very easy and apps runs surprisingly fast whether on the machine or on an iOS device. I found this great since sometimes a problem would come about where I would have to re-run the app a half dozen times to get it right.

Having the app talk to the server was one of the first problems I had to figure out. Using a CodeIgniter backend with every bit of security I could jam into it and requiring a token cookie for CSRF meant a work around. iOS doesn't use cookies but localStorage. I figured someone had built a plugin but nothing turned up in when searching the net.

I didn't really want to disable some security for the app, so I added onto the custom CI session library to treat anything with the proper parameters as a stateless call. I got the idea from how Facebook treats API calls from third party apps.

As long as the iOS device added its token and app token parameter and it matched with an available session that had user data, it associated all data as if it was that user. Below is a screenshot from the website that shows that the iOS device is indeed logged in

managing log ins

This allowed the session id to continue updating yet not destroy the handshake from the iOS device.

Mission accomplished right? Wrong! Before I even got that figured out I ran into a problem with AJAX POST requests. When I would send a POST request to https://www.mideome.com the POST data would be dropped and the server would tell me it was a GET request. The fixes from searching the net didn’t work, again most were outdated and weren’t related. The fix was removing the www from the url and just calling https://mideome.com. MideoMe was setup via .htaccess to remove the www from urls. This works fine on the browser but didn’t work on the iOS device.

So, with these problems figured out the rest was just a matter of calling the server and getting the data that the website was already set up to do. The server was already set up to send data back from the cloud.

If you are a programmer than well I’m preaching to the choir when I say REST and JSON is the way to go. Very little had to be changed server side for the MideoMe app to get calls back successfully since a lot of parts were already set up this way. This allowed us to reuse a lot of Javascript and be able to trouble shoot by using the browser when need be instead of Xcode. By keeping everything the same, we can change things server side without having to update the iOS app.

I’m sure there is more I’m forgetting about the development of the app. Getting it on the App Store was a bit of work and stressful. We were already behind with submitting it and if it failed to get on the App Store, it meant another week (I say week because it was a 7 day wait) to try again.

I was going to finish this off by writing a list of what I would have done different but the only thing I can think of is that I would have worked on a smaller app and maybe one that didn’t depend on a server to function. I really enjoyed programming an app and hope I can work on more iOS projects in the future.

The MideoMe app is on the App Store and needed an update even as it was submitted since we had to cut some things out.

MideoMe in the iOS app store

Hopefully in the near future the app can be updated and new features can be added to expand on the short video social networking world.

I would also like to say that most of the HTML of the MideoMe app was done by CEO and awesome graphic designer Jason Rai.

Subscribe to the newsletter