Use the ActiveLedger SDK interface to Use the SDK.
let activeledgerSDK = ActiveledgerSDK(http: "http", baseURL: "testnet-uk.activeledger.io", port: "5260")
activeledgerSDK?.generateKeys(type: encryptionSelected, name: "ASL")
let publicKey = activeledgerSDK?.getPublicKeyPEM()
let privateKey = activeledgerSDK?.getPrivateKeyPEM()
Onboarding a KeyPair will give an Single Observable in return. Use RxSwift to subscribe to it.
let response: Single<JSON> = activeledgerSDK?.onBoardKeys()
Server Sent Events can be subscribed by giving the URL. Function return RxSwift Observable that can be subscribed (Example given below). Events are connected automatically and is disconnected when disposing Observable. Dont forget to dispose Observable to avoid memory leaks. There are Three events : 1- Open 2- Message 3- Complete
Properties of event object might change with respect to differnt types which can be accessed by "type" property of the event. In case in which event is disconnect unexpecteldly, User can reconnect using
activeledgerSDK?.reConnectEvent()
Example:
activeledgerSDK?.subscribeToEvent(url: URL(string: "http://testnet-uk.activeledger.io:5261/api/activity/subscribe")!)
.subscribe(
onNext: { data in
print("---event---")
print(data.type)
},
onError: { error in
print(error)
},
onCompleted: {
print("Completed")
},
onDisposed: {
print("Disposed")
self.activeledgerSDK?.disconnectEvent()
}
).disposed(by: bag)
Execute method takes a transaction and will give an Single Observable in return with response in JSON format. Use RxSwiftto subscribe to it.
let request: Single<JSON> = executeTransaction(transaction: transaction)
request
.subscribe(onSuccess: { response in
print("---success response---")
print(response)
}, onError: { error in
print(error)
}).disposed(by: bag)
This project is licensed under the MIT License