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:
importPortalSwiftstructCipherTextResult:Codable {var cipherText: String}classViewController:UIViewController {publicvar portal: Portal?publicvar yourApiUrl: String="https://YOUR_API_URL.com"publicvar clientId: String="YOUR_CLIENT_ID"@IBActionfunchandleRecover(_sender: UIButton!) {// Get the existing encrypted client backup share from your API.let request = HttpRequest<CipherTextResult, [String:String]>( url:"\(yourApiUrl)clients/\(clientId)/backup", method:"GET", body: [:], headers: ["Content-Type":"application/json"])// Send the request. request.send() { (result: Result<Any>) iniflet error = result.error {// โ Handle errors retrieving the backup share.print("Error fetching backup share: \(error.localizedDescription)")return }guardlet response = result.data as?Dictionary<String, String>,let backupShare = response["backupShare"]else {// Handle unexpected data format or backupShare missing.print("Unexpected data format or backupShare missing.")return }// Provide the encrypted client backup share and the backup method to provisionWallet. self.portal?.provisionWallet( cipherText: backupShare, method: BackupMethods.iCloud.rawValue) { (result: Result<String>) ->Voidiniflet error = result.error {// โ Handle provisionWallet errors.print("Error provisioning the wallet: \(error.localizedDescription)")return }// Success, maybe update the UI or navigate elsewhere. } progress: { status inprint("Provision Wallet Status: ", status) } } }}
And that's it! You're now equipped to support multiple sessions across different devices for your users.