Keychain
Get and set data in the iOS Keychain
Requires Cordova plugin: cordova-plugin-ios-keychain. For more info, please see the Keychain plugin docs.
See also Secure Storage for more supported platforms.
Repo: https://github.com/ionic-team/cordova-plugin-ios-keychain
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-ios-keychain $ npm install --save @ionic-native/keychain@4 - Add this plugin to your app's module
 
Supported platforms
- iOS
 
Usage
import { Keychain } from '@ionic-native/keychain';
constructor(private keychain: Keychain) { }
...
this.keychain.set(key, value).then(() => {
  this.keychain.get(key)
    .then(value => console.log('Got value', value))
    .catch(err => console.error('Error getting', err));
})
.catch(err => console.error('Error setting', err));
Instance Members
get(key, touchIDMessage)
Retrieves a value for a key
| Param | Type | Details | 
|---|---|---|
| key | 
      string
     | 
    
       the key to retrieve  | 
  
| touchIDMessage | 
      string
     | 
    
       the message to show underneath the TouchID prompt (if any)Optional  | 
  
set(key, value, useTouchID)
Sets a value for a key
| Param | Type | Details | 
|---|---|---|
| key | 
      string
     | 
    
       the key to set  | 
  
| value | 
      string|number|boolean
     | 
    
       the value to set  | 
  
| useTouchID | 
      boolean
     | 
    
       whether to store the value with security such that TouchID will be needed to grab itOptional  | 
  
getJson(key, touchIDMessage)
Gets a JSON value for a key
| Param | Type | Details | 
|---|---|---|
| key | 
      string
     | 
    
       the key to retrieve  | 
  
| touchIDMessage | 
      string
     | 
    
       the message to show underneath the TouchID prompt (if any)  | 
  
setJson(key, obj, useTouchId)
Sets a JSON value for a key
| Param | Type | Details | 
|---|---|---|
| key | 
      string
     | 
    
       the key to set  | 
  
| obj | 
      any
     | 
    
       value the value to set  | 
  
| useTouchId | 
      boolean
     | 
    
       Wether to store the value with security such that TouchID will be needed to grab itOptional  | 
  
remove(key)
Removes a value for a key
| Param | Type | Details | 
|---|---|---|
| key | 
      string
     | 
    
       the key to remove  |