Skip to main content

Initializing PnP iOS SDK

After installation, the next step to use Web3Auth is to initialize the SDK. However, the initialization can be done in two ways,

Please note that these are the most critical steps where you need to pass on different parameters according to the preference of your project. Additionally, Whitelabeling and Custom Authentication have to be configured within this step, if you wish to customize your Web3Auth Instance.

Creating Web3Auth.plist

Setup Web3Auth.plist

In your application bundle add a plist file named Web3Auth.plist with the following information:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ClientId</key>
<string>YOUR_OPENLOGIN_CLIENT_ID</string>
<key>Network</key>
<string>mainnet | testnet</string>
</dict>
</plist>

When you have a Web3Auth.plist and you have specified your Web3Auth configuration there, you can simply construct your Web3Auth instance with

import Web3Auth

let web3auth = Web3Auth()

Using Web3Auth instance

If you don't want to create a plist file and want to use optional configuration parameters, you can construct the Web3Auth instance with

import Web3Auth

let web3auth = Web3Auth(W3AInitParams(
clientId: "<your clientId>",
network: .sapphire_mainnet,
))

After creating a Web3Auth instance using one of the above methods, you can use the instance to call various methods.

W3AInitParams object

The Web3Auth constructor takes an object called W3AInitParams as input. Below are the available fields of the W3AInitParams object.

ParameterDescription
clientIdYour Web3Auth Client ID. You can get it from Web3Auth Dashboard under project details. It's a mandatory field of type String
networkDefines the Web3Auth network. It's a mandatory field of type Network. Available options sapphire_mainne, sapphire_devnet, mainnet, cyan, aqua, and testnet.
redirectUrlURL that Web3Auth will redirect API responses upon successful authentication from browser. It's a mandatory field of type URL.
whiteLabel?WhiteLabel options for web3auth. It helps you define custom UI, branding, and translations for your brand app. It takes W3AWhiteLabelData as a value.
loginConfig?Login config for the custom verifiers. It takes Dictonary of [String: W3ALoginConfig] as a value.
useCoreKitKey?Use CoreKit Key to get core kit key. It's an optional field with default value as false.
chainNamespace?Chain Namespace [eip155 and solana]. It takes ChainNamespace as a value.
mfaSettings?Allows developers to configure the Mfa settings for authentication. It takes MfaSettings as a value.
sessionTime?It allows developers to configure the session management time. Session Time is in seconds, default is 86400 seconds which is 1 day. sessionTime can be max 7 days