Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) added cordova-plugin-app-preferences support #1084

Merged
merged 7 commits into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AdMob } from './plugins/admob';
import { AndroidFingerprintAuth } from './plugins/android-fingerprint-auth';
import { AppAvailability } from './plugins/appavailability';
import { AppRate } from './plugins/apprate';
import { AppPreferences } from './plugins/apppreferences';
import { AppVersion } from './plugins/appversion';
import { Badge } from './plugins/badge';
import { BackgroundGeolocation } from './plugins/background-geolocation';
Expand Down Expand Up @@ -130,6 +131,7 @@ export * from './plugins/actionsheet';
export * from './plugins/admob';
export * from './plugins/android-fingerprint-auth';
export * from './plugins/appavailability';
export * from './plugins/apppreferences';
export * from './plugins/apprate';
export * from './plugins/appversion';
export * from './plugins/background-geolocation';
Expand Down Expand Up @@ -254,6 +256,7 @@ window['IonicNative'] = {
AdMob,
AndroidFingerprintAuth,
AppAvailability,
AppPreferences,
AppRate,
AppVersion,
Badge,
Expand Down
132 changes: 132 additions & 0 deletions src/plugins/apppreferences.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';

/**
* @name AppPreferences
* @description
* This plugin allows you to read and write app preferences
*
* @usage
* ```
* import { AppPreferences } from 'ionic-native';
*
* AppPreferences.fetch('key').then((res) => { console.log(res); });
*
*
*/
@Plugin({
pluginName: 'AppPreferences',
plugin: 'cordova-plugin-app-preferences', // npm package name, example: cordova-plugin-camera
pluginRef: 'plugins.appPreferences', // the variable reference to call the plugin, example: navigator.geolocation
repo: 'https://github.com/apla/me.apla.cordova.app-preferences', // the github repository URL for the plugin
})
export class AppPreferences {

/**
* Get a preference value
*
* @param {string} dict Dictionary for key (OPTIONAL)
* @param {string} key Key
* @return {Promise<any>} Returns a promise
*/
@Cordova({
callbackOrder: 'reverse'
})
static fetch(dict: string, key?: string): Promise<any> { return; }

/**
* Set a preference value
*
* @param {string} dict Dictionary for key (OPTIONAL)
* @param {string} key Key
* @param {string} value Value
* @return {Promise<any>} Returns a promise
*/
@Cordova({
callbackOrder: 'reverse'
})
static store(dict: string, key: string, value?: string): Promise<any> {
return;
}

/**
* Remove value from preferences
*
* @param {string} dict Dictionary for key (OPTIONAL)
* @param {string} key Key
* @return {Promise<any>} Returns a promise
*/
@Cordova({
callbackOrder: 'reverse'
})
static remove(dict: string, key?: string): Promise<any> { return; }

/**
* Clear preferences
*
* @return {Promise<any>} Returns a promise
*/
@Cordova({
callbackOrder: 'reverse'
})
static clearAll(): Promise<any> { return; }

/**
* Show native preferences interface
*
* @return {Promise<any>} Returns a promise
*/
@Cordova({
callbackOrder: 'reverse'
})
static show(): Promise<any> { return; }

/**
* Show native preferences interface
*
* @param {boolean} subscribe true value to subscribe, false - unsubscribe
* @return {Observable<any>} Returns an observable
*/
@Cordova({
observable: true
})
static watch(subscribe: boolean): Observable<any> { return; }

/**
* Return named configuration context
* In iOS you'll get a suite configuration, on Android — named file
* Supports: Android, iOS
* @param {string} suiteName suite name
* @returns {Object} Custom object, bound to that suite
*/
@Cordova({
platforms: ['Android']
})
static suite(suiteName: string): Object { return; }

@Cordova({
platforms: ['iOS']
})
static iosSuite(suiteName: string): Object { return; }

/**
* Return cloud synchronized configuration context
* Currently supports Windows and iOS/macOS
* @returns {Object} Custom object, bound to that suite
*/
@Cordova({
platforms: ['iOS', 'Windows', 'Windows Phone 8']
})
static cloudSync(): Object { return; }

/**
* Return default configuration context
* Currently supports Windows and iOS/macOS
* @returns {Object} Custom Object, bound to that suite
*/
@Cordova({
platforms: ['iOS', 'Windows', 'Windows Phone 8']
})
static defaults(): Object { return; }

}