Mobile

Yafra edited this page Feb 12, 2016 · 23 revisions

The Mobile Project is a mobile application which runs on Apple iOS or Google Android and is build on top of Ionic Framework, AngularJS and Apache Cordova. The mobile app uses RESTful API's to communicate with backend services.

Administration

Prerequisites for mobile development are:

  • NodeJS
  • AngularJS
  • Ionic Framework
  • Jetbrains IDE (Webstorm or any other if you develop a backend in the same project)
  • Google and Apple development account

A version is set on the following locations:

  • on github.com as release and git tag
  • on app js/app.js
  • on app config.xml (the cordova config which updates xcode and adk configs)
  • on app package.json

Google Android

Install the Android SDK - you can use the Android Studio (based on Jetbrains IDEA) however if you have already your environment and do not intend to program Android specifics, the plain SDK is good enough. Set the ANDROID_HOME variable.

Install at least:

  • Android SDK Tools
  • Android SDK Platform Tools
  • Android SDK Build Tools
  • one SDK Platform (4.4 or higher)
  • Android Support Repository
  • Android Support Library

Use the https://console.developers.google.com/project to address any server side or specific API needs. Use the http://developer.android.com/index.html to learn more around the Android SDK.

Use adb logcat to see the console log messages.

Push notifications: Google Cloud Messages

Google push uses a similar way as apple and consists of the client device, your server and google servers. All 3 interact with each other.

Your server interacts via https, an implementation is available as php using curl library. You need to use the browser API key, the server API key is not working on all environments.

If you don't want to host it by yourself you can use common PAAS/SAAS platforms.

See as well a short intro into push plugin Blog Ionic PushV5

Deploy

Register your app on the Google Play Store https://play.google.com/ - you need a one time license in order to publish an app or more. You can use Google+ groups to communicate to your test group.

Apple iOS

Install xcode and enable your Mac and devices to run development software. You will need to set it up through xcode under Settings -> Accounts and on the internet service https://developer.apple.com.

To debug you need the console plugin and you can use the xcode console output or the safari develop option to attach to the device.

You need an Apple ID on the Development Member Center. As well some certificates for Distribution and Development. They are valid for a year.

Push notification: APNS

You will have 2 certificates, one for development and one for production. Development is only used for local builds/installs. For all testdrive and store applications you need to use the PROD certificate. Mixing can cause errors (e.g. no push).

Download the APN certificates as p12 without password and convert them to pem files which you can upload to your server:

openssl pkcs12 -in mcbpush-dev2016.p12 -out mcbpush-dev2016.pem -nodes -clcerts

If you don't want to host it by yourself you can use common PAAS/SAAS platforms.

See as well a short intro into push plugin Blog Ionic PushV5

Deploy

Use xcode (Menu Product) and iTunes Connect https://itunesconnect.apple.com/. Make sure you do not mix Development and Production builds. Before you upload a build, make sure the desired device orientation support is selected. Set the Device requires Full Screen mode, else you get issues with the new ipad multitasking.

Tests

Using Karma with Jasmine or similar for unit tests. Using Protractor / PhantomJS/Selenium for end to end testing.

Template / Demo Mobile App

A non published (not in the app store) mobile application project is available. You can build it and run it on your local mobile phones.

The app shows usage of common modules:

Local storage / sync

Cordova provides a storage plugin in order to use a simple JSON like storage (key, value pairs). Beside that there is a sqlite plugin. Be aware that it only stores a string! If you store an integer use parseInt() or if you use a Date() parse the Date correctly.

GPS

There are 2 different plugins. One which uses the standard HTML5 geolocation API but runs only if the app is running and one which uses background GPS updates and runs even while the app is not running, however it needs an expensive license, only a light version is available for ios.

Push

Native push to Google and Apple Push services. Using internet services like www.parse.com or www.ionicframework.com

Server communications

Using AngularJS Resources (RESTful).

Security / Authentication

OAuth2 protocol usage, simplified through a ngCordova plugin.

General setup:

  • register app on provider side (mainly on a developer portal)
  • get app-id which is used on the app on the authorization call
  • allow callback to localhost
  • allow API in general

General flow is to authenticate:

  • request oauth2 token and permission on the provider api's (like getting the email, pictures, mobiles, ...)
  • do login on in app browser on respecitve provider (mainly providing e-mail / password and allowing the request)
  • getting in the callback the token and expires_in date
  • request info from an API of the provider to get further data

Facebook

Google

Linkedin

Dropbox

to be done.

Github

to be done.