Flutter教程

Secure Storage

Contents

This plugin gets, sets and removes key,value pairs from a device's secure storage.

Requires Cordova plugin: cordova-plugin-secure-storage. For more info, please see the Cordova Secure Storage docs.

The browser platform is supported as a mock only. Key/values are stored unencrypted in localStorage.

https://github.com/Crypho/cordova-plugin-secure-storage

联系我们?

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic's experts offer official maintenance, support, and integration help.

Contact Us Today!

Ionic 本地存储 Secure Storage插件的安装(Installation)

ionic cordova plugin add cordova-plugin-secure-storage npm install @ionic-native/secure-storage
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
ionic enterprise register --key=YOURPRODUCTKEY npm install @ionic-enterprise/secure-storage

Ionic 本地存储 Secure Storage插件支持的平台(Supported Platforms)

  • Android
  • Browser
  • iOS
  • Windows

Ionic 本地存储 Secure Storage插件的用法(Usage)

import { SecureStorage, SecureStorageObject } from '@ionic-native/secure-storage/ngx';

constructor(private secureStorage: SecureStorage) { }

...

this.secureStorage.create('my_store_name')
  .then((storage: SecureStorageObject) => {

     storage.get('key')
       .then(
         data => console.log(data),
         error => console.log(error)
     );

     storage.set('key', 'value')
       .then(
        data => console.log(data),
         error => console.log(error)
     );

     storage.remove('key')
     .then(
         data => console.log(data),
         error => console.log(error)
     );

  });