Realaml 0.3.0

Realaml 0.3.0

Gowtham Selvaraj 维护。



Realaml 0.3.0

  • 作者
  • realaml

Realaml

Realaml SDK 支持 iOS 11 及以上版本

从 Cocoapods 安装 iOS 框架

pod 'Realaml'

所需权限

Privacy - Camera Usage Description

入门

UIKit (Swift)

开始KYC会话

import Realaml

class ViewController: UIViewController {

    @IBAction private func startKYC(_ sender: Any) {

        let controller: KYCViewController = KYCViewController(environment: .staging, 
                                                              signatureKey: YOUR_SIGNATURE_KEY)
        controller.delegate = self
        self.present(controller, animated: true)
    }
}

实现代理函数以监听回调

extension ViewController: KYCViewControllerDelegate {
    func kycViewController(_ controller: KYCViewController, didFinishWith error: Error?) {
        kycController.dismiss(animated: true)
    }

    func kycViewControllerDidCancelled(_ controller: KYCViewController) {
        kycController.dismiss(animated: true)
    }
}

SwiftUI

开始KYC会话

import Realaml

struct ContentView: View {

    @State private var isKycPresented = false

    @State private var kycResult: KYCView.Result?

    private let signKey = "YOUR_SIGNATURE_KEY"

    var body: some View {
        //...
        .fullScreenCover(isPresented: $isKycPresented) {
            KYCView(environment: .staging, signatureKey: signKey, result: $kycResult)
        }
    }
}

UIKit (Objective-C)

开始KYC会话并实现代理函数以监听回调

#import <Realaml/Realaml.h>

@interface ViewController ()<KYCViewControllerDelegate>

@end

@implementation ViewController

- (IBAction)startKYC:(id)sender {

    KYCViewController *controller = [[KYCViewController alloc] initWithEnvironment:RealamlEnvironmentStaging 
                                                                      signatureKey:YOUR_SIGNATURE_KEY];
    controller.delegate = self;
    [self presentViewController:controller animated:YES completion:nil];
}

-(void)kycViewController:(KYCViewController *)controller didFinishWith:(nullable NSError *)error {
    [controller dismissViewControllerAnimated:YES completion:nil];
}

-(void)kycViewControllerDidCancelled:(KYCViewController *)controller {
    [controller dismissViewControllerAnimated:YES completion:nil];
}

@end

环境

public enum RealamlEnvironment: Int {
    case staging
    case release
}

错误代码

public enum RealamlErrorCode: Int {
    case invalidSignatureKey
    case networkError
    case cameraPermissionDenied
}