SBP

0.1.1

SBP swift package, СБП
c-villain/SBP

What's New

0.1.1

2023-01-17T08:24:54Z

SBP

Latest release

contact: @lexkraev Telegram Group

Swift package for service SBP (СБП), more details about SBP you can find here.

Quick Start

with UIKit

you may define smth like this:

import SwiftUI
import SBP

@available(iOS 13.0, *)
final class SBPay {
    
  func chooseBank(on viewController: UIViewController,
                    presentationStyle: UIModalPresentationStyle = .fullScreen,
                    completion: @escaping (String) -> (),
                    onClose: @escaping () -> ()) {
        
        let vc = UIHostingController(rootView: BanksView() {
            print($0)
            completion($0)
            viewController.presentedViewController?.dismiss(animated: true)
        } onCloseTap: {
            onClose()
            viewController.presentedViewController?.dismiss(animated: true)
        })
        vc.modalPresentationStyle = presentationStyle
        viewController.present(vc, animated: true)
    }
}


class ViewController: UIViewController {
  
  override func viewDidLoad() {
    super.viewDidLoad()
  }
  
  override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    
    SBPay().chooseBank(on: self) {
      print($0)
    }
  }
}

also you need add LSApplicationQueriesSchemes key into you project info.plst

 <key>LSApplicationQueriesSchemes</key>
  <array>
    <string>bank100000000000</string>
    <string>bank100000000001</string>
    ...
    <string>bank100000000999</string>
    <string>bank100000001000</string>
  </array>

Warning! Starting with iOS 15 there's limit in maximum 50 entries in list, so you probably need to take first 50 entries from c2bmembers.json. Look for details here.

That's need for UIApplication.shared.canOpenURL method worked correctly. You can copy and paste all lines from example

Different cases

Based on the infomartion above service is trying to find installed apps and then module opens screen with the list of bank apps:

Otherwise the service offers to choose the bank connected to SBP from the list:

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Oct 18 2024 03:45:07 GMT-0900 (Hawaii-Aleutian Daylight Time)