React Native
1.4.29-alpha.19接入配置
React Native 0.72.15;Android API 24 及以上,iOS 15.0 及以上。
npm install react-native-ywx-sign@1.4.29-alpha.19 --registry=https://nexus-inner.51trust.com/repository/npm/Android Maven 配置:
repositories {
google()
mavenCentral()
maven { url 'https://nexus-inner.51trust.com/repository/android/' }
}iOS Podfile 配置:
source 'https://github.com/yiwangxin/YWXSignSDK-Specs.git'
source 'https://cdn.cocoapods.org/'
platform :ios, '15.0'cd ios
pod install --repo-update初始化与环境配置
重点:认证客户使用 public,医信客户使用 szyx。import {SignManager} from 'react-native-ywx-sign';
await SignManager.initialize(clientId);
SignManager.setServerUrl(SignManager.envType.public, clientId, result => {
console.log(result);
});
// 集成环境使用 SignManager.envType.integrate。接口说明
导出加密日志
接口: exportEncryptedLogs
导出加密日志。
调用示例
const result = await SignManager.exportEncryptedLogs();返回结果
Promise<{path: string; segmentCount: number; recordingFailure?: string}>。path 为加密日志文件路径,segmentCount 为日志分段数,recordingFailure 为可选的记录失败信息;失败时 Promise 拒绝,错误包含 code、message。
获取设备标识
接口: getDeviceId
获取设备标识。
调用示例
const result = await SignManager.getDeviceId();返回结果
Promise<string>,成功返回设备标识;失败时 Promise 拒绝,错误包含 code、message。
初始化 SDK
接口: initialize
初始化 SDK。
调用示例
const result = await SignManager.initialize(clientId);| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
返回结果
Promise<boolean>。Android 返回初始化是否成功;iOS 返回 true,初始化由 setServerUrl 完成。
查询当前用户证书
接口: existsCert
查询当前用户证书。
调用示例
SignManager.existsCert(result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
callback | function | 返回结果回调 |
返回结果
callback(exists: boolean)
查询指定手机号证书
接口: existsCerts
查询指定手机号证书。
调用示例
SignManager.existsCerts(phone, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
phone | string | 手机号 |
callback | function | 返回结果回调 |
返回结果
callback(exists: boolean)
查询指定厂商证书
接口: existsCertWithFirmId
查询指定厂商证书。
调用示例
SignManager.existsCertWithFirmId(phone, firmId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
phone | string | 手机号 |
firmId | string | 厂商标识 |
callback | function | 返回结果回调 |
返回结果
callback(exists: boolean)
下载证书
接口: certDown
下载证书。
调用示例
SignManager.certDown(clientId, phone, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
phone | string | 手机号 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
下载指定厂商证书
接口: certDownWithFirmId
下载指定厂商证书。
调用示例
SignManager.certDownWithFirmId(clientId, phone, firmId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
phone | string | 手机号 |
firmId | string | 厂商标识;独立接入时与 clientId 相同 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
更新证书
接口: certUpdate
更新证书。
调用示例
SignManager.certUpdate(clientId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
更新指定厂商证书
接口: certUpdateWithFirmId
更新指定厂商证书。
调用示例
SignManager.certUpdateWithFirmId(clientId, firmId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
firmId | string | 厂商标识 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
设置服务环境
接口: setServerUrl
设置服务环境。
调用示例
SignManager.setServerUrl(SignManager.envType.public, clientId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
envNo | enum | SignManager.envType.public/szyx/integrate |
clientId | string | 客户应用标识 |
callback | function | 返回结果回调 |
返回结果
Android:callback(serverUrl: string | null),成功返回服务根地址,初始化失败返回 null;iOS:callback(),无结果参数。
重置签名密码
接口: certResetPin
重置签名密码。
调用示例
SignManager.certResetPin(clientId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
重置指定厂商签名密码
接口: certResetPinWithFirmId
重置指定厂商签名密码。
调用示例
SignManager.certResetPinWithFirmId(clientId, firmId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
firmId | string | 厂商标识 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
查看证书
接口: showCertView
查看证书。
调用示例
SignManager.showCertView(clientId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
查看指定厂商证书
接口: showCertViewWithFirmId
查看指定厂商证书。
调用示例
SignManager.showCertViewWithFirmId(clientId, firmId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
firmId | string | 厂商标识 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
获取用户证书信息
接口: getCertInfo
获取用户证书信息。
调用示例
SignManager.getCertInfo(clientId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
获取指定厂商用户信息
接口: getCertInfoWithFirmId
获取指定厂商用户信息。
调用示例
SignManager.getCertInfoWithFirmId(clientId, firmId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
firmId | string | 厂商标识 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
设置签章
接口: drawStamp
设置签章。
调用示例
SignManager.drawStamp(clientId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
清除本地证书
接口: clearCert
清除本地证书。
调用示例
SignManager.clearCert();返回结果
无返回值。
开启免密签名
接口: keepPin
开启免密签名。
调用示例
SignManager.keepPin(clientId, keepDay, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
keepDay | number | 免密有效天数,1–60 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
查询免密状态
接口: isPinExempt
查询免密状态。
调用示例
SignManager.isPinExempt(result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
callback | function | 返回结果回调 |
返回结果
callback(enabled: boolean)
关闭免密签名
接口: clearPin
关闭免密签名。
调用示例
SignManager.clearPin();返回结果
无返回值。
处理业务二维码
接口: qrDispose
处理业务二维码。
调用示例
SignManager.qrDispose(clientId, qrText, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
qrText | string | 二维码原文 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
处理二维码与授权登录
接口: qrDisposeWithGrantOauth
处理二维码与授权登录。
调用示例
SignManager.qrDisposeWithGrantOauth(clientId, qrText, isHandleGrantOauth, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
qrText | string | 二维码原文 |
isHandleGrantOauth | boolean | 是否处理授权登录信息 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
完成授权登录
接口: startOauthLogin
完成授权登录。
调用示例
SignManager.startOauthLogin(clientId, uuid, grantOpenId, grantUserName, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
uuid | string | 授权请求标识 |
grantOpenId | string | 授权用户 OpenId |
grantUserName | string | 授权用户姓名 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
获取 SDK 版本
接口: getVersion
获取 SDK 版本。
调用示例
SignManager.getVersion(result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
callback | function | 返回结果回调 |
返回结果
callback(version: string)
获取用户 OpenId
接口: getOpenId
获取用户 OpenId。
调用示例
SignManager.getOpenId(result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
callback | function | 返回结果回调 |
返回结果
callback(openId: string)
签署待签数据
接口: sign
签署待签数据。
调用示例
SignManager.sign(clientId, uniqueIdList, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
uniqueIdList | string[] | 待签数据 ID 数组,最多 100 条 |
callback | function | 返回结果回调 |
返回结果
回调结果含 status、message。Android 的业务数据位于 data;iOS 成功时将签名结果字段放在结果顶层,不提供 data 和 uniqueId 字段。
签署指定厂商待签数据
接口: signWithFirmId
签署指定厂商待签数据。
调用示例
SignManager.signWithFirmId(clientId, firmId, uniqueIdList, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
firmId | string | 厂商标识 |
uniqueIdList | string[] | 待签数据 ID 数组,最多 100 条 |
callback | function | 返回结果回调 |
返回结果
回调结果含 status、message。Android 的业务数据位于 data;iOS 成功时将签名结果字段放在结果顶层,不提供 data 和 uniqueId 字段。
协同签名
接口: signForTeam
协同签名。
调用示例
SignManager.signForTeam(clientId, uniqueIdList, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
uniqueIdList | string[] | 待签数据 ID 数组,最多 100 条 |
callback | function | 返回结果回调 |
返回结果
回调结果含 status、message。Android 的业务数据位于 data;iOS 成功时将签名结果字段放在结果顶层,不提供 data 和 uniqueId 字段。
获取签章图片
接口: getStampPic
获取签章图片。
调用示例
SignManager.getStampPic(result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
callback | function | 返回结果回调 |
返回结果
callback(stampPicture: string),Base64 图片。
获取指定厂商签章图片
接口: getStampPicWithFirmId
获取指定厂商签章图片。
调用示例
SignManager.getStampPicWithFirmId(firmId, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
firmId | string | 厂商标识 |
callback | function | 返回结果回调 |
返回结果
callback(stampPicture: string),Base64 图片。
设置生物识别签名
接口: alterFingerSignState
设置生物识别签名。
调用示例
SignManager.alterFingerSignState(SignManager.fingerSignState.on, result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
fingerSignState | 0 | 1 | SignManager.fingerSignState.on 或 off |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
查询生物识别状态
接口: getFingerSignState
查询生物识别状态。
调用示例
SignManager.getFingerSignState(result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
callback | function | 返回结果回调 |
返回结果
callback(enabled: boolean)
开启自动签名
接口: signAutoRequest
开启自动签名。
调用示例
const result = await SignManager.signAutoRequest(clientId, firmId, sysTag);| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
firmId | string | 厂商标识 |
sysTag | string | 自动签系统标识 |
返回结果
Promise<业务结果>:status、message、data。
查询自动签名信息
接口: signAutoInfo
查询自动签名信息。
调用示例
const result = await SignManager.signAutoInfo(clientId);| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
返回结果
Promise<业务结果>:status、message、data。
查询指定厂商自动签名信息
接口: signAutoInfoWithFirmId
查询指定厂商自动签名信息。
调用示例
const result = await SignManager.signAutoInfoWithFirmId(clientId, firmId);| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
firmId | string | 厂商标识 |
返回结果
Promise<业务结果>:status、message、data。
关闭自动签名
接口: signAutoStop
关闭自动签名。
调用示例
const result = await SignManager.signAutoStop(clientId, firmId, sysTag);| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
firmId | string | 厂商标识 |
sysTag | string | 自动签系统标识 |
返回结果
Promise<业务结果>:status、message、data。
授权他人签名
接口: sureGrantSign
授权他人签名。
调用示例
const result = await SignManager.sureGrantSign(clientId, firmId, grantedUserId, timeOut);| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
firmId | string | 厂商标识 |
grantedUserId | string | 被授权用户标识 |
timeOut | number | 授权时长,单位小时 |
返回结果
Promise<业务结果>:status、message、data。
设置页面语言
接口: setLanguage
设置页面语言。
调用示例
SignManager.setLanguage(language);| 参数 | 类型 | 说明 |
|---|---|---|
language | string | zh 或 en |
返回结果
无返回值。
显示 PIN 输入框
接口: showPinWindow
显示 PIN 输入框。
调用示例
const result = await SignManager.showPinWindow();返回结果
Promise 结果含 status、message、data;成功时 data.pin 为签名密码,data.pinForNet 为网络传输密文。
关闭 PIN 输入框
接口: hidePinWindow
关闭 PIN 输入框。
调用示例
const result = await SignManager.hidePinWindow();返回结果
Promise<业务结果>:status、message、data。
设置指定厂商签章
接口: drawStampWithFirmId
设置指定厂商签章。
调用示例
const result = await SignManager.drawStampWithFirmId(clientId, firmId);| 参数 | 类型 | 说明 |
|---|---|---|
clientId | string | 客户应用标识 |
firmId | string | 厂商标识 |
返回结果
Promise<业务结果>:status、message、data。
查询可用生物识别类型(iOS)
接口: getSupportedBiometricTypes
查询可用生物识别类型。
调用示例
SignManager.getSupportedBiometricTypes?.(result => console.log(result));| 参数 | 类型 | 说明 |
|---|---|---|
callback | function | 返回结果回调 |
返回结果
callback({status, message, data: ('fingerprint' | 'face')[] | null})
开启指定生物识别签名(iOS)
接口: openBiometric
开启指定生物识别签名。
调用示例
SignManager.getSupportedBiometricTypes?.(result => {
const type = result.status === '0' ? result.data?.[0] : undefined;
if (type) SignManager.openBiometric?.(type, value => console.log(value));
});| 参数 | 类型 | 说明 |
|---|---|---|
type | 'fingerprint' | 'face' | 从 getSupportedBiometricTypes 返回值中选择 |
callback | function | 返回结果回调 |
返回结果
回调业务结果:status、message、data。
升级指引
npm install react-native-ywx-sign@1.4.29-alpha.19 --registry=https://nexus-inner.51trust.com/repository/npm/
cd ios
pod install --repo-update| 原调用 | 必须修改 |
|---|---|
setEnableLog(...) | 删除调用;通过 exportEncryptedLogs() 导出加密日志 |
setIsHideSignLoading(...) | 删除调用 |
signBySignet(...) | 改用 sign(clientId, uniqueIdList, callback) |