ios-sdk
集成到 Silt 的注册的 SDK
这是一个用于与 iOS 上的 Silt 的 KYC & ID 验证集成的 SDK。Silt SDK 框架位于 SiltSDK 目录中。有关 API 和其他 SDK 的更多信息,请访问 https://getsilt.com/developers
如何导入 SDK
- 只需创建一个名为
Podfile
的文件或将以下行添加到该文件中:pod 'SiltSDK', '~> 1.2'
。
target 'MyApp' do
pod 'SiltSDK', '~> 1.2'
end
(有关 Podfile 的更多信息请参阅:(https://guides.cocoapods.org.cn/using/the-podfile.html))
- 运行命令
$ pod install
。 - 重要:打开
YourApp.xcworkspacep
并编译。 - 最后,将
隐私 - 相机用途描述
:相机用途描述
添加到您的Info.plist
文件中。
SiltSDK 是一个可在以下位置找到的 Cocoapod:https://cocoapods.org.cn/pods/SiltSDK
以下是使用 Cocoapods 的入门指南:(https://guides.cocoapods.org.cn/using/getting-started.html) 以及将 Cocoapod 库导入应用程序的指南:(https://guides.cocoapods.org.cn/using/using-cocoapods.html)
如何使用
您需要添加到您的应用程序的唯一代码位于示例 ViewController 文件中:SiltSDKExamples/ViewController.swift
loadSiltSignup
函数的按钮
1. 添加一个调用 // siltButtonBlue position and target
siltButtonBlue.addTarget(self, action: #selector(loadSiltSignup), for: .touchUpInside)
siltButtonBlue.setStyle(bStyle: "blue")
siltButtonBlue.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
loadSiltSignup
函数。
2. 查看 SiltSDKExamples/ViewController.swift
以获取示例。
在 [email protected] 上请求您的 companyAppId
或从 https://dashboard.getsilt.com 获取它,并在初始化器中使用它。
tldr;
用于验证用户进行 KYC 的函数 loadSiltSignup
的所有代码示例
@objc func loadSiltSignup() {
let vc = SiltWebviewController(companyAppId:"{{YOUR_COMPANY_APP_ID}}", extraQuery:"&[email protected]")
// Subscribe to the notification that will be triggered when a user finishes Silt's verification flow,
// that will run "onFinishedSiltVerification" function
NotificationCenter.default.addObserver(self, selector: #selector(onFinishedSiltVerification(_:)), name: .didFinishedSiltVerification, object: nil)
// set the Presentation style of the webview
vc.modalPresentationStyle = .overFullScreen //or .overFullScreen for transparency
self.present(vc, animated: true, completion: nil)
}
loadSiltSignup
函数的详细说明。
在 [email protected] 上请求您的 companyAppId
或从 https://dashboard.getsilt.com 获取它,并在初始化器中使用它。
SiltWebviewController(companyAppId: {YOUR_CUSTOMER_APP_ID} )
演示公司 AppId:2022a022-a662-4c58-8865-a1fb904d2cde
。
向 SiltWebviewController 添加参数 "outTransition: .fromLeft"
来定义关闭 webview 时的退出动画
示例 KYC
@objc func loadSiltSignup() {
let vc = SiltWebviewController(companyAppId:"2022a022-a662-4c58-8865-a1fb904d2cde", extraQuery:"&[email protected]")
...
示例 Biocheck
@objc func loadSiltSignup() {
let vc = SiltWebviewController(companyAppId:"2022a022-a662-4c58-8865-a1fb904d2cde",
path: "biocheck",
extraQuery:"&temp_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxx")
...
订阅当用户完成 Silt 的验证流程时将触发的通知,该通知将运行 onFinishedSiltVerification
函数
NotificationCenter.default.addObserver(self, selector: #selector(onFinishedSiltVerification(_:)), name: .didFinishedSiltVerification, object: nil)
您也可以在获取 userID 后订阅通知 didGotSiltUserID
,在获取 app 令牌后订阅 didGotCompanyAppToken
。 siltUserId
或 siltCompanyAppToken
的值将包含在 userInfo 对象中。
NotificationCenter.default.addObserver(self, selector: #selector(onGotSiltUserId(_:)), name: .didGotSiltUserID, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(onGotCompanyAppToken(_:)), name: .didGotCompanyAppToken, object: nil)
您可以使用 Silt 提供的 getTransition
函数创建转换
view.window!.layer.add(getTransition(subtype: .fromRight), forKey: kCATransition)
设置 webview 的显示样式
vc.modalPresentationStyle = .overFullScreen //or .overFullScreen for transparency
self.present(vc, animated: true, completion: nil)
您还可以设置默认动画
self.present(vc, animated: true, completion: nil)
onFinishedSiltVerification
func
3. The onFinishedSiltVerification
函数用于恢复淤积物 ID。请参阅 SiltSDKExamples/ViewController.swift
以获取示例。
@objc func onFinishedSiltVerification(_ notification: Notification) {
let siltUserId = notification.userInfo?["siltUserId"] as? String
let siltCompanyAppToken = notification.userInfo?["siltCompanyAppToken"] as? String
if(!(siltUserId!).isEmpty && !(siltCompanyAppToken!).isEmpty){
// Call your backend here to verify this userId
print("Got a verified user Id: \(siltUserId!) \(siltCompanyAppToken!)")
}
}
4. 查询用户的验证信息
实现从不属于 Silt 的后端调用 Silt 的后端以获取用户的验证状态和信息。更多详情请参见 https://getsilt.com/developers
如何工作
此 SDK 仅包含一个按钮,该按钮打开一个 webview 并在用户完成 webview 中的验证后捕获用户 ID。这是您可以用于在 Silt 中验证该用户身份证验证的用户 ID。