To start connections, you need to create and keep alive a Client
object to which you provide DappInfo
and a delegate:
let client = Client(delegate: self, dAppInfo: dAppInfo)
The delegate then will receive calls when connection established, failed, or disconnected.
Upon successful connection, you can invoke various API methods on the Client
.
try? client.personal_sign(url: session.url, message: "Hi there!", account: session.walletInfo!.accounts[0]) {
[weak self] response in
// handle the response from Wallet here
}
You can also send a custom request. The request ID required by JSON RPC is generated and handled by the library internally.
try? client.send(Request(url: url, method: "eth_gasPrice")) { [weak self] response in
// handle the response
}
You can convert the received response result to a Decodable
type.
let nonceString = try response.result(as: String.self)
You can also check if the wallet responded with error:
if let error = response.error { // NSError
// handle error
}
For more details, see the ExampleApps/ClientApp
Please open ExampleApps/ExampleApps.xcodeproj
- iOS 13.0 or macOS 10.14
- Swift 5
- CryptoSwift - for cryptography operations
In your Package.swift
:
dependencies: [
.package(url: "https://github.com/BitizenWallet/BitizenConnectSwift.git", .upToNextMinor(from: "1.2.0"))
]
In your Podfile
:
platform :ios, '13.0'
use_frameworks!
target 'MyApp' do
pod 'BitizenConnectSwift', :git => 'https://github.com/BitizenWallet/BitizenConnectSwift.git', :branch => 'master'
end
In your Cartfile
:
github "BitizenConnect/BitizenConnectSwift"
Run carthage update
to build the framework and drag the BitizenConnectSwift.framework in your Xcode project.
MIT License (see the LICENSE file).