From the course: Learning Cloud Service APIs

Working cross-device

In the three device specific lessons in this chapter for iOS, Android, and Windows Phone, the coding approach has been to go native, with references to the low-level languages preferred by those systems. For many apps, this is the only way to go, which, if you're targeting more than one platform, is a lengthy development process to travel. In this lesson, we'll look at the number of alternative approaches that work cross device. However, before we do, let's examine cloud service APIs optimized for natively coded apps. Not all decide targeted cloud service APIs come from the OS manufacturers. There are a number of third party services that offer dedicated APIs designed to work with one or more of the devices. Amazon Web Services, for example, provides separate SDKs for the top three smartphones. iOS, Android, and Windows Phone via .NET. Of course, there are other cloud services that hone in on just one or two of the markets. Evernote, for instance, creators of the popular note taking app, have an SDK both for iOS, as you see here, and Android. If you're working natively and need an API from a specific service, be sure to research its availability. More and more companies are extending their access in this way. Now let's turn to creating cross-device apps with a single code base. There are basically two different camps to approaching this technique. The first, more generally accessible method uses HTML5 and JavaScript to build the code foundation, which is then compiled and interpreted to run on the different platforms. Companies taking this approach include Sencha, as you see here, and Adobe PhoneGap. When Adobe acquired PhoneGap, they donated the cross-device libraries to Apache, so that they could run under the open source platform, which is now called Cordova. Both Sencha and PhoneGap use Cordova libraries to transform what is, in essence, a web app into a native app. Apps developed during this process are still able to be distributed through the various app stores. Moreover, most of the individual device unique features are available through custom API. Here, for example, is the PhoneGap API for the Accelerometer, which captures device motion in three axes. The other approach to building cross-device apps from a single code base, is to use a lower-level language, which is then output into apps for the various platforms. One product that works this way is Xamarin. Xamarin relies on C# to build cross-device apps, which is great for .NET developers who are used to using that language anyway. Another company, Embarcadero, offers RAD Studio that uses Delphi and C++ to create native language apps for iOS, Android, and Windows. There are plusses and minuses for both cross-device approaches. With the JavaScript approach used by Cordova, you get a much easier to code app that has a high degree of interoperability among the devices. However, some operations may not perform as efficiently as those offered by lower-level language app builders like Xamarin. Such systems require a different and particular skill set to code and, depending on the app, be a bit longer to develop. Whichever approach you take for your app, whether it's native all the way or a version of cross device coding, will, of course, depend on many factors, including your app's needs and your available resources.

Contents