Core Client
环境要求
- Android min SDK 23
- Java 11
安装
root/build.gradle.kts:
allprojects {
repositories {
mavenCentral()
}
}
app/build.gradle
implementation("com.walletconnect:android-core:release_version")
Project set up
To use initialize RelayClient properly you will need a projectId. Go to https://cloud.walletconnect.com/app, register your project and get projectId.
CoreClient initialization
Before using any of the WalletConnect Kotlin SDKs, it is necessary to initialize the CoreClient. The initialization of CoreClient must always happen in the Android Application class. Provide the projectId generated in the WalletConnec Cloud, the WebSocket url, choose the connection type, and pass the application class. You can also pass your own Relay instance using the RelayConnectionInterface
.
val projectId = "" //Get Project ID at https://cloud.walletconnect.com/
val relayUrl = "relay.walletconnect.com"
val serverUrl = "wss://$relayUrl?projectId=${projectId}"
val connectionType = ConnectionType.AUTOMATIC or ConnectionType.MANUAL
val application = //Android Application level class
[Optional] val optionalRelay: RelayConnectionInterface? = /*implement interface*/
CoreClient.initialize(relayServerUrl = serverUrl, connectionType = connectionType, application = application, relay = optionalRelay)
Using your own Relay instance
The CoreClient offers the ability to use a custom Relay client. Just creating an instance of RelayConnectionInterface
and passing it to CoreClient.initalize
.
...
val optionalRelay: RelayConnectionInterface = /*implement interface*/
CoreClient.initialize(relayServerUrl = serverUrl, connectionType = connectionType, application = application, relay = optionalRelay)