Chris Risner . Com

LensRocket for iOS Source Code Released

Posted on: 2/20/2014 8:11:00 PM by

LensRocketFollowing on the heels of the renaming to LensRocket, I’m happy to announce the release of the source code for the iOS version of LensRocket.  LensRocket is an application that allows users to share photos and videos with each other.  The sender can select who they want to send it to and how long the recipients should be able to see it.  Once that time period is up, the photo or video is gone.  It works a lot like the popular app SnapChat.  LensRocket was build to demonstrate that Windows Azure, and more specifically Windows Azure Mobile Services, could be used to quickly get a mobile application off the ground and running.  More so, it shows that Mobile Services is fully capable of working as the backend of a serious mobile application and, in this case, a social app.  You can easily set this app up yourself by signing up for a free trial for Windows Azure here.  Some of the following will be a rehash of what was mentioned at the release of the Android version of LensRocket, though some of it, specifically the platform specific stuff, will be new.

What does the app do

If you think about the core capabilities of an app like this, there really isn’t that much to it.  First, users need to be able to register for an account and then later they need to be able to log into that same account.  From there, users should be able to find other users and become “friends” with them.  Lastly, users should be able to record media, whether it’s pictures or video, and send them to those “friends”.  Now, if that was all an app like SnapChat allowed you to do, it would be hard to imagine it having become so popular.  The real reason SnapChat’s took off was that it makes the media ephemeral (a fancy way of saying it only lives for a short time).  Specifically, users have the ability to decide for how many seconds that image or video is available for their friends to see.  If you think about what that feature means, it makes sense how it’s made SnapChat so popular.  In today’s world of “once it’s on the internet, you can’t get it off”, having some degree of assurance that things will actually be deleted feels pretty good.  That being said, there certainly has been some controversy over whether or not SnapChat actually deletes the files in addition to other apps being made that attempt to grab the files off your device.

How does Azure help us

If I have a great app idea, I definitely want to get my app out there and fast.  Any delay means someone else can beat me to market and my app won’t become popular.  Thankfully Windows Azure has a number of features that make it super simple to get all of the backend features I need but don’t have to spend the time designing, developing, testing, and maintaining them.  For LensRocket we need to be able to authenticate users, store information for users, friend connections, and the files they want to share, actually store the files, as well as push notifications down to our users.  Now, like I said before, this really isn’t a huge amount of stuff.  However, if you think about the time it would take to design systems to handle all of these capabilities, then develop them, then test them, then load test them to make sure they can scale, and then maintain them as my app grows, that is a LOT of time.  Not to mention that is all stuff that will take away from building a really great client experience.  Thanks to the different pieces of Windows Azure, I get the ability to do all of that stuff with very little work on my side.

What parts of Azure does LensRocket use

First and foremost, LensRocket is using Windows Azure Mobile Services.  Mobile Services is what’s known as a Backend-as-a-Service (or BaaS).  The idea is that you spin it up and get access to a ton of features without having to do much work.  If you haven’t looked at Mobile Services before, I highly advise taking a look through some of the tutorials or videos to understand how it works.  For our Mobile Service we’re using both the built in data storage (using SQL Database) as well as the Custom APIs.  We’re also making heavy use of the scripting layer to put in custom logic as well as to handle our own user registration / authentication system (Mobile Services has built in authentication with Facebook, Google, Microsoft, and Twitter accounts but we’re rolling our own).  Mobile Services has us completely covered for all of the relational data we need to store.  For our file storage, we’re going to use Windows Azure Blob Storage.  Blob storage allows us to store both photos and videos extremely cheaply and gives us a way to secure those files so we can make sure only the appropriate people have access to them and only for the appropriate amount of time.  Lastly, we’ll use Windows Azure Notification Hubs to handle push notifications.  Mobile Services has the ability to handle push notifications built into it, however, using Notification Hubs means I can easily set up templates for my pushes (for when I have this app running on more than just Android), do tag based pushes (i.e. easily perform a push notification to all of a user’s devices), as well as many other things.  All of this without me having to build anything into my backend (i.e. keeping track of each user’s devices and what OS they are on and whether or not they want to get pushes, etc).  One thing that is phenomenal about both Mobile Services and Notification Hubs is that they have a free tier.  While storage does not have a free tier, storage is so cheap that I’d have to be storing several gigabytes of picture / video data before I’d even have to pay a dollar a month (Storage has two costs, the actual storage and transactions, however both are cheap).  What this all means is that I can easily develop my app against Windows Azure for nearly free and then, when my app is released and usage goes through the roof, I just need to drag a slider to scale up my Mobile Service and Notification Hub (Storage doesn’t need to be told you want to scale, you just put more data in when you want to).

Tell me about the code

The source code which is available on GitHub under the Apache V2 license, includes both the iOS client source code as well as the Mobile Services scripts (which are javascript).  Once you’ve pulled the code down, you’ll find the iOS code in source/client and the scripts in source/server.  The Readme file includes instructions for how to set up your Mobile Service, Notification Hub, and Storage account as well as where to put the different account names and keys in the client and server code.

Is this code perfect?

I don’t know that I would ever refer to my code as perfect and I’m certain that those of you that spend all of your time in Xcode developing for iOS will take issue with a lot of what is in the app.  That said, the code works and provides a great example of how to do many different things.  Like the Android version, if I’d had more time I’d improve the image handling including taking pictures and videos as well as prefetching them for display when a friend sends you one.  The design is a vast improvement over what I originally had in the Android version though I didn’t have time to fully adapt the design comps over yet but hopefully will in the future.

Can I use this code for my own app?

As the source code for this app is licensed under the Apache 2 license, you’re free to do anything allowed therein, except hold me liable for it.  I would highly recommend testing the client side code extensively launching anything in a public market though.  The same goes for the server side scripts.

What’s next?

Now that the Android and iOS source code is released.  The next step is to actually release this app to the App Store and Google Play.  That will make it easier for people to step through the app’s flow without having to set everything up themselves.  If you’re already experienced with Windows Azure, you can probably be set up within half an hour (for both iOS and Android), however, it’s much easier to just download the app right to your device and that’s the plan.

Summary

LensRocket is a pretty powerful example of how Windows Azure can help you not worry about everything that goes into building a backend and instead focus on making a good client experience.  In time this should become a great cross-platform example as well.  For now, take a look at the iOS and server side source code on GitHub.

Categories: Azure, iOS, Mobile Services
Bookmark and Share
Comments: 0
blog comments powered by Disqus