npm i --save nativescript-onfido
- 版本:0.0.5
- GitHub:
- NPM: https://npmjs.net.cn/package/nativescript-onfido
- 下载
- 昨天: 0
- 上周: 0
- 上个月: 0
NativeScript
用于在 NativeScript 应用中使用 Onfido 的插件,支持 IOS 和 Android(尚未开始)。
先决条件
为了开始集成,您需要 API 令牌 和 移动 SDK 令牌。您可以使用我们的 沙盒 环境来测试您的集成,您可以在 Onfido 控制台 中找到这两个沙盒令牌。
警告:当配置 SDK 本身时,您 必须 使用 移动 SDK 令牌 而不是 API 令牌。
安装
描述您的插件安装步骤。理想情况下,它应该是这样的
tns plugin add nativescript-onfido
用法
Angular
app.component.html
<Onfido [settings]="onfidoSettings"></Onfido>
app.component.ts
import { registerElement } from 'nativescript-angular/element-registry';
registerElement('Onfido', () => require('nativescript-onfido').Onfido);
class AppComponent {
onfidoSettings: any;
constructor() {
this.onfidoSettings = {
applicantId: "YOUR_APPLICANT_ID",
token: "YOUR_SDK_TOKEN",
enable: true,
responseHandler: (response: any) => {
if (response.userCanceled) {
// Flow cancelled by the user
} else if (response.results) {
// User completed the flow
// You can create your check here
} else if (response.error) {
// Some error happened
}
}
};
}
}
JavaScript
main-page.xml
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="pageLoaded" class="page"
xmlns:ui="nativescript-onfido">
<ui:Onfido settings="{{onfidoSettings}}"></ui:Onfido>
</Page>
main-view-model.ts
import { Observable } from 'tns-core-modules/data/observable';
export class HelloWorldModel extends Observable {
public onfidoSettings: any;
constructor() {
super();
this.onfidoSettings = {
applicantId: "YOUR_APPLICANT_ID",
token: "YOUR_SDK_TOKEN",
enable: true,
responseHandler: (response: any) => {
if (response.userCanceled) {
// Flow cancelled by the user
} else if (response.results) {
// User completed the flow
// You can create your check here
} else if (response.error) {
// Some error happened
}
}
};
}
}
许可证
Apache 许可证版本 2.0,2004 年 1 月