Why Native Extensions for AIR
With the release of the RC builds of AIR 3.0 and Flash Player 11 on labs more details about the coming runtimes is being discussed publicly. I want to focus on one of the new features called Native Extensions for AIR, Oliver Goodman does a great job explaining the feature and some of the details of how it works. To get more information you will not want to miss MAX 2011 in LA.
Now to the why. Why would you use Native Extensions for AIR? Let us start at the beginning with content. Content and its requirements drive decisions about where you want to take your application. Does it require specific features that are not cross platform? Does it need to be multi-screen? Does it need to have a reasonable ROI on UI and business logic across multiple screen?
With the current release of AIR (2.7) a lot of high quality content can be built across screens (ie: CaltrainTimes), but with AIR 3.0 the possibilities grow even larger. Now when you need that one specialized feature across certain screens or all screens with AIR 3.0 you have the flexibility to look at Native Extensions as an option to extend AIR. My use case was creating an application for mobile devices that acts like a point of sale system, basically being able to take credit card transactions on the go. AIR is great for the use case to encapsulate my UI across the various platforms along with having all my business logic for the transaction with the merchant gateway. But what was lacking was the ability to interface with the various card reader device accessories.
To give my use case a try, I obtained a Magtek iDynamo credit card reader. The Magtek accessory fits into the bottom connector on a iPod or iPhone. I then created a XCode project and coded up the native Objective C code part of the Native Extensions for AIR. The Objective C code was the bare minimum of setting up the EAAccessory and waiting for an InputStream of data coming from the card reader. I created the ActionScript interface library to start up the EAAccessory and listen for data events. Even with being fairly new to Objective C and XCode library projects, I was still able to whip up an example from Objective C to ActionScript to Flex mobile application using Flash Builder 4.5.1 in less than a day. The result can be seen in the image below (my credit card # is masked and it is an expired/cancelled card):
I am sure there are a few questions around this new feature. For now, definitely read through Oliver’s article, come to MAX, and wait for the final runtime releases when more detail information and examples will be made available.
Pingback: Cool Stuff with the Flash Platform - 9/8/2011 | Remote Synthesis
Pingback: Adobe MAX 2011: A Year in the Making | Paul Trani
Pingback: Flash Player 11, AIR 3, and Flex/Flash Builder 4.6 | Ryan Stewart – Mountaineer Coding
Pingback: AIR Native Extension Example: iBattery for iOS | todd anderson
Pingback: Why I’m Doing PhoneGap | Ryan Stewart – Mountaineer Coding
Pingback: What *IS* Wrong With AIR 3.0 Native Extensions!