Check out the Key Store Plugin in the product documentation.
The Key Store Plugin allows your application to securely store, get and remove secrets (key-value pairs) such as usernames, passwords, tokens, certificates or other sensitive information (strings) on iOS & Android devices.
After adding the plugin to your app, you should follow the good practice of verifying if the plugin is available during runtime in your app to prevent the app from crashing. Use the Logic > Client Actions > KeyStorePlugin > CheckKeyStorePlugin action to check for the plugin availability. If the plugin isn't available to the app, display an error to your users.
The Key Store Plugin allows you to do the following:
Set, get and remove your secrets;
Choose if you want authentication to access your secrets (available from version 2.3.0);
Migrate the key-value pairs stored in a previous version to a new version of the plugin (only for Android, available from version 2.3.0).
To create your key-value pair you can use the client action SetValue:
Add the SetValue client action after the Start node;
Handle the response from the client action. After the SetValue, add an If;
Set the Condition of the If to SetValue.Success;
In the False branch of the If, add a Message, set the message type to Error and set a Message to be shown to end users.
After setting your key-value pair, you can access them using the GetValue client action:
Add the GetValue action after the Start node;
Handle the response from the client action. After the GetValue, add an If;
Set the Condition of the If to GetValue.Success; Then, you can handle the response by assigning its value to a local variable.
In case you want to remove a key-value pair that you previously created, you can do it using the RemoveKey client action:
Add the RemoveKey action after the Start node;
Handle the response from the client action. After the RemoveKey, add an If;
Set the Condition of the If to RemoveKey.Success;
From version 2.3.0, you can set if you want additional authentication to access your key-value pairs by setting the value for KeyAuthentication in the SetValue client action. By default, no authentication is required to access the pair (False). If True, the access to the pair will require an additional user authentication method. This authentication method will depend on the user’s device lock screen settings.
As the KeyAuthentication variable is only available from the version 2.3.0, you can use the MigratedKeysAuthentication preference to migrate your secrets from an older version of the plugin (starting from 2.2.0). The value used on this preference will be applied to KeyAuthentication for all your key-value pairs. By default, no authentication is required to access the pair (False). If True, the access to the pair will require an additional user authentication method. This authentication method will depend on the user’s device lock screen settings.
Check the following known issues and possible workarounds.
For both iOS and Android.
This plugin allows your application to securely store secrets such as usernames, passwords, tokens, certificates or other sensitive information (strings) on iOS & Android devices.
The component basically lets you store, get, and remove strings, for each of these functionalities the component has an action that I will explain right ahead. But first, we’ll see how to check if the plugin works.
CheckKeyStorePlugin
SetValue
The SetValue action is the action that will let you store the secret information in your device, in order to do it you should choose the store name and pass it to the Store attribute, also you need to choose a secret key to lock the secret information this will be passed to the Key attribute, and of course you need to pass the secret information that you want to lock to the Value attribute.
As output, you will have the same Success and Error as before.
GetValue
If you have the need to get the stored data this is the function to use. You basically you need to have the store name and key that were used before to store the data and pass it to the Store and Key inputs of this action, it’s as simple as that. If the action is successful it will return you the stored data through the Value attribute otherwise you’ll receive the error.
RemoveValue
The RemoveValue action deletes the stored value and also deletes the key, to do it as well as the previous action you will need the store name and the key then it will return true if the process was successful or false otherwise pretty much the same as the action before.