Skip to content
This repository was archived by the owner on Nov 19, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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());
}
}
7 changes: 2 additions & 5 deletions cordova-plugin-template/www/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', []);
}
};

Expand Down
2 changes: 1 addition & 1 deletion onfidoSampleApp/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@
<plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^1.1.16" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
<plugin name="my-cordova-plugin" spec="/Users/sergiomoura/repos/cordova-plugin-template" />
<plugin name="my-cordova-plugin" spec="../cordova-plugin-template" />
<engine name="android" spec="^7.0.0" />
</widget>
1 change: 1 addition & 0 deletions onfidoSampleApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions onfidoSampleApp/src/pages/home/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ export class HomePage {

}

startSdk() {
(<any>window).MyCordovaPlugin.launchFido(function() {
// callback
});
}
}