Cookie Notice

Showing posts with label Windows Azure Mobile Services. Show all posts
Showing posts with label Windows Azure Mobile Services. Show all posts

Wednesday, 29 January 2014

Simple Apps are not Necessarily Stupid Apps

I am a Developer

I have been one from the moment I walked into my high school a long long long time ago and found out they had a computer.  This was in the dark ages before any (mostly) had a computer at home.  I worked hard at learning programming.  Over the years I went HP/Basic to dBase to COBOL to Clipper to RPGII to Visual Basic to VB.NET to C# to Java Script.  There are a few others tossed in for fun but those were the ones I remember the most or somebody paid me to work with.  I wrote software.  I wrote software that had great scope from corporate aircraft schedule software for NASA to medical/dental billing programs for specialist physicians.  They programs were large and did much "stuff".  Programs that did just one thing well were call "features".

That all changed with the advent of smart phones and mobile apps.  I didn't though in the beginning and perhaps many of you haven't either.  Some developers have only know the quick and small app model.  I envy them.  There is nothing to unlearn.  I used to scoff at "waste apps" like flashlights thinking that there is no art in it.  Well, I was wrong.

I have had the fortunate luck to spend some time talking with Atley Hunter (@atleyhunter) and I learned a few things I have since proven with my own apps.  The one single most important thing, and the topic of this post, is that the simpler, more single minded an app is, the more popular it is.  People don't want to open an app to do a bunch of stuff.  They want to open an app that does what they want and then goes away.  The trick is to find what they want, build it and get it out the door.  The other trick is to make something that might not be as simple as it looks, look really simple. 

A Unique Bell

As a test, I wrote a simple app that doesn't do anymore than ring a desk bell.  Simple right?  But others have done it so why bother?  I was sitting around a table at a friends house and he explained how his bell app was really useful.  Useful for getting service attention, useful for meetings, and most important,  useful for annoying his family no end.  I looked at the apps there were there and thought "I can do better than that".  I thought, a bell is kinda boring, how can I make it fun.  Well with Windows Phone I have all sorts of helpful stuff available to me.  I thought, why not make a bit of a game out of it.  So I create a bell that keeps score.  Every time you tap the bell it registers in Windows Azure the country the bell was rung in.  Then lets you know where your locale stands.  It took no extra effort by the user but created a really stupid simple app that was fun and is still different than what is in the score.  It took me a long time to figure out and break my bad habit of dismissing simple apps as "not real programming".  It is and has value to somebody.  All it took was a little bit of sound and Windows Azure Mobile Services.  I made a believer of some users and they have even suggested that for their locale it would be nice if it showed competition between cities!  I love when I get ideas from users of my apps.  They are gold.  I started out with the first page which was just a counter, but requests came in to add a leaderboard.  As of this writing, it's in certification.

And it Applies to Most Categories

I have also written simple apps in the Camera category (Camera is hot hot hot in WP), GPS and games.  Keep it simple.  Let them be able to go in, have fun, then get on with their real life.  The programs that are used for hours on end have their place but there is no reason why you can't start with small and easy.  Let the users dictate the complexity.

Windows Azure Mobile Services
Desk Bell - Look for the leaderboard update coming soon!

Thursday, 26 December 2013

Registering for Live Tile Pushes from Windows Azure Mobile Services

This last weekend I decided to get started on my Developer Movement apps.  I decided to make sure the new app had Windows Azure integration and what better way to do that by using Mobile Services. 

I was surprised to find out that there was not as much sample code available as I would have liked.  I created a very simple app that keeps a simple counter.  I wanted that counter to be pushed to a live tile.  Sounds simple right?  Well mostly it is, but, of course, I wanted to have a bit of flexibility so I decided to do it with JScript using the scheduler.  I handled the input of the data from the app using web services deployed to a web site but that is really for another conversation.   What I want to cover here is the push stuff.  What happens after the app is closed and Azure takes over.

Windows Azure mobile services are simply marvelous.  They not only give you a nice tidy way to read and write to the SQL Azure database but it has the built in ability to schedule pushes for your applications.  From the Mobile Services homepage for your application (first 5 are free right now) you have the ability to create databases, add an API that allows your mobile app access to that database, define and create PUSHes to your mobile app (toast and live tiles) and lastly you can schedule automatic pushes of those notifications.  And it works with Windows Phone, and most other platforms.  So write your backend once and then roll it out to multiple mobile platforms.  However, we are talking Live Tiles here and that means Windows Phone.

Right from the Windows Azure Mobile Services home page for your app it gives you great instructions on how to create a Live Tile push notifications including sample code (JScript for the Azure size and C# for the Windows Phone side).  The instructions are very clear and I was able to implement the Live Tile quite easily.

http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-with-push-wp8/

There is one little tiny bit of information that is missing here though.  You see, the instructions include code for registering a particular app instance on a phone so that the push knows where to send the data.  However, to be polite, you really should always give the user the option to turn Live Tiles off.  At least I think its polite.  To do that you have to Unregister your app when requested.  By default you don't need to do anything on the Azure side.  If you followed the instructions in the link above, all is done for you.  What you do need to do is call a bit of code in your app when the user requests that pushes be turned off.  The important line there is the DeleteAsync but you need to make sure you have the correct channel identification.   This will work with the sample code linked above.

// In the AquirePushChannel method, save the ID when we get the registration
//   And save it someplace like isolatedstorage or just App.Xaml.cs.  
//   You could write something to return the ID, but this will just work.
//   immediately after the await  InsertAsync()
PushRegistration = registration.Id;

// See if we have a Channel already
CurrentChannel = HttpNotificationChannel.Find("MyPushChannel");

if (CurrentChannel != null)
{
    // We have a channel.  need to retrieve the ID from the 
    //   Registrations table
    IMobileServiceTable<Registrations> registrationsTable = App.MobileService.GetTable<Registrations>();
    var registration = new Registrations
    {
        // Get the ID we stored away when we started the App.
        Id= PushRegistration
    };
    //  Tell Windows Azure Mobile Services to delete our channel
    await registrationsTable.DeleteAsync(registration);
}

That's all there is to it.  Follow the rest of the instructions and you should have a nicely full functioning Live Tile App.

Enjoy!