From e37401528e2a9da18de35a38f1d2cd55d3872015 Mon Sep 17 00:00:00 2001 From: tony <1@anthony.sh> Date: Fri, 27 Apr 2018 19:46:10 +0200 Subject: [PATCH 1/4] Cordova Plugin > Switch 'withToken' to the OnfidoConfig instead of the Applicant --- .../src/android/com/example/MyCordovaPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cordova-plugin-template/src/android/com/example/MyCordovaPlugin.java b/cordova-plugin-template/src/android/com/example/MyCordovaPlugin.java index 8fc0ccd..a72b29a 100644 --- a/cordova-plugin-template/src/android/com/example/MyCordovaPlugin.java +++ b/cordova-plugin-template/src/android/com/example/MyCordovaPlugin.java @@ -79,12 +79,12 @@ private Applicant getTestApplicant() { return Applicant.builder() .withFirstName("Ionic") .withLastName("User") - .withToken("YOUR_MOBILE_TOKEN") .build(); } private OnfidoConfig.Builder getTestOnfidoConfigBuilder() { return OnfidoConfig.builder() + .withToken("YOUR_MOBILE_TOKEN") .withApplicant(getTestApplicant()); } } From 1447181a60e53b53d0848929fc0f09dbd22b4faf Mon Sep 17 00:00:00 2001 From: tony <1@anthony.sh> Date: Fri, 27 Apr 2018 19:48:35 +0200 Subject: [PATCH 2/4] onfidoSampleApp > fix dependency to the plugin --- onfidoSampleApp/config.xml | 2 +- onfidoSampleApp/package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/onfidoSampleApp/config.xml b/onfidoSampleApp/config.xml index 954d862..aa77e43 100644 --- a/onfidoSampleApp/config.xml +++ b/onfidoSampleApp/config.xml @@ -81,6 +81,6 @@ - + diff --git a/onfidoSampleApp/package.json b/onfidoSampleApp/package.json index 3b01e9e..f8a340b 100644 --- a/onfidoSampleApp/package.json +++ b/onfidoSampleApp/package.json @@ -23,6 +23,7 @@ "@angular/platform-browser-dynamic": "5.2.9", "@ionic-native/core": "^4.5.3", "@ionic-native/splash-screen": "4.5.3", + "cordova-plugin-template": "file:../cordova-plugin-template", "@ionic-native/status-bar": "4.5.3", "@ionic/storage": "2.1.3", "cordova-android": "^7.0.0", From f5dbf13014f3ec38b3ef2a457b593caf362122d1 Mon Sep 17 00:00:00 2001 From: tony <1@anthony.sh> Date: Fri, 27 Apr 2018 19:53:17 +0200 Subject: [PATCH 3/4] onfidoSampleApp > Made the 'Start Flow' button exec onfido sdk --- .../src/android/com/example/MyCordovaPlugin.java | 2 +- cordova-plugin-template/www/plugin.js | 7 ++----- onfidoSampleApp/src/pages/home/home.ts | 5 +++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cordova-plugin-template/src/android/com/example/MyCordovaPlugin.java b/cordova-plugin-template/src/android/com/example/MyCordovaPlugin.java index a72b29a..142de4d 100644 --- a/cordova-plugin-template/src/android/com/example/MyCordovaPlugin.java +++ b/cordova-plugin-template/src/android/com/example/MyCordovaPlugin.java @@ -49,7 +49,7 @@ public void initialize(CordovaInterface cordova, CordovaWebView webView) { } public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { - if(action.equals("startSdk")) { + if(action.equals("launchFido")) { Activity context=this.cordova.getActivity(); client = OnfidoFactory.create(context).getClient(); diff --git a/cordova-plugin-template/www/plugin.js b/cordova-plugin-template/www/plugin.js index c877d75..c5410b5 100644 --- a/cordova-plugin-template/www/plugin.js +++ b/cordova-plugin-template/www/plugin.js @@ -4,11 +4,8 @@ var exec = require('cordova/exec'); var PLUGIN_NAME = 'MyCordovaPlugin'; var MyCordovaPlugin = { - echo: function(phrase, cb) { - exec(cb, null, PLUGIN_NAME, 'echo', [phrase]); - }, - getDate: function(cb) { - exec(cb, null, PLUGIN_NAME, 'getDate', []); + launchFido: function(cb) { + exec(cb, null, PLUGIN_NAME, 'launchFido', []); } }; diff --git a/onfidoSampleApp/src/pages/home/home.ts b/onfidoSampleApp/src/pages/home/home.ts index 1d510dd..04c220a 100644 --- a/onfidoSampleApp/src/pages/home/home.ts +++ b/onfidoSampleApp/src/pages/home/home.ts @@ -11,4 +11,9 @@ export class HomePage { } + startSdk() { + (window).MyCordovaPlugin.launchFido(function() { + // callback + }); + } } From 9ab8f31a44471a6d8148d3572de27185d389bb2e Mon Sep 17 00:00:00 2001 From: tony <1@anthony.sh> Date: Fri, 27 Apr 2018 20:03:22 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 67c9e98..efa1a95 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,44 @@ # onfido-sdk-ionic-sample-app Sample app showcasing the integration of the Onfido SDK on an Ionic app -This project consists of 2 modules: +## This project consists of 2 modules: - `onfidoSampleApp` contains the sample app code - `cordova-plugin-template` contains the Cordova plugin that wraps the Onfido Android SDK. Based on [this template](https://github.com/ionic-team/cordova-plugin-template) -How to run: +## How to run: +Install the project, link the plugin to the sample app and add android platform -`cd cordova-plugin-template && cordova build android` -Builds the cordova plugin wrapping the Onfido Android SDK +``` +cd onfidoSampleApp +npm install +cordova plugin add --link ../cordova-plugin-template +cordova platform add android +``` -`cd onfidoSampleApp && cordova plugin add --link ../cordova-plugin-template` -Links the plugin to the sample app -`ionic serve` -Starts the app +## Edit for adding the SDK dependency (According to the [Android SDK Documentation](https://github.com/onfido/onfido-android-sdk#2-adding-the-sdk-dependency)): +``` +platforms/android/app/build.gradle +``` +``` +repositories { + maven { + url "https://dl.bintray.com/onfido/maven" + } +} -TODO: +dependencies { + compile 'com.onfido.sdk.capture:onfido-capture-sdk:+' +} +``` + +## Build and start the app +``` +ionic cordova build android +cordova emulate android +``` + + +## TODO: - Complete the e2e integration between the Ionic application and the Cordova plugin, with callbacks to the application. \ No newline at end of file