Use wallet provisioning to enable your users to create multiple signing shares across their devices.
Once users successfully back up their wallets, they can generate a new set of signing shares irrespective of the SDK in use. Furthermore, both the new and old sets of signing shares can be used simultaneously, thanks to portal.provisionWallet. This provisioning relies on the user already having a successful set of backup shares.
While provisioning, the wallet fetches the encryption key from the user's cloud storage provider to decrypt the encrypted client backup share. Note that our SDK handles the decryption; you only need to supply the encrypted client backup share.
For wallet provisioning support, consult the recovery documentation to establish the necessary /backup/fetch webhook. Also, ensure the user has successfully completed the backup process.
Here's how to implement portal.provisionWallet:
// Imports...import kotlinx.coroutines.*classMainActivity : AppCompatActivity() {lateinitvar portal: Portallateinitvar provisionButton: Button// Your API instance.privateval exchangeApi: Api=Api()// The user from your API instance.lateinitvar user: UseroverridefunonCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main) provisionButton =findViewById(R.id.provisionButton) provisionButton.setOnClickListener { handleProvision() } }overridefunonActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {super.onActivityResult(requestCode, resultCode, data) portal.backup.drive.auth.onActivityResult!!(requestCode, resultCode, data) }privatefunhandleProvision() {CoroutineScope(Dispatchers.IO).launch {try {// Retrieve the existing encrypted client backup share from your API.val backupShare =async { exchangeApi.getCipherText(user.id) }// Set a new signing share by running provisionWallet. portal.provisionWallet(backupShare.await()) { status ->// Ensure UI interactions are done on the main threadwithContext(Dispatchers.Main) {// Do something with the status, such as update a progress bar// or log the progress Log.i("[PORTAL]", "Provision wallet status: ${status.status}, is done: ${status.done}") } } } catch (e: Exception) {// ❌ Handle any errors provisioning the wallet. Log.e("[PORTAL]", "Error provisioning wallet: ${e.message}") } } }}
And that's it! You're now equipped to support multiple sessions across different devices for your users.