Skip to main content

PnP Android SDK - v4 to v5

General

openlogin v5 is supported

With V5, Users can now log in from sapphire mainnet and sapphire testnet.

// With V5
web3Auth = Web3Auth(
Web3AuthOptions(
...
network = Network.SAPPHIRE_MAINNET, // pass over the network you want to use (MAINNET or TESTNET or CYAN, AQUA, SAPPHIRE_MAINNET or SAPPHIRE_TESTNET) // focus-end
...
)
)

Android Compile and Target SDK: 34.

In V5, android compile target sdk is changed from 33 to 34. If you previously used the target SDK with 33, update your build.gradle file.

// With V5
android {
compileSdk 34

defaultConfig {
applicationId "com.sbz.web3authdemoapp"
minSdk 24
targetSdk 34
versionCode 1
versionName "1.0"
...

}
}

Web3AuthOptions param configuration changed

In v5, the way parameters are configured has changed. The buildEnv parameter must be included. The whiteLabel parameter type and configuration has changed. And, as mentioned earlier, the network type has been added.

change of WhiteLabel parameter configuration

ParameterTypeMandatoryDescription
appNameStringNoName of your application
appUrlStringNoUrl of your application
logoLightStringNoLight logo for dark background
logoDarkStringNoDark logo for light background
defaultLanguageStringNoDefault translation language to be used
modeBooleanNo3 Theme modes of the application
themeMap<String, Any>NoWhitelabel theme
useLogoLoaderBooleanNoLoads the logo when loading

Here's the example configuration of Web3AuthOptions.

web3Auth = Web3Auth(
Web3AuthOptions(
context = this,
clientId = getString(R.string.web3auth_project_id), // pass over your Web3Auth Client ID from Developer Dashboard
network = Network.CYAN, // pass over the network you want to use (MAINNET or TESTNET or CYAN or AQUA or SAPPHIRE_MAINNET or SAPPHIRE_TESTNET)
buildEnv = BuildEnv.TESTING, // 3 options available: PRODUCTION, STAGING, TESTING
redirectUrl = Uri.parse("com.sbz.web3authdemoapp://auth"), // your app's redirect URL
// Optional parameters
whiteLabel = WhiteLabelData(
"Web3Auth Android Auth0 Example", null, null, null, Language.EN, ThemeModes.LIGHT, true,
hashMapOf(
"primary" to "#eb5424"
)
),
loginConfig = hashMapOf("jwt" to LoginConfigItem(
verifier = "web3auth-auth0-demo",
typeOfLogin = TypeOfLogin.JWT,
name = "Auth0 Login",
clientId = getString(R.string.web3auth_auth0_client_id)
))
)
)