Allow customers to create a password/pin. Customers can either remember the password or store it in a password storage manager.
Implementation Requirements
Create a UI for password input.
Enforce password requirements. Customer can choose between password, PIN code, passcode, or any other text-based input.
If user forgets password there are no additional recovery options.
package io.portal.android.app
// Imports...
class MainActivity : AppCompatActivity() {
lateinit var portal: Portal
lateinit var backupButton: Button
// Your API instance.
private val exchangeApi: Api = Api()
// The user from your API instance.
lateinit var user: User
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
backupButton = findViewById(R.id.backupButton)
backupButton.setOnClickListener { handleBackup() }
}
private fun handleBackup() {
CoroutineScope(Dispatchers.IO).launch {
try {
val backupConfigs = BackupConfigs(PasswordStorageConfig(password = PASSWORD))
// Get an encryped client backup share.
val backupShare = portal.backupWallet(
backupMethod = BackupMethods.Password,
backupConfigs = backupConfigs) { status ->
// Do something with the status, such as update a progress bar
// or log the progress
Log.println(Log.INFO, "[Portal]", "Backup status: ${status.status} is done: ${status.done}")
}
// Send the backup share to your API and store it.
exchangeApi.storeCipherText(user.id, backupShare)
// ✅ Notify Portal that the backup share was stored! 🙌
portal.api.storedClientBackupShare(true)
} catch (err: Throwable) {
// ❌ Notify Portal that the backup share was not stored.
portal.api.storedClientBackupShare(false)
}
}
}
}