2016-07-18 02:01:31 +08:00
|
|
|
import { Cordova, Plugin } from './plugin';
|
|
|
|
|
|
|
|
|
2016-07-17 14:32:19 +08:00
|
|
|
/**
|
2016-08-03 06:52:37 +08:00
|
|
|
* @name NativeStorage
|
|
|
|
* @description Native storage of variables in Android and iOS
|
2016-07-18 02:01:31 +08:00
|
|
|
*
|
2016-07-17 14:35:31 +08:00
|
|
|
* @usage
|
|
|
|
* ```typescript
|
2016-07-20 23:17:09 +08:00
|
|
|
* import { NativeStorage } from 'ionic-native';
|
2016-07-17 14:35:31 +08:00
|
|
|
*
|
|
|
|
* NativeStorage.setItem('myitem', {property: 'value', anotherProperty: 'anotherValue'})
|
|
|
|
* .then(
|
|
|
|
* () => console.log('Stored item!'),
|
|
|
|
* error => console.error('Error storing item', error)
|
|
|
|
* );
|
|
|
|
*
|
|
|
|
* NativeStorage.getItem('myitem')
|
|
|
|
* .then(
|
|
|
|
* data => console.log(data),
|
|
|
|
* error => console.error(error)
|
|
|
|
* );
|
|
|
|
* ```
|
2016-07-17 14:32:19 +08:00
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
plugin: 'cordova-plugin-nativestorage',
|
|
|
|
pluginRef: 'NativeStorage',
|
|
|
|
repo: 'https://github.com/TheCocoaProject/cordova-plugin-nativestorage'
|
|
|
|
})
|
|
|
|
export class NativeStorage {
|
|
|
|
/**
|
|
|
|
* Stores a value
|
2016-08-03 06:52:37 +08:00
|
|
|
* @param reference {string}
|
2016-07-17 14:32:19 +08:00
|
|
|
* @param value
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static setItem(reference: string, value: any): Promise<any> {return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a stored item
|
2016-08-03 06:52:37 +08:00
|
|
|
* @param reference {string}
|
2016-07-17 14:32:19 +08:00
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static getItem(reference: string): Promise<any> {return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a single stored item
|
2016-08-03 06:52:37 +08:00
|
|
|
* @param reference {string}
|
2016-07-17 14:32:19 +08:00
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static remove(reference: string): Promise<any> {return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all stored values.
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static clear(): Promise<any> {return; }
|
2016-07-18 02:01:31 +08:00
|
|
|
|
2016-07-17 14:32:19 +08:00
|
|
|
}
|