mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-02-16 00:00:02 +08:00
Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b11da8da0b | ||
|
|
9987fb24da | ||
|
|
bcdec67c2e | ||
|
|
e391f5fa39 | ||
|
|
5105b0a184 | ||
|
|
87637792ba | ||
|
|
eed8cb1b1d | ||
|
|
25d1d0a0cd | ||
|
|
2f6688c9c4 | ||
|
|
21ffe99226 | ||
|
|
2a568d2398 | ||
|
|
3c49face4c | ||
|
|
46564c8ca3 | ||
|
|
ccafdbac13 | ||
|
|
d12a99c962 | ||
|
|
87751ca277 | ||
|
|
52a6114721 | ||
|
|
d561694750 | ||
|
|
f7ace39516 | ||
|
|
58b351ce13 | ||
|
|
5c7b7e350f | ||
|
|
9ddde5762d | ||
|
|
631d7f2d85 | ||
|
|
e9739882f4 | ||
|
|
293145257c | ||
|
|
2daca853dc | ||
|
|
0f4fdda8c6 | ||
|
|
38cab62d64 | ||
|
|
58e3f0bbb9 | ||
|
|
f055905190 | ||
|
|
62f71b2221 | ||
|
|
ddbd64d19a | ||
|
|
f0d5b88ec4 | ||
|
|
9d200e7020 | ||
|
|
ce2772b994 | ||
|
|
96c47df151 |
@@ -92,6 +92,10 @@ The `@Cordova` decorator has a few more options now.
|
||||
|
||||
`clearFunction` is used in conjunction with the `observable` option and indicates the function to be called when the Observable is disposed.
|
||||
|
||||
### Testing your changes
|
||||
|
||||
You need to run `npm run build_bundle` in the `ionic-native` project, this will create a `dist` directory. Then, you must go to your ionic application folder and replace your current `node_modules/ionic-native/dist/` with the newly generated one.
|
||||
|
||||
### 'Wrapping' Up
|
||||
|
||||
That's it! The only thing left to do is rigorously document the plugin and it's usage. Take a look at some of the other plugins for good documentation styles.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ionic-native",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
|
||||
"main": "dist/index.js",
|
||||
"directories": {
|
||||
@@ -10,7 +10,7 @@
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"rxjs": "5.0.0-beta.2"
|
||||
"rxjs": "^5.0.0-beta.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^13.0.0",
|
||||
@@ -33,7 +33,7 @@
|
||||
"semver": "^5.0.1",
|
||||
"tslint": "^3.8.1",
|
||||
"tslint-eslint-rules": "^1.3.0",
|
||||
"typescript": "^1.7.5"
|
||||
"typescript": "^1.8.10"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
|
||||
14
src/index.ts
14
src/index.ts
@@ -11,6 +11,7 @@ import {AppAvailability} from './plugins/appavailability';
|
||||
import {AppRate} from './plugins/apprate';
|
||||
import {AppVersion} from './plugins/appversion';
|
||||
import {Badge} from './plugins/badge';
|
||||
import {BackgroundGeolocation} from './plugins/background-geolocation';
|
||||
import {BarcodeScanner} from './plugins/barcodescanner';
|
||||
import {Base64ToGallery} from './plugins/base64togallery';
|
||||
import {BatteryStatus} from './plugins/batterystatus';
|
||||
@@ -31,6 +32,7 @@ import {Dialogs} from './plugins/dialogs';
|
||||
import {EmailComposer} from './plugins/emailcomposer';
|
||||
import {Facebook} from './plugins/facebook';
|
||||
import {File} from './plugins/file';
|
||||
import {Transfer} from './plugins/filetransfer';
|
||||
import {Flashlight} from './plugins/flashlight';
|
||||
import {Geolocation} from './plugins/geolocation';
|
||||
import {Globalization} from './plugins/globalization';
|
||||
@@ -39,6 +41,7 @@ import {GoogleAnalytics} from './plugins/googleanalytics';
|
||||
import {Hotspot} from './plugins/hotspot';
|
||||
import {ImagePicker} from './plugins/imagepicker';
|
||||
import {InAppBrowser} from './plugins/inappbrowser';
|
||||
import {Insomnia} from './plugins/insomnia';
|
||||
import {Keyboard} from './plugins/keyboard';
|
||||
import {LaunchNavigator} from './plugins/launchnavigator';
|
||||
import {LocalNotifications} from './plugins/localnotifications';
|
||||
@@ -64,6 +67,7 @@ export {
|
||||
AppRate,
|
||||
AppVersion,
|
||||
Badge,
|
||||
BackgroundGeolocation,
|
||||
BarcodeScanner,
|
||||
Base64ToGallery,
|
||||
BatteryStatus,
|
||||
@@ -93,6 +97,7 @@ export {
|
||||
Hotspot,
|
||||
ImagePicker,
|
||||
InAppBrowser,
|
||||
Insomnia,
|
||||
Keyboard,
|
||||
LaunchNavigator,
|
||||
LocalNotifications,
|
||||
@@ -104,10 +109,11 @@ export {
|
||||
SocialSharing,
|
||||
SpinnerDialog,
|
||||
Splashscreen,
|
||||
SQLite,
|
||||
SQLite,
|
||||
StatusBar,
|
||||
Toast,
|
||||
TouchID,
|
||||
Transfer,
|
||||
Vibration,
|
||||
WebIntent
|
||||
}
|
||||
@@ -122,6 +128,7 @@ window['IonicNative'] = {
|
||||
AppRate: AppRate,
|
||||
AppVersion: AppVersion,
|
||||
Badge: Badge,
|
||||
BackgroundGeolocation: BackgroundGeolocation,
|
||||
BarcodeScanner: BarcodeScanner,
|
||||
Base64ToGallery: Base64ToGallery,
|
||||
BatteryStatus: BatteryStatus,
|
||||
@@ -146,7 +153,7 @@ window['IonicNative'] = {
|
||||
Flashlight: Flashlight,
|
||||
Geolocation: Geolocation,
|
||||
Globalization: Globalization,
|
||||
GoogleMaps : GoogleMaps,
|
||||
GoogleMaps : GoogleMaps,
|
||||
GoogleAnalytics: GoogleAnalytics,
|
||||
Hotspot: Hotspot,
|
||||
ImagePicker: ImagePicker,
|
||||
@@ -162,10 +169,11 @@ window['IonicNative'] = {
|
||||
SocialSharing: SocialSharing,
|
||||
SpinnerDialog: SpinnerDialog,
|
||||
Splashscreen: Splashscreen,
|
||||
SQLite: SQLite,
|
||||
SQLite: SQLite,
|
||||
StatusBar: StatusBar,
|
||||
Toast: Toast,
|
||||
TouchID: TouchID,
|
||||
Transfer: Transfer,
|
||||
Vibration: Vibration,
|
||||
WebIntent: WebIntent
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
/**
|
||||
* @name AdMob
|
||||
@@ -174,4 +174,4 @@ export class AdMob {
|
||||
})
|
||||
static onInterstitialDismiss (): Observable<any> {return; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
336
src/plugins/background-geolocation.ts
Normal file
336
src/plugins/background-geolocation.ts
Normal file
@@ -0,0 +1,336 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
declare var window;
|
||||
|
||||
|
||||
export interface Location {
|
||||
|
||||
/**
|
||||
* ID of location as stored in DB (or null)
|
||||
*/
|
||||
locationId: number;
|
||||
|
||||
/**
|
||||
* Service provider
|
||||
*/
|
||||
serviceProvider: string;
|
||||
|
||||
/**
|
||||
* true if location recorded as part of debug
|
||||
*/
|
||||
debug: boolean
|
||||
|
||||
/**
|
||||
* UTC time of this fix, in milliseconds since January 1, 1970.
|
||||
*/
|
||||
time: number;
|
||||
|
||||
/**
|
||||
* latitude, in degrees.
|
||||
*/
|
||||
latitude: number;
|
||||
|
||||
/**
|
||||
* longitude, in degrees.
|
||||
*/
|
||||
longitude: number;
|
||||
|
||||
/**
|
||||
* estimated accuracy of this location, in meters.
|
||||
*/
|
||||
accuracy: number;
|
||||
|
||||
/**
|
||||
* speed if it is available, in meters/second over ground.
|
||||
*/
|
||||
speed: number;
|
||||
|
||||
/**
|
||||
* altitude if available, in meters above the WGS 84 reference ellipsoid.
|
||||
*/
|
||||
altitude: number;
|
||||
|
||||
/**
|
||||
* bearing, in degrees.
|
||||
*/
|
||||
bearing: number;
|
||||
|
||||
/**
|
||||
* A Coordinates object defining the current location
|
||||
*/
|
||||
coords: Coordinates;
|
||||
|
||||
/**
|
||||
* A timestamp representing the time at which the location was retrieved.
|
||||
*/
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
|
||||
/**
|
||||
* Desired accuracy in meters. Possible values [0, 10, 100, 1000]. The lower
|
||||
* the number, the more power devoted to GeoLocation resulting in higher
|
||||
* accuracy readings. 1000 results in lowest power drain and least accurate
|
||||
* readings. @see Apple docs (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instp/CLLocationManager/desiredAccuracy)
|
||||
*/
|
||||
desiredAccuracy: number;
|
||||
|
||||
/**
|
||||
* Stationary radius in meters. When stopped, the minimum distance the device
|
||||
* must move beyond the stationary location for aggressive background-tracking
|
||||
* to engage.
|
||||
*/
|
||||
stationaryRadius: number;
|
||||
|
||||
/**
|
||||
* When enabled, the plugin will emit sounds for life-cycle events of
|
||||
* background-geolocation! See debugging sounds table.
|
||||
*/
|
||||
debug: boolean;
|
||||
|
||||
/**
|
||||
* The minimum distance (measured in meters) a device must move horizontally
|
||||
* before an update event is generated. @see Apple docs. (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instp/CLLocationManager/distanceFilter)
|
||||
*/
|
||||
distanceFilter: number;
|
||||
|
||||
/**
|
||||
* IOS, ANDROID ONLY
|
||||
* Enable this in order to force a stop() when the application terminated
|
||||
* (e.g. on iOS, double-tap home button, swipe away the app).
|
||||
*/
|
||||
stopOnTerminate?: boolean;
|
||||
|
||||
/**
|
||||
* ANDROID, WP8 ONLY
|
||||
* The minimum time interval between location updates in seconds.
|
||||
* @see Android docs (http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(long,%20float,%20android.location.Criteria,%20android.app.PendingIntent))
|
||||
* and the MS doc (http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.geolocation.geolocator.reportinterval)
|
||||
* for more information
|
||||
*/
|
||||
locationTimeout?: number;
|
||||
|
||||
/**
|
||||
* ANDROID ONLY
|
||||
* Custom notification title in the drawer.
|
||||
*/
|
||||
notificationTitle?: string;
|
||||
|
||||
/**
|
||||
* ANDROID ONLY
|
||||
* Custom notification text in the drawer.
|
||||
*/
|
||||
notificationText?: string;
|
||||
|
||||
/**
|
||||
* ANDROID ONLY
|
||||
* The accent color to use for notification. Eg. #4CAF50.
|
||||
*/
|
||||
notificationIconColor?: string;
|
||||
|
||||
/**
|
||||
* ANDROID ONLY
|
||||
* The filename of a custom notification icon. See android quirks.
|
||||
* NOTE: Only available for API Level >=21.
|
||||
*/
|
||||
notificationIcon?: string;
|
||||
|
||||
/**
|
||||
* ANDROID ONLY
|
||||
* Set location service provider @see wiki (https://github.com/mauron85/cordova-plugin-background-geolocation/wiki/Android-providers)
|
||||
*/
|
||||
locationService?: number;
|
||||
|
||||
/**
|
||||
* IOS ONLY
|
||||
* [AutomotiveNavigation, OtherNavigation, Fitness, Other] Presumably,
|
||||
* this affects iOS GPS algorithm. @see Apple docs for more information
|
||||
* (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instp/CLLocationManager/activityType)
|
||||
*/
|
||||
activityType?: string;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @name BackgroundGeolocation
|
||||
* @description
|
||||
* This plugin provides foreground and background geolocation with battery-saving "circular region monitoring" and "stop detection". For
|
||||
* more detail, please see https://github.com/mauron85/cordova-plugin-background-geolocation
|
||||
*
|
||||
* @usage
|
||||
*
|
||||
* ```ts
|
||||
* import {BackgroundGeolocation} from 'ionic-native';
|
||||
*
|
||||
*
|
||||
*
|
||||
* // When device is ready :
|
||||
* platform.ready().then(() => {
|
||||
*
|
||||
* // BackgroundGeolocation is highly configurable. See platform specific configuration options
|
||||
* BackgroundGeolocation.configure(
|
||||
* (location) => {
|
||||
* console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude);
|
||||
*
|
||||
* // IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished,
|
||||
* // and the background-task may be completed. You must do this regardless if your HTTP request is successful or not.
|
||||
* // IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background.
|
||||
* BackgroundGeolocation.finish();
|
||||
* },
|
||||
* (error) => {
|
||||
* console.log('BackgroundGeolocation error');
|
||||
* },
|
||||
* {
|
||||
* desiredAccuracy: 10,
|
||||
* stationaryRadius: 20,
|
||||
* distanceFilter: 30,
|
||||
* debug: true, // enable this hear sounds for background-geolocation life-cycle.
|
||||
* stopOnTerminate: false, // enable this to clear background location settings when the app terminates
|
||||
* }
|
||||
* );
|
||||
*
|
||||
* // Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app.
|
||||
* BackgroundGeolocation.start();
|
||||
* }
|
||||
*
|
||||
* // If you wish to turn OFF background-tracking, call the #stop method.
|
||||
* BackgroundGeolocation.stop();
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
plugin: 'cordova-plugin-mauron85-background-geolocation',
|
||||
pluginRef: 'plugins.backgroundGeoLocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js
|
||||
repo: 'https://github.com/mauron85/cordova-plugin-background-geolocation'
|
||||
})
|
||||
export class BackgroundGeolocation {
|
||||
|
||||
/**
|
||||
* Configure the plugin.
|
||||
* Success callback will be called with one argument - Location object, which tries to mimic w3c Coordinates interface.
|
||||
* See http://dev.w3.org/geo/api/spec-source.html#coordinates_interface
|
||||
* Callback to be executed every time a geolocation is recorded in the background.
|
||||
*
|
||||
* Fail callback to be executed every time a geolocation error occurs.
|
||||
*
|
||||
* Options a json object of type Config
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse'
|
||||
})
|
||||
static configure(options: Config): Promise<Location> { return; }
|
||||
|
||||
|
||||
/**
|
||||
* Turn ON the background-geolocation system.
|
||||
* The user will be tracked whenever they suspend the app.
|
||||
*/
|
||||
@Cordova()
|
||||
static start(): Promise<any> { return; }
|
||||
|
||||
|
||||
/**
|
||||
* Turn OFF background-tracking
|
||||
*/
|
||||
@Cordova()
|
||||
static stop(): Promise<any> { return; }
|
||||
|
||||
|
||||
/**
|
||||
* Inform the native plugin that you're finished, the background-task may be completed
|
||||
* NOTE: IOS, WP only
|
||||
*/
|
||||
@Cordova()
|
||||
static finish() { }
|
||||
|
||||
|
||||
/**
|
||||
* Force the plugin to enter "moving" or "stationary" state
|
||||
* NOTE: IOS, WP only
|
||||
*/
|
||||
@Cordova()
|
||||
static changePace(isMoving: boolean) { }
|
||||
|
||||
|
||||
/**
|
||||
* Setup configuration
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse'
|
||||
})
|
||||
static setConfig(options: Config): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* Returns current stationaryLocation if available. null if not
|
||||
* NOTE: IOS, WP only
|
||||
*/
|
||||
@Cordova()
|
||||
static getStationaryLocation(): Promise<Location> { return; }
|
||||
|
||||
/**
|
||||
* Add a stationary-region listener. Whenever the devices enters "stationary-mode",
|
||||
* your #success callback will be executed with #location param containing #radius of region
|
||||
* NOTE: IOS, WP only
|
||||
*/
|
||||
@Cordova()
|
||||
static onStationary(): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* Check if location is enabled on the device
|
||||
* @returns {Promise<number>} Returns a promise with int argument that takes values 0, 1 (true).
|
||||
* NOTE: ANDROID only
|
||||
*/
|
||||
@Cordova()
|
||||
static isLocationEnabled(): Promise<number> { return; }
|
||||
|
||||
/**
|
||||
* Display device location settings
|
||||
*/
|
||||
@Cordova()
|
||||
static showLocationSettings() { }
|
||||
|
||||
/**
|
||||
* Method can be used to detect user changes in location services settings.
|
||||
* If user enable or disable location services then success callback will be executed.
|
||||
* In case or error (SettingNotFoundException) fail callback will be executed.
|
||||
* NOTE: ANDROID only
|
||||
*/
|
||||
@Cordova()
|
||||
static watchLocationMode(): Promise<boolean> { return; }
|
||||
|
||||
/**
|
||||
* Stop watching for location mode changes.
|
||||
* NOTE: ANDROID only
|
||||
*/
|
||||
@Cordova()
|
||||
static stopWatchingLocationMode() { }
|
||||
|
||||
/**
|
||||
* Method will return all stored locations.
|
||||
* Locations are stored when:
|
||||
* - config.stopOnTerminate is false and main activity was killed
|
||||
* by the system
|
||||
* or
|
||||
* - option.debug is true
|
||||
* NOTE: ANDROID only
|
||||
*/
|
||||
@Cordova()
|
||||
static getLocations(): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* Delete stored location by given locationId.
|
||||
* NOTE: ANDROID only
|
||||
*/
|
||||
@Cordova()
|
||||
static deleteLocation(locationId: number): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* Delete all stored locations.
|
||||
* NOTE: ANDROID only
|
||||
*/
|
||||
@Cordova()
|
||||
static deleteAllLocations(): Promise<any> { return; }
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
/**
|
||||
* @name Battery Status
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
/**
|
||||
* @name BLE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
/**
|
||||
* @name Bluetooth Serial
|
||||
@@ -16,29 +16,27 @@ export class BluetoothSerial {
|
||||
|
||||
/**
|
||||
* Connect to a Bluetooth device
|
||||
* Returns an Observable. Subscribe to connect, unsubscribe to disconnect.
|
||||
* @param macAddress_or_uuid Identifier of the remote device
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone']
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
observable: true,
|
||||
clearFunction: 'disconnect'
|
||||
})
|
||||
static connect (macAddress_or_uuid: string): Promise<any> {return; }
|
||||
static connect (macAddress_or_uuid: string): Observable<any> {return; }
|
||||
|
||||
/**
|
||||
* Connect insecurely to a Bluetooth device
|
||||
* Returns an Observable. Subscribe to connect, unsubscribe to disconnect.
|
||||
* @param macAddress Identifier of the remote device
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android']
|
||||
platforms: ['Android'],
|
||||
observable: true,
|
||||
clearFunction: 'disconnect'
|
||||
})
|
||||
static connectInsecure (macAddress: string): Promise<any> {return; }
|
||||
|
||||
/**
|
||||
* Disconnect
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone']
|
||||
})
|
||||
static disconnect (): Promise<any> {return; }
|
||||
static connectInsecure (macAddress: string): Observable<any> {return; }
|
||||
|
||||
/**
|
||||
* Writes data to the serial port
|
||||
@@ -223,4 +221,4 @@ export class BluetoothSerial {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,26 @@ export interface Calendar {
|
||||
platforms: ['Android', 'iOS']
|
||||
})
|
||||
export class Calendar {
|
||||
|
||||
/**
|
||||
* This function checks if we have permission to read/write from/to the calendar.
|
||||
* The promise will resolve with `true` when:
|
||||
* - You're running on iOS, or
|
||||
* - You're targetting API level lower than 23, or
|
||||
* - You're using Android < 6, or
|
||||
* - You've already granted permission
|
||||
*
|
||||
* If this returns false, you should call `requestReadWritePermissions` function
|
||||
*/
|
||||
@Cordova()
|
||||
static hasReadWritePermissions(): Promise<boolean> { return; }
|
||||
|
||||
/**
|
||||
* Requests read/write permissions
|
||||
*/
|
||||
@Cordova({sync: true})
|
||||
static requestReadWritePermissions(): void {}
|
||||
|
||||
/**
|
||||
* Create a calendar. (iOS only)
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
/**
|
||||
* @name DB Meter
|
||||
* @description This plugin defines a global DBMeter object, which permits to get the decibel values from the microphone.
|
||||
@@ -68,4 +68,4 @@ export class DBMeter {
|
||||
@Cordova()
|
||||
static delete(): Promise<any> {return; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
export interface AccelerationData {
|
||||
|
||||
@@ -101,4 +101,4 @@ export class DeviceMotion {
|
||||
static watchAcceleration(options?: AccelerometerOptions): Observable<AccelerationData> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
export interface CompassHeading {
|
||||
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
|
||||
import {Email} from './types/email.type';
|
||||
declare var cordova;
|
||||
|
||||
/**
|
||||
* Email object for Opening Email Composer
|
||||
*/
|
||||
export interface Email {
|
||||
app?: string;
|
||||
to: string | Array<string>;
|
||||
cc: string | Array<string>;
|
||||
bcc: string | Array<string>;
|
||||
attachments: Array<any>;
|
||||
subject: string;
|
||||
body: string;
|
||||
isHtml: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Email Composer
|
||||
* @description
|
||||
@@ -49,7 +35,7 @@ export interface Email {
|
||||
* };
|
||||
*
|
||||
* // Send a text message using default options
|
||||
* EmailComposer.send(email);
|
||||
* EmailComposer.open(email);
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@@ -64,13 +50,13 @@ export class EmailComposer {
|
||||
/**
|
||||
* Verifies if sending emails is supported on the device.
|
||||
*
|
||||
* @param app {string?} An optional app id or uri scheme. Defaults to mailto.
|
||||
* @param scope {any?} An optional scope for the promise
|
||||
* @returns {Promise<boolean>} Resolves promise with boolean whether EmailComposer is available
|
||||
* @param app {string?} An optional app id or uri scheme.
|
||||
* @returns {Promise<boolean>} Resolves if available, rejects if not available
|
||||
*/
|
||||
static isAvailable (app?: string, scope?: any): Promise<boolean> {
|
||||
static isAvailable (app?: string): Promise<any> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
cordova.plugins.email.isAvailable(app, resolve, scope);
|
||||
if (app) cordova.plugins.email.isAvailable(app, (isAvailable) => { if (isAvailable) resolve(); else reject(); });
|
||||
else cordova.plugins.email.isAvailable((isAvailable) => { if (isAvailable) resolve(); else reject(); });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,10 @@ export class File {
|
||||
rejectFn('directory cannot start with \/');
|
||||
}
|
||||
|
||||
if (!(/\/$/.test(dir))) {
|
||||
path += '/';
|
||||
}
|
||||
|
||||
try {
|
||||
var directory = path + dir;
|
||||
|
||||
@@ -351,6 +355,10 @@ export class File {
|
||||
rejectFn('file cannot start with \/');
|
||||
}
|
||||
|
||||
if (!(/\/$/.test(file))) {
|
||||
path += '/';
|
||||
}
|
||||
|
||||
try {
|
||||
var directory = path + file;
|
||||
|
||||
@@ -462,7 +470,57 @@ export class File {
|
||||
|
||||
// static writeExistingFile(path: string, fileName: string, text: string): Promise<any> { return }
|
||||
|
||||
// static readAsText(path: string, file: string): Promise<any> { return }
|
||||
/**
|
||||
* Read a file as string.
|
||||
*
|
||||
* @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
||||
* @param {string} fileName Name of file to move
|
||||
* @return Returns a Promise that resolves or rejects with an error.
|
||||
*/
|
||||
static readAsText(path: string, fileName: string): Promise<any> {
|
||||
let resolveFn, rejectFn;
|
||||
let promise = new Promise((resolve, reject) => {resolveFn = resolve; rejectFn = reject; });
|
||||
|
||||
if ((/^\//.test(fileName))) {
|
||||
rejectFn('file-name cannot start with \/');
|
||||
}
|
||||
|
||||
try {
|
||||
window.resolveLocalFileSystemURL(path, function (fileSystem) {
|
||||
fileSystem.getFile(fileName, {create: false}, function (fileEntry) {
|
||||
fileEntry.file(function (file) {
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onloadend = function(e) {
|
||||
if (this.result !== undefined && this.result !== null) {
|
||||
resolveFn(this.result);
|
||||
} else if (this.error !== undefined && this.error !== null) {
|
||||
rejectFn(this.error);
|
||||
} else {
|
||||
rejectFn({code: null, message: 'READER_ONLOADEND_ERR'});
|
||||
}
|
||||
};
|
||||
|
||||
reader.readAsText(file);
|
||||
}, function (error) {
|
||||
error.message = File.cordovaFileError[error.code];
|
||||
rejectFn(error);
|
||||
});
|
||||
}, function (err) {
|
||||
err.message = File.cordovaFileError[err.code];
|
||||
rejectFn(err);
|
||||
});
|
||||
}, function (er) {
|
||||
er.message = File.cordovaFileError[er.code];
|
||||
rejectFn(er);
|
||||
});
|
||||
} catch (e) {
|
||||
e.message = File.cordovaFileError[e.code];
|
||||
rejectFn(e);
|
||||
}
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
// static readAsDataURL(path: string, file: string): Promise<any> { return }
|
||||
|
||||
|
||||
194
src/plugins/filetransfer.ts
Normal file
194
src/plugins/filetransfer.ts
Normal file
@@ -0,0 +1,194 @@
|
||||
import {Plugin, CordovaInstance} from './plugin';
|
||||
|
||||
declare var FileTransfer;
|
||||
|
||||
export interface FileUploadOptions {
|
||||
|
||||
/**
|
||||
* The name of the form element.
|
||||
* Defaults to 'file'.
|
||||
*/
|
||||
fileKey?: string;
|
||||
|
||||
/**
|
||||
* The file name to use when saving the file on the server.
|
||||
* Defaults to 'image.jpg'.
|
||||
*/
|
||||
fileName?: string;
|
||||
|
||||
/**
|
||||
* The HTTP method to use - either PUT or POST.
|
||||
* Defaults to POST.
|
||||
*/
|
||||
httpMethod?: string;
|
||||
|
||||
/**
|
||||
* The mime type of the data to upload.
|
||||
* Defaults to image/jpeg.
|
||||
*/
|
||||
mimeType?: string;
|
||||
|
||||
/**
|
||||
* A set of optional key/value pairs to pass in the HTTP request.
|
||||
*/
|
||||
params?: { [s: string]: any; }
|
||||
|
||||
/**
|
||||
* Whether to upload the data in chunked streaming mode.
|
||||
* Defaults to true.
|
||||
*/
|
||||
chunkedMode?: boolean;
|
||||
|
||||
/**
|
||||
* A map of header name/header values. Use an array to specify more
|
||||
* than one value. On iOS, FireOS, and Android, if a header named
|
||||
* Content-Type is present, multipart form data will NOT be used.
|
||||
*/
|
||||
headers?: { [s: string]: any; }
|
||||
}
|
||||
|
||||
export interface FileUploadResult {
|
||||
|
||||
/**
|
||||
* The number of bytes sent to the server as part of the upload.
|
||||
*/
|
||||
bytesSent: number;
|
||||
|
||||
/**
|
||||
* The HTTP response code returned by the server.
|
||||
*/
|
||||
responseCode: number;
|
||||
|
||||
/**
|
||||
* The HTTP response returned by the server.
|
||||
*/
|
||||
response: string;
|
||||
|
||||
/**
|
||||
* The HTTP response headers by the server.
|
||||
*/
|
||||
headers: { [s: string]: any; }
|
||||
}
|
||||
|
||||
export interface FileTransferError {
|
||||
|
||||
/**
|
||||
* One of the predefined error codes listed below.
|
||||
*/
|
||||
code: number;
|
||||
|
||||
/**
|
||||
* URL to the source.
|
||||
*/
|
||||
source: string;
|
||||
|
||||
/**
|
||||
* URL to the target.
|
||||
*/
|
||||
target: string;
|
||||
|
||||
/**
|
||||
* HTTP status code. This attribute is only available when a response
|
||||
* code is received from the HTTP connection.
|
||||
*/
|
||||
http_status: number;
|
||||
|
||||
/**
|
||||
* Response body. This attribute is only available when a response is received from the HTTP connection.
|
||||
*/
|
||||
body: string;
|
||||
|
||||
/**
|
||||
* Either e.getMessage or e.toString.
|
||||
*/
|
||||
exception: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Transfer
|
||||
* @description This plugin allows you to upload and download files.
|
||||
* Example:
|
||||
* Create instance:
|
||||
* const fileTransfer = new Transfer();
|
||||
*
|
||||
* Upload a file:
|
||||
* fileTransfer.upload(..).then(..).catch(..);
|
||||
*
|
||||
* Download a file:
|
||||
* fileTransfer.download(..).then(..).catch(..);
|
||||
*
|
||||
* Abort active transfer:
|
||||
* fileTransfer.abort();
|
||||
*/
|
||||
@Plugin({
|
||||
plugin: 'cordova-plugin-file-transfer',
|
||||
pluginRef: 'FileTransfer',
|
||||
repo: 'https://github.com/apache/cordova-plugin-file-transfer'
|
||||
})
|
||||
export class Transfer {
|
||||
|
||||
public static FILE_NOT_FOUND_ERR: number = 1;
|
||||
public static INVALID_URL_ERR: number = 2;
|
||||
public static CONNECTION_ERR: number = 3;
|
||||
public static ABORT_ERR: number = 4;
|
||||
public static NOT_MODIFIED_ERR: number = 4;
|
||||
|
||||
private _objectInstance: any;
|
||||
|
||||
constructor() {
|
||||
this._objectInstance = new FileTransfer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a file to a server.
|
||||
*
|
||||
* @param {string} fileUrl Filesystem URL representing the file on the device or a data URI. For backwards compatibility, this can also be the full path of the file on the device.
|
||||
* @param {string} url URL of the server to receive the file, as encoded by encodeURI().
|
||||
* @param {FileUploadOptions} options Optional parameters.
|
||||
* @param {boolean} trustAllHosts: Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful since Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS.
|
||||
* @return Returns a Promise that resolves to a FileUploadResult and rejects with FileTransferError.
|
||||
*/
|
||||
@CordovaInstance({
|
||||
successIndex: 2,
|
||||
errorIndex: 3
|
||||
})
|
||||
upload(fileUrl: string, url: string, options?: FileUploadOptions, trustAllHosts?: boolean): Promise<FileUploadResult> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads a file from server.
|
||||
*
|
||||
* @param {string} source URL of the server to download the file, as encoded by encodeURI().
|
||||
* @param {stirng} target Filesystem url representing the file on the device. For backwards compatibility, this can also be the full path of the file on the device.
|
||||
* @param {boolean} trustAllHosts Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful because Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS.
|
||||
* @param {object} Optional parameters, currently only supports headers (such as Authorization (Basic Authentication), etc).
|
||||
* @return Returns a Promise that resolves to a FileEntry object.
|
||||
*/
|
||||
@CordovaInstance({
|
||||
successIndex: 2,
|
||||
errorIndex: 3
|
||||
})
|
||||
download(source: string, target: string, trustAllHosts?: boolean, options?: { [s: string]: any; }): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a listener that gets called whenever a new chunk of data is transferred.
|
||||
* @param {function} Listener that takes a progress event.
|
||||
*/
|
||||
|
||||
onProgress(listener: (event: ProgressEvent) => any): void {
|
||||
this._objectInstance.onprogress = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aborts an in-progress transfer. The onerror callback is passed a FileTransferError
|
||||
* object which has an error code of FileTransferError.ABORT_ERR.
|
||||
*/
|
||||
@CordovaInstance({
|
||||
sync: true
|
||||
})
|
||||
abort(): void {}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
declare var window;
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ export class Globalization {
|
||||
successIndex: 1,
|
||||
errorIndex: 2
|
||||
})
|
||||
static stringToNumber(stringToConvert: string, options: {type: string}): Promise<{value}> {return; }
|
||||
static stringToNumber(stringToConvert: string, options: {type: string}): Promise<{value:number|string}> {return; }
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Cordova, Plugin} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
import {CordovaInstance} from './plugin';
|
||||
/**
|
||||
* Created by Ibrahim on 3/29/2016.
|
||||
|
||||
47
src/plugins/insomnia.ts
Normal file
47
src/plugins/insomnia.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
|
||||
/**
|
||||
* @name Insomnia
|
||||
* @description
|
||||
* Prevent the screen of the mobile device from falling asleep.
|
||||
*
|
||||
* @usage
|
||||
* ```js
|
||||
* import {Insomnia} from 'ionic-native';
|
||||
*
|
||||
* Insomnia.keepAwake()
|
||||
* .then(
|
||||
* () => console.log('success'),
|
||||
* () => console.log('error')
|
||||
* );
|
||||
*
|
||||
* Insomnia.allowSleepAgain()
|
||||
* .then(
|
||||
* () => console.log('success'),
|
||||
* () => console.log('error')
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
@Plugin({
|
||||
plugin: 'https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin.git',
|
||||
pluginRef: 'plugins.insomnia',
|
||||
repo: 'https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin',
|
||||
platforms: ['Android', 'iOS', 'Windows Phone 8']
|
||||
})
|
||||
export class Insomnia {
|
||||
|
||||
/**
|
||||
* Keeps awake the application
|
||||
* @returns {Promise}
|
||||
*/
|
||||
@Cordova()
|
||||
static keepAwake(): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* Allows the application to sleep again
|
||||
* @returns {Promise}
|
||||
*/
|
||||
@Cordova()
|
||||
static allowSleepAgain(): Promise<any> { return; }
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Cordova, Plugin} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
/**
|
||||
* @name Keyboard
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Plugin, Cordova, CordovaProperty} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
declare var navigator: any;
|
||||
|
||||
@@ -25,7 +25,7 @@ declare var navigator: any;
|
||||
* let connectSubscription = Network.onConnect().subscribe(() => {
|
||||
* console.log('network connected!');
*
|
||||
* // We just got a connection but we need to wait briefly
|
||||
*
// before we determine the connection type. Might need to wait
|
||||
*
// before we determine the connection type. Might need to wait
|
||||
* // prior to doing any api requests as well.
|
||||
* setTimeout(() => {
|
||||
* console.log(Network.connection);
|
||||
|
||||
@@ -6,7 +6,7 @@ declare var window;
|
||||
declare var Promise;
|
||||
declare var $q;
|
||||
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -160,7 +160,7 @@ function callInstance(pluginObj: any, methodName: string, args: any[], opts: any
|
||||
return pluginObj._objectInstance[methodName].apply(pluginObj._objectInstance, args);
|
||||
}
|
||||
|
||||
function wrapInstance (pluginObj: any, methodName: string, args: any[], opts: any = {}) {
|
||||
function wrapInstance (pluginObj: any, methodName: string, opts: any = {}) {
|
||||
return (...args) => {
|
||||
if (opts.sync) {
|
||||
return callInstance(pluginObj, methodName, args, opts);
|
||||
@@ -335,4 +335,4 @@ export function InstanceProperty(target: Function, key: string, descriptor: Type
|
||||
};
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {Cordova, Plugin} from './plugin';
|
||||
declare var navigator: any;
|
||||
@Plugin({
|
||||
plugin: 'https://github.com/gitawego/cordova-screenshot.git',
|
||||
pluginRef: 'navigator.screenshot',
|
||||
@@ -8,29 +9,52 @@ export class Screenshot {
|
||||
|
||||
/**
|
||||
* Takes screenshot and saves the image
|
||||
*
|
||||
*
|
||||
* @param {string} format. Format can take the value of either 'jpg' or 'png'
|
||||
* On ios, only 'jpg' format is supported
|
||||
* @param {number} quality. Determines the quality of the screenshot.
|
||||
* @param {number} quality. Determines the quality of the screenshot.
|
||||
* Default quality is set to 100.
|
||||
* @param {string} filename. Name of the file as stored on the storage
|
||||
* @param {string} filename. Name of the file as stored on the storage
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 0
|
||||
})
|
||||
static save (format?: string, quality?: number, filename?: string): Promise<any> {return; }
|
||||
static save (format?: string, quality?: number, filename?: string): Promise<any> {
|
||||
return new Promise<any>(
|
||||
(resolve, reject) => {
|
||||
navigator.screenshot.save(
|
||||
(error, result) => {
|
||||
if(error){
|
||||
reject(error);
|
||||
}else{
|
||||
resolve(result);
|
||||
}
|
||||
},
|
||||
format,
|
||||
quality,
|
||||
filename
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes screenshot and returns the image as an URI
|
||||
*
|
||||
* @param {number} quality. Determines the quality of the screenshot.
|
||||
*
|
||||
* @param {number} quality. Determines the quality of the screenshot.
|
||||
* Default quality is set to 100.
|
||||
*/
|
||||
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 0
|
||||
})
|
||||
static URI (quality?: number): Promise<any> {return; }
|
||||
}
|
||||
static URI (quality?: number): Promise<any> {
|
||||
return new Promise<any>(
|
||||
(resolve, reject) => {
|
||||
navigator.screenshot.URI(
|
||||
(error, result) => {
|
||||
if(error){
|
||||
reject(error);
|
||||
}else{
|
||||
resolve(result);
|
||||
}
|
||||
},
|
||||
quality
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {Observable} from 'rxjs/Rx';
|
||||
|
||||
export interface ToastOptions {
|
||||
/**
|
||||
|
||||
13
src/plugins/types/email.type.ts
Normal file
13
src/plugins/types/email.type.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Email object for Opening Email Composer
|
||||
*/
|
||||
export interface Email {
|
||||
app?: string;
|
||||
to?: string | Array<string>;
|
||||
cc?: string | Array<string>;
|
||||
bcc?: string | Array<string>;
|
||||
attachments?: Array<any>;
|
||||
subject?: string;
|
||||
body?: string;
|
||||
isHtml?: boolean;
|
||||
}
|
||||
@@ -35,4 +35,4 @@ export class WebIntent {
|
||||
@Cordova()
|
||||
static sendBroadcast(options: {action: string, extras?: {option: boolean}}): Promise<any> {return; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user