XS2AiOS 2.0.0

XS2AiOS 2.0.0

Felix Fritz 维护。



 
依赖关系
SwiftyJSON= 5.0.1
NVActivityIndicatorView= 5.1.1
XS2AiOSNetService= 1.0.7
KeychainAccess= 4.2.2
 

XS2AiOS 2.0.0

  • Tink Germany GmbH

header

XS2AiOS - 本地 iOS SDK 用于 XS2A

License Platform Languages Swift Package Manager Cocoapods Carthage compatible

此 iOS SDK 可以将 XS2A 集成到本地 iOS 应用中。也提供 Android SDKReact Native SDK

演示屏幕捕获

可以在 这里 找到测试银行登录流程的演示屏幕捕获。

如何集成

要求

  • iOS >= 11.0

估计的二进制大小

使用 cocoapods-size 测量时,报告的额外大小增加约为 1.87 兆字节(针对版本 1.1.4)。

Swift Package Manager(推荐)

使用 Xcode 的 文件 -> Swift 包 -> 添加包依赖项(Xcode 12)或 文件 -> 添加...(Xcode 13)来添加此包。使用此存储库的 URL

https://github.com/FinTecSystems/xs2a-ios

Cocoapods

在 Podfile 中包含此库

pod "XS2AiOS"

然后运行 pod install。在某些情况下,您可能需要运行 pod install --repo-update

Carthage

如果您想通过 Carthage 将模块集成为 XCFramework,请将以下行添加到您的 Cartfile 中

github "FinTecSystems/xs2a-ios"
binary "https://raw.githubusercontent.com/FinTecSystems/xs2a-ios-netservice/master/Carthage.json" ~> 1.0.7
github "ninjaprox/NVActivityIndicatorView" ~> 5.1.1
github "SwiftyJSON/SwiftyJSON" ~> 5.0.1
github "kishikawakatsumi/KeychainAccess" ~> 4.2.2

然后运行 carthage update --use-xcframeworks 并将生成的 XCFrameworks 拖放到 Xcode 项目的框架部分。

使用方法

import XS2AiOS

配置并展示视图

SDK提供了一个可以在适当的时候展示给客户的XS2AViewController。在此操作之前,您需要先配置SDK。该XS2AViewController将引导客户完成这个过程。完成后,您将收到下面的回调。

let config = XS2AiOS.Configuration(
  wizardSessionKey: "YOUR_WIZARD_SESSION_KEY",
  // Use .de/.en/.fr/.es/.it to overwrite session language
  // Default is device language if part of supported languages,
  // otherwise fallback to .en
  language: .en, // (optional)
  // Boolean to control whether the exposes View from XS2AViewController
  // is an UIScrollView (default) or an UIView.
  withScrollView: true
)

// See the detailed Styling API below
let style = XS2AiOS.StyleProvider()

XS2AiOS.configure(
  withConfig: config,
  withStyle: style
)

// Reference to the VC in order to present and dismiss it
var xs2aViewController: XS2AViewController?

self.xs2aViewController = XS2AViewController { result in
  switch result {
  case .success(.finish):
    // e.g. present a success view
  case .success(.finishWithCredentials(let credentials)):
    // only called for XS2A.API with connection sync_mode set to "shared"
    // will return the shared credentials
    // e.g. present a success view
  case .failure(let error):
      switch error {
      case .userAborted:
        // the user pressed the abort button or
        // swiped down to abort in case of popover presentation
        // e.g. present an abort view
      case .networkError:
        // a network error occurred
        // e.g. present an error view
      }
  /**
   Session errors occur during a session.
   Implementation of the different cases below is optional.
   No action needs to be taken for them, in fact we recommend
   to let the user handle the completion of the session until one of the above .success or .failure cases is called.
   You can however use below cases for measuring purposes.
   NOTE: Should you decide to do navigation to different screens based on below cases, you should only do so
   in case of the recoverable parameter being false, otherwise the user can still finish the session.
   */
  case .sessionError(let sessionError):
    switch sessionError {
      case .loginFailed(recoverable: let recoverable):
        // Login to bank failed (e.g. invalid login credentials)
      case .sessionTimeout(recoverable: let recoverable):
        // The customer's session has timed out.
      case .tanFailed(recoverable: let recoverable):
        // User entered invalid TAN.
      case .techError(recoverable: let recoverable):
        // An unknown or unspecified error occurred.
      case .testmodeError(recoverable: let recoverable):
        // An error occurred using testmode settings.
      case .transNotPossible(recoverable: let recoverable):
        // A transaction is not possible for various reasons.
      case .validationFailed(recoverable: let recoverable):
        // Validation error (e.g. entered letters instead of numbers).
      case .other(errorCode: let errorCode, recoverable: let recoverable):
        // Other errors.
    }
  }
}

// present the configured view
self.present(self.xs2aViewController!, animated: true, completion: nil)

获取当前步骤 & 注册自定义返回按钮功能

某些场景需要知道当前会话的步骤,以及当按下返回按钮时可以注册回调。

您可以通过传递配置中的backButtonAction函数来接收返回按钮按下时的通知

func backButtonTapped() {
  /// get the current step of the session
  let currentStep = XS2AiOS.shared.currentStep
  
  if (currentStep == .login) {
    /// e.g. do something when the back button is pressed during the login step
  }
}

如果您想当会话步骤变化时接收通知,可以通过配置传递onStepChanged回调

func stepHasChanged(step: WizardStep?) {
  // session step has changed
}

let config = XS2AiOS.Configuration(
  wizardSessionKey: key,
  backButtonAction: backButtonTapped,
  onStepChanged: stepHasChanged
)

如果您需要知道会话是否在银行搜索屏幕或初始登录屏幕上,有两种方法可用

// Will return true/false depending on if the session is on the bank search screen
self.xs2aViewController.isBankSearch()

// Will return true/false depending on if the session is on *first* login screen,
// will return false if on any additional login screens
self.xs2aViewController.isLogin()

实现自定义返回按钮

对于某些使用案例,需要在表单中不显示默认的返回按钮,而是使用不同的自定义元素作为返回按钮,当然从功能上应该表现相同。这可以通过在配置中将enableBackButton设置为false来实现。

只有当您打算实现自己的后退按钮时,才禁用后退按钮!

let config = XS2AiOS.Configuration(
  // ...
  enableBackButton: false,
)

这将在XS2AViewController中不再显示后退按钮。然后您应该构建自己的按钮,该按钮可以调用XS2AViewController上的goBack()

self.xs2aViewController.goBack()

样式API

您可以根据需要对视图进行样式设计。请注意,淡色模式在模块内部被重写,但您当然可以简单地为淡色模式定义另一个样式提供者。

自定义加载动画

您可以通过构建自己的逻辑来覆盖默认加载动画,该逻辑实现了LoadingStateProvider协议。

showLoadingIndicatorhideLoadingIndicator方法在提供的视图控制器上显示全屏加载状态。loadingIndicatorView提供在AutosubmitLine表单组件中嵌入的视图。

然后您可以通过配置方法传递您的类

class MyCustomLoadingProvider: LoadingStateProvider {
  func showLoadingIndicator(title: String, message: String, over viewController: UIViewController) {
    // Logic that shows a loading animation over the passed `viewController`
  }

  func hideLoadingIndicator(over viewController: UIViewController) {
    // Logic that hides the loading animation
  }

  var loadingIndicatorView: LoadingView {
    // Returns UIView that displays the loading, for example:
    // NVActivityIndicatorView(frame: CGRect(x: 0, y: 0, width: 50, height: 50), type: .lineScale, color: .blue)
    return MyCustomLoadingView()
  }

  // UIView that implements the LoadingView protocol
  class MyCustomLoadingView: LoadingView {
    func startAnimating() { ... }   
    func stopAnimating() { ... }
  }
}

let myCustomLoadingAnimation = MyCustomLoadingProvider()

XS2AiOS.configure(
  withConfig: config,
  withStyle: style,
  withLoading: myCustomLoadingAnimation
)

颜色、按钮及其他样式

可用的属性包括

/// General Styles
var font: Font /// .custom("FontNameHere") or .systemDefault
var tintColor: UIColor
var logoVariation: LogoVariation /// (default as shown below, all white or all black)
var backgroundColor: UIColor
var textColor: UIColor

/// Textfield Styles
var inputBackgroundColor: UIColor
var inputBorderRadius: CGFloat
var inputBorderColor: UIColor
var inputBorderWidth: CGFloat
var inputBorderWidthActive: CGFloat
var inputTextColor: UIColor
var placeholderColor: UIColor

/// Button Styles
var buttonBorderRadius: CGFloat
var submitButtonStyle: ButtonStyle /// (textColor, backgroundColor, borderWidth and borderColor)
var backButtonStyle: ButtonStyle
var abortButtonStyle: ButtonStyle
var restartButtonStyle: ButtonStyle

/// Alert Styles
var alertBorderRadius: CGFloat
var errorStyle: AlertStyle /// (textColor & backgroundColor)
var warningStyle: AlertStyle
var infoStyle: AlertStyle

Styling API

加密出口合规信息

当您将应用程序上传到App Store Connect时,苹果通常会想要了解有关您的应用程序是否使用加密和是否符合美国出口管理局法规第五类第二章豁免条件的信息。此SDK确实符合此类豁免,即第(d)

特别设计用于银行用途或“资金交易”

请注意,此条款仅适用于本SDK及其相关XS2AiOSNetService,并不适用于您应用的其他部分,这些部分可能不符合此类豁免条件,您可能需要重新考虑如何回答该对话框。

许可

请注意,此移动SDK受MIT许可协议约束。MIT许可协议不适用于德国Tink公司的标志、使用条款和隐私政策。德国Tink公司标志的使用条款、使用条款和隐私政策包含在LICENSE文件中,称为Tink Germany LICENSE。