|
| 1 | +import { Cordova, Plugin } from './plugin'; |
| 2 | +import { Observable } from 'rxjs/Observable'; |
| 3 | + |
| 4 | +/** |
| 5 | + * @name AppPreferences |
| 6 | + * @description |
| 7 | + * This plugin allows you to read and write app preferences |
| 8 | + * |
| 9 | + * @usage |
| 10 | + * ``` |
| 11 | + * import { AppPreferences } from 'ionic-native'; |
| 12 | + * |
| 13 | + * AppPreferences.fetch('key').then((res) => { console.log(res); }); |
| 14 | + * |
| 15 | + * |
| 16 | + */ |
| 17 | +@Plugin({ |
| 18 | + pluginName: 'AppPreferences', |
| 19 | + plugin: 'cordova-plugin-app-preferences', // npm package name, example: cordova-plugin-camera |
| 20 | + pluginRef: 'plugins.appPreferences', // the variable reference to call the plugin, example: navigator.geolocation |
| 21 | + repo: 'https://github.com/apla/me.apla.cordova.app-preferences', // the github repository URL for the plugin |
| 22 | +}) |
| 23 | +export class AppPreferences { |
| 24 | + |
| 25 | + /** |
| 26 | + * Get a preference value |
| 27 | + * |
| 28 | + * @param {string} dict Dictionary for key (OPTIONAL) |
| 29 | + * @param {string} key Key |
| 30 | + * @return {Promise<any>} Returns a promise |
| 31 | + */ |
| 32 | + @Cordova({ |
| 33 | + sync: true, |
| 34 | + callbackOrder: 'reverse' |
| 35 | + }) |
| 36 | + static fetch(dict: string, key?: string): Promise<any> { return; } |
| 37 | + |
| 38 | + /** |
| 39 | + * Set a preference value |
| 40 | + * |
| 41 | + * @param {string} dict Dictionary for key (OPTIONAL) |
| 42 | + * @param {string} key Key |
| 43 | + * @param {string} value Value |
| 44 | + * @return {Promise<any>} Returns a promise |
| 45 | + */ |
| 46 | + @Cordova({ |
| 47 | + callbackOrder: 'reverse' |
| 48 | + }) |
| 49 | + static store(dict: string, key: string, value?: string): Promise<any> { |
| 50 | + return; |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Remove value from preferences |
| 55 | + * |
| 56 | + * @param {string} dict Dictionary for key (OPTIONAL) |
| 57 | + * @param {string} key Key |
| 58 | + * @return {Promise<any>} Returns a promise |
| 59 | + */ |
| 60 | + @Cordova({ |
| 61 | + callbackOrder: 'reverse' |
| 62 | + }) |
| 63 | + static remove(dict: string, key?: string): Promise<any> { return; } |
| 64 | + |
| 65 | + /** |
| 66 | + * Clear preferences |
| 67 | + * |
| 68 | + * @return {Promise<any>} Returns a promise |
| 69 | + */ |
| 70 | + @Cordova({ |
| 71 | + callbackOrder: 'reverse' |
| 72 | + }) |
| 73 | + static clearAll(): Promise<any> { return; } |
| 74 | + |
| 75 | + /** |
| 76 | + * Show native preferences interface |
| 77 | + * |
| 78 | + * @return {Promise<any>} Returns a promise |
| 79 | + */ |
| 80 | + @Cordova({ |
| 81 | + callbackOrder: 'reverse' |
| 82 | + }) |
| 83 | + static show(): Promise<any> { return; } |
| 84 | + |
| 85 | + /** |
| 86 | + * Show native preferences interface |
| 87 | + * |
| 88 | + * @param {boolean} subscribe true value to subscribe, false - unsubscribe |
| 89 | + * @return {Observable<any>} Returns an observable |
| 90 | + */ |
| 91 | + @Cordova({ |
| 92 | + observable: true |
| 93 | + }) |
| 94 | + static watch(subscribe: boolean): Observable<any> { return; } |
| 95 | + |
| 96 | + /** |
| 97 | + * Return named configuration context |
| 98 | + * In iOS you'll get a suite configuration, on Android — named file |
| 99 | + * Supports: Android, iOS |
| 100 | + * @param {string} suiteName suite name |
| 101 | + * @returns {Object} Custom object, bound to that suite |
| 102 | + */ |
| 103 | + @Cordova({ |
| 104 | + platforms: ['Android'] |
| 105 | + }) |
| 106 | + static suite(suiteName: string): Object { return; } |
| 107 | + |
| 108 | + @Cordova({ |
| 109 | + platforms: ['iOS'] |
| 110 | + }) |
| 111 | + static iosSuite(suiteName: string): Object { return; } |
| 112 | + |
| 113 | + /** |
| 114 | + * Return cloud synchronized configuration context |
| 115 | + * Currently supports Windows and iOS/macOS |
| 116 | + * @returns {Object} Custom object, bound to that suite |
| 117 | + */ |
| 118 | + @Cordova({ |
| 119 | + platforms: ['iOS', 'Windows', 'Windows Phone 8'] |
| 120 | + }) |
| 121 | + static cloudSync(): Object { return; } |
| 122 | + |
| 123 | + /** |
| 124 | + * Return default configuration context |
| 125 | + * Currently supports Windows and iOS/macOS |
| 126 | + * @returns {Object} Custom Object, bound to that suite |
| 127 | + */ |
| 128 | + @Cordova({ |
| 129 | + platforms: ['iOS', 'Windows', 'Windows Phone 8'] |
| 130 | + }) |
| 131 | + static defaults(): Object { return; } |
| 132 | + |
| 133 | +} |
0 commit comments