https://github.com/c-villain/sbp
SBP swift package, СБП
https://github.com/c-villain/sbp
cocoapods ios13 sbp swift-package swiftui
Last synced: 2 months ago
JSON representation
SBP swift package, СБП
- Host: GitHub
- URL: https://github.com/c-villain/sbp
- Owner: c-villain
- License: mit
- Created: 2022-12-02T09:52:50.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-07T13:22:54.000Z (about 1 year ago)
- Last Synced: 2025-04-03T03:48:16.854Z (2 months ago)
- Topics: cocoapods, ios13, sbp, swift-package, swiftui
- Language: Swift
- Homepage: https://t.me/swiftui_dev
- Size: 2.43 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SDK для работы с СБП НСПК
[](https://github.com/c-villain/SBP/releases/latest)
[](https://swiftpackageindex.com/c-villain/SBP)
[](https://swiftpackageindex.com/c-villain/SBP)
[](https://swift.org/package-manager/)
[](https://t.me/lexkraev)
[](https://telegram.dog/swiftui_dev)Swift package for service SBP (СБП), more details about SBP you can find [here](https://sbp.nspk.ru).
## Quick Start
### with UIKit
you may define smth like this:
```swift
import SwiftUI
import SBP@available(iOS 13.0, *)
final class SBPay {
func chooseBank(on viewController: UIViewController,
presentationStyle: UIModalPresentationStyle = .fullScreen,
completion: @escaping (String) -> (),
onClose: @escaping () -> ()) {
registerFonts()
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)
}
}
}
```
### with SwiftUIJust use `BanksView()`
### project settings
also you need add LSApplicationQueriesSchemes key into you project info.plst
```plst
LSApplicationQueriesSchemes
bank100000000000
bank100000000001
...
bank100000000999
bank100000001000
```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](https://qr.nspk.ru/proxyapp/c2bmembers.json). Look for details [here](https://developer.apple.com/documentation/uikit/uiapplication/1622952-canopenurl#discussion).
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:
![]()