跳到主要内容

初始化

创建 unipass SDK 实例

通过传入自定义的配置信息 UniPassSDKOptions

unipassInstance = UniPassSDK(UniPassSDKOptions)

参数说明

UniPassSDKOptions

属性类型是否必须说明
contextandroid.content.Context应用上下文
activityAppCompatActivity调用 SDK 的活动
envcom.unipass.core.types.EnvironmentSDK 环境参数
redirectUrlUri重定向地址,用于重新唤起 app,需要根据您的 deep link 配置
walletUrlString钱包 Url,默认 domain https://testnet.wallet.unipass.id
appSettingscom.unipass.core.types.AppSettingsapp 自定义配置,用于页面展示 (logo, icon, 主题色等)

AppSettings

/// app 自定义配置(appSettings)
data class AppSettings(
val chain: ChainType = ChainType.polygon,
val appName: String? = null,
val appIcon: String? = null,
val theme: UniPassTheme = UniPassTheme.dark
)

// ChainType
enum class ChainType(val value: String) {
eth("eth"),
polygon("polygon"),
bsc("bsc"),
rangers("rangers"),
scroll("scroll")
}

// 主题(UniPassTheme)
enum class UniPassTheme(val value: String){
dark("dark"),
light("light")
}

代码示例

unipassInstance = UniPassSDK(
UniPassSDKOptions(
context = this,
activity = this,
redirectUrl = Uri.parse("unipassapp://com.unipass.wallet/redirect"),
env = Environment.TESTNET
)
)

如果您使用 v0.0.3 或以下版本,您还需要在 onNewIntent 中调用 setResultUrl API

配置 Result URL

override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
unipassInstance.setResultUrl(intent?.data)
}