When developing your enterprise mobile app that you and your organization foresee as solving an important business problem for your customers/employees, the time to market is critical. You want to develop the app as quickly as possible and get it into production use. At the same time, you want the make sure that your organization’s data, APIs, and mobile app are secure, and that the mobile back end can seamlessly scale to a large number of mobile users. In this blog, we show you how to leverage open source technologies, such as Apache Cordova and Ionic Framework, and cloud services such as Cloudant® NoSQL database, IBM Cloud Object Storage, and IBM Mobile Foundation to quickly develop and host secure, scalable enterprise mobile apps.

Let us first get a glimpse of the choices we have for mobile app front-end development, as shown below. The quickest and easiest way is pure web apps designed using responsive web design principles, which make your page look good on all devices – desktops, tablets, and phones. According to W3Schools, “responsive web design is about using HTML and CSS to resize, hide, shrink, enlarge, or move content to make it look good on any screen.” Client-side frameworks such as Dojo Mobile and jQuery Mobile further simplify making mobile-friendly websites. While development and maintenance costs are less expensive with mobile web apps, their major disadvantage is that you only have access to the native device features that the browser provides to you.

With the pure native development approach, you can create applications written for a specific platform and run on that platform only. Your applications achieve great performance and can fully leverage all platform functions, such as accessing the camera or contact list, enabling gestures, or interacting with other applications on the device. Native apps for iOS are written in Objective-C or Swift and use Xcode tool on macOS. Native apps for Android are written in the Java™ programming language (some C/C++ code) using Android Studio. Native apps for Windows Phone are written in C# or Visual Basic .NET using Visual Studio. And that is the major disadvantage of native development approach: Code written for one mobile platform cannot be used on another, making the development and maintenance of native apps for multiple platforms a long and expensive undertaking.

Hybrid applications combine the characteristics of pure web and native applications. You can build an application with the simplicity of developing with HTML/CSS/JavaScript. But you can augment that with a variety of native services and produce an application for app stores. With technology like Apache Cordova, you can call native features with JavaScript from your web markup. At its core, Cordova offers a simple but powerful API to call JavaScript functions that map to native code or plugins. It comes with a set of pre-made plugins to do things like access the device’s camera, accelerometer, GPS, compass, file system, microphone, and more. The resulting applications are hybrid, meaning that they are neither truly native mobile applications (because all layout rendering is done via web views instead of the platform’s native UI framework) nor purely web-based (because they are not just web apps but are packaged as apps for distribution and have access to native device APIs).

Ionic, based on the popular open source front-end web application framework Angular, complements Apache Cordova by simplifying the development and the testing of mobile apps. Angular provides a framework for client-side MVC architecture. Ionic provides all the functionality found in native mobile development SDKs. Users can build their apps, customize them for Android or iOS, and deploy through Cordova.

Let us now turn our attention to the mobile back-end services needed for centralized hosting of data and enterprise connectivity. Thanks to cloud-hosted services, you can focus your time and resources on building the app, rather than building and hosting the back end. Cloudant is a fully managed database as a service (DBaaS) running on IBM Cloud. It is a NoSQL JSON document store optimized for handling heavy workloads of concurrent reads and writes in the cloud – a workload that is typical of large, fast-growing web and mobile apps. Cloudant’s horizontal scaling architecture can handle millions of users and terabytes of data to grow seamlessly alongside your business.

In addition to textual data, many mobile apps generate/show non-textual data such as images, audio, and video. For example, an insurance app might allow users to upload images of accident spot. Similarly, a smarter city app might allow the citizens to upload images/video of civic problems. While it is technically feasible to store such non-textual data as attachments to Cloudant documents, there are other cloud services such as IBM Cloud Object Storage that can store/retrieve such non-textual data in a much more economical and scalable way than Cloudant. IBM Cloud Object Storage is a highly scalable cloud storage service, designed for durability, resiliency, and security. It is designed for data durability of 99.999999999 percent. All objects stored in Cloud Object Storage are encrypted by default. Data at rest is encrypted with AES 256-bit encryption and SHA-256 hash and data in motion is secured by using built-in carrier grade TLS/SSL.

A common mistake by novice developers while using such cloud services is embedding the API keys inside the hybrid mobile app. Even though the JavaScript can be obfuscated and the app is packaged into a native package for the app stores, the source code of any Cordova app can still be viewed, and the embedded API keys are not safe from prying eyes. The recommended alternative is to use a secure intermediary server with which the mobile user needs to first authenticate, then the intermediary server acts a gateway through which the mobile app can fetch the data from the back-end services. The API keys for accessing the back-end services are stored securely on the gateway in this scenario.

IBM Mobile Foundation service is a scalable, secure mobile access gateway that radically simplifies integration with back-end and cloud services. In addition, it provides other essential mobile back-end capabilities such as push notifications, app lifecycle management, app analytics, and more.

A new IBM Code developer pattern titled “Develop hybrid mobile app with cloud-native back end” gives you step-by-step instructions for developing an Ionic/Cordova app that securely connects to Cloudant and IBM Cloud Object Storage services via the IBM Mobile Foundation service.

When you have completed this pattern, you will understand:

  • How to authenticate users (through pre-emptive login) using IBM Mobile Foundation security adapter.
  • How to write an IBM Mobile Foundation adapter that authenticates with the IBM Cloud Object Storage service and pass the authorization token to the mobile app.
  • The recommended architectural patterns for coding the interaction between mobile app and the IBM Cloud Object Storage service.
  • How to use imgcache.js in Ionic app for caching images fetched from the IBM Cloud Object Storage service.
  • How to show Google Maps in Ionic app as well as capture user’s geo-location and image from camera.
  • How to upload the captured image from mobile app to IBM Cloud Object Storage.
  • How to fetch data from Cloudant to mobile app via IBM Mobile Foundation adapter, as well as post new data to Cloudant.
  • How to customize the Ionic app logo and splash, and build the release APK for uploading to public/private app stores.

Join The Discussion

Your email address will not be published. Required fields are marked *