Skip to main content
Version: 4.3

Installation

Don't have an Identity Vault subscription? Try it free now.

Follow these steps to install Identity Vault into your app.

Installation#

If you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.

Next, install the plugin:

npm install @ionic-enterprise/identity-vault
npx cap sync

Update the native project config files:

// iOS - Info.plist
<key>NSFaceIDUsageDescription</key>
<string>Use Face ID to authenticate yourself and login</string>
// Android - No additional changes needed

Configuring the Vault#

The IonicIdentityVaultUser class takes a generic session type which represents the type of the session you'll store in the vault. You can use the DefaultSession or extend the class to create a custom session. In the constructor of your Identity service, the vault is configured by providing options to the super() call:

interface MyCustomSession extends DefaultSession {
// username & token are inherited
email: string;
age: number;
nicknames: string[];
}
export class IdentityService extends IonicIdentityVaultUser<MyCustomSession> {
constructor(private http: HttpClient, private router: Router, platform: Platform) {
super(platform, {
authMode: AuthMode.BiometricAndPasscode, // Use biometrics auth with passcode fallback
restoreSessionOnReady: false, // whether or not to immediately attempt to restore the session when the vault is ready
unlockOnReady: false, // set true to auto prompt the user to unlock when vault is ready
unlockOnAccess: true, // set to true to auto prompt the user to unlock on first read access
lockAfter: 5000, // lock after 5 seconds in the background
hideScreenOnBackground: true // when in app launcher mode hide the current screen and display the splashscreen
});
onVaultUnlocked(config: VaultConfig) {
//Route to my home page
}
onVaultLocked() {
//Route to my login page
}
async onPasscodeRequest(isPasscodeSetRequest: boolean) {
// Display a custom Passcode prompt and return the passcode as a string
// or return undefined to use the build in native prompts. isPasscodeSetRequest
// is true when attempting to set a new passcode on the vault, you can use
// it to do something like prompt the user twice for the pin.
}
}