Creating a one-time login for a mobile AIR Application
October 12, 2012
Posted by on
One of the aspects of Pointillism was that we wanted to minimize the amount of time that the user needed to worry about logins, passwords and signing up for the service. This should be a pretty common goal for most mobile applications — the more you force the user to input that type of information into your app (or verify, re-verify, etc), the less chance they will use it.
We decided to base the app around the “ViewNavigatorApplication” model within Flex. For the rest of the application, it made perfect sense as this type of app could easily be built around “screens” that were stacked as the user moved from one activity to another. The problem was — if I wanted to force the user to login, I would either have to introduce some sort of “launching” screen that would contain the logic-check to see if the user had logged in prior, or I could not define the “firstView” property of the application tag and have some script in the Application tag decide.
My solution consisted of this — I defined the firstView to go right to the dashboard within the application (so, where a logged in user would go). I then added a bit of code to the initialize event handler that could intercept the creation of the View and force it to go to the login screen ONLY IF the user had never logged in before. This allowed the normal operation of launching the app after the user had logged in to go very quickly, yet still force the login in a seamless way. This also meant that the user wasn’t subjected to multiple awkward transitions as the application decided if they were logged in or not.
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
initialize="preAppInit()" firstView="org.pointi.views.MainScreen" .....>
public function preAppInit():void
var userInfo:CurrentUserManager = new CurrentUserManager();
navigator.defaultPushTransition = null;
You will note that I set the default “push” transition because I wanted it to seem that the application launched right to the login screen, instead of having it flip to the screen (giving the impression that the user could hit the back button to go back to another screen). Otherwise, the rest should be pretty self-explanatory.