Merge & fix confilcts

This commit is contained in:
Guille 2016-07-17 19:44:19 +02:00
commit 712f201bf2
32 changed files with 1598 additions and 199 deletions

View File

@ -1,3 +1,76 @@
<a name="1.3.6"></a>
## [1.3.6](https://github.com/driftyco/ionic-native/compare/v1.3.5...v1.3.6) (2016-07-17)
### Bug Fixes
* **googlemaps:** able to pass array of LatLng to GoogleMapsLatLngBounds constructor ([de14b0e](https://github.com/driftyco/ionic-native/commit/de14b0e)), closes [#298](https://github.com/driftyco/ionic-native/issues/298)
* **launch-navigator:** fix the navigate function wrapper to match latest plugin API ([6f625f9](https://github.com/driftyco/ionic-native/commit/6f625f9))
### Features
* **camera-preview:** add wrapper for camera-preview ([#301](https://github.com/driftyco/ionic-native/issues/301)) ([3a1a3ce](https://github.com/driftyco/ionic-native/commit/3a1a3ce))
* **launch-navigator:** add new methods and constants to match latest plugin API ([29de6b3](https://github.com/driftyco/ionic-native/commit/29de6b3))
<a name="1.3.5"></a>
## [1.3.5](https://github.com/driftyco/ionic-native/compare/v1.3.4...v1.3.5) (2016-07-17)
### Bug Fixes
* **ibeacon:** minor fixes ([b5a2ffc](https://github.com/driftyco/ionic-native/commit/b5a2ffc))
* **safari-view-controller:** fix wrappers ([b4b3ec0](https://github.com/driftyco/ionic-native/commit/b4b3ec0))
### Features
* **googlemaps:** add Geocoder class ([#292](https://github.com/driftyco/ionic-native/issues/292)) ([2996da6](https://github.com/driftyco/ionic-native/commit/2996da6)), closes [#280](https://github.com/driftyco/ionic-native/issues/280)
* **media-capture:** add media capture plugin ([#293](https://github.com/driftyco/ionic-native/issues/293)) ([daa6d4c](https://github.com/driftyco/ionic-native/commit/daa6d4c)), closes [#272](https://github.com/driftyco/ionic-native/issues/272)
* **nativestorage:** add NativeStorage plugin wrapper ([af5d4ad](https://github.com/driftyco/ionic-native/commit/af5d4ad))
* **pin-dialog:** add pin dialog plugin ([#291](https://github.com/driftyco/ionic-native/issues/291)) ([2fe37c4](https://github.com/driftyco/ionic-native/commit/2fe37c4))
<a name="1.3.4"></a>
## [1.3.4](https://github.com/driftyco/ionic-native/compare/v1.3.3...v1.3.4) (2016-07-14)
### Bug Fixes
* **touchid:** make isAvailable static ([c23f5e9](https://github.com/driftyco/ionic-native/commit/c23f5e9))
### Reverts
* **changelog:** old changelog ([0cb79d1](https://github.com/driftyco/ionic-native/commit/0cb79d1))
<a name="1.3.3"></a>
## [1.3.3](https://github.com/driftyco/ionic-native/compare/v1.3.2...v1.3.3) (2016-07-11)
### Bug Fixes
* remove unnecessary decorator ([#257](https://github.com/driftyco/ionic-native/issues/257)) ([25fab64](https://github.com/driftyco/ionic-native/commit/25fab64))
* **actionsheet:** add missing optional parameter for hide function ([#262](https://github.com/driftyco/ionic-native/issues/262)) ([644e999](https://github.com/driftyco/ionic-native/commit/644e999))
* **background-geolocation:** fix pluginref again ([b8a5133](https://github.com/driftyco/ionic-native/commit/b8a5133))
* **geolocation:** fix plugin reference ([4f0cd24](https://github.com/driftyco/ionic-native/commit/4f0cd24)), closes [#258](https://github.com/driftyco/ionic-native/issues/258)
* **googlemaps:** use correct methods for addGroundOverlay and addKmlOverlay ([#268](https://github.com/driftyco/ionic-native/issues/268)) ([b8be1de](https://github.com/driftyco/ionic-native/commit/b8be1de))
* **socialsharing:** all methods return Promises now ([e150224](https://github.com/driftyco/ionic-native/commit/e150224)), closes [#275](https://github.com/driftyco/ionic-native/issues/275)
### Features
* **ibeacon:** add iBeacon plugin support ([#270](https://github.com/driftyco/ionic-native/issues/270)) ([dd97df1](https://github.com/driftyco/ionic-native/commit/dd97df1))
* **onesignal:** added wrapper for the Cordova OneSignal Plugin ([#252](https://github.com/driftyco/ionic-native/issues/252)) ([ba20dbe](https://github.com/driftyco/ionic-native/commit/ba20dbe))
* **push:** added support for Action Buttons on iOS with categories ([#273](https://github.com/driftyco/ionic-native/issues/273)) ([592feb4](https://github.com/driftyco/ionic-native/commit/592feb4))
<a name="1.3.2"></a>
## [1.3.2](https://github.com/driftyco/ionic-native/compare/v1.3.1...v1.3.2) (2016-06-27)

View File

@ -2,11 +2,11 @@
## Feature request?
Have a plugin you'd like to see supported? Because Ionic Native is a thin wrapper around existing Cordova plugins, adding support for new plugins is as easy as creating a new wrapper for whichever plugin you'd like to add.
Have a plugin you'd like to see supported? Since Ionic Native is a thin wrapper around existing Cordova plugins, adding support for new plugins is as easy as creating a new wrapper for whatever plugin you'd like to add.
Take a look at our [Developer Guide](https://github.com/driftyco/ionic-native/blob/master/DEVELOPER.md) for more info on adding new plugins.
## Having an issue?
## Have an issue?
#### There are no rules, but here are a few things to consider:
###### Before you submit an issue:
* Do a quick search to see if there are similar issues

View File

@ -1,6 +1,6 @@
{
"name": "ionic-native",
"version": "1.3.2",
"version": "1.3.6",
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
"main": "dist/index.js",
"files": [

View File

@ -20,6 +20,7 @@ import {BLE} from './plugins/ble';
import {BluetoothSerial} from './plugins/bluetoothserial';
import {Calendar} from './plugins/calendar';
import {Camera} from './plugins/camera';
import {CameraPreview} from './plugins/camera-preview';
import {CardIO} from './plugins/card-io';
import {Clipboard} from './plugins/clipboard';
import {Contacts} from './plugins/contacts';
@ -44,19 +45,24 @@ import {GoogleMap} from './plugins/googlemaps';
import {GoogleAnalytics} from './plugins/googleanalytics';
import {Hotspot} from './plugins/hotspot';
import {Httpd} from './plugins/httpd';
import {IBeacon} from './plugins/ibeacon';
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';
import {MediaCapture} from './plugins/media-capture';
import {NativeStorage} from './plugins/nativestorage';
import {MediaPlugin} from './plugins/media';
import {Network, Connection} from './plugins/network';
import {Network} from './plugins/network';
import {OneSignal} from './plugins/onesignal';
import {PinDialog} from './plugins/pin-dialog';
import {Printer} from './plugins/printer';
import {Push} from './plugins/push';
import {SafariViewController} from './plugins/safari-view-controller';
import {Screenshot} from './plugins/screenshot';
import {Sim} from './plugins/sim';
import {SMS} from './plugins/sms';
import {SocialSharing} from './plugins/socialsharing';
import {SpinnerDialog} from './plugins/spinnerdialog';
@ -80,13 +86,16 @@ export * from './plugins/datepicker';
export * from './plugins/device';
export * from './plugins/devicemotion';
export * from './plugins/deviceorientation';
export * from './plugins/filetransfer';
export * from './plugins/googlemaps';
export * from './plugins/httpd';
export * from './plugins/ibeacon';
export * from './plugins/imagepicker';
export * from './plugins/inappbrowser';
export * from './plugins/launchnavigator';
export * from './plugins/localnotifications';
export * from './plugins/media';
export * from './plugins/media-capture';
export * from './plugins/printer';
export * from './plugins/push';
export * from './plugins/safari-view-controller';
@ -106,8 +115,8 @@ export {
Brightness,
BLE,
BluetoothSerial,
CameraPreview,
Clipboard,
Connection,
DBMeter,
Deeplinks,
DeviceAccounts,
@ -124,10 +133,13 @@ export {
Hotspot,
Insomnia,
Keyboard,
NativeStorage,
Network,
OneSignal,
PinDialog,
Screenshot,
SocialSharing,
Sim,
Splashscreen,
SQLite,
StatusBar,
@ -148,6 +160,7 @@ window['IonicNative'] = {
AppVersion: AppVersion,
Badge: Badge,
BackgroundGeolocation: BackgroundGeolocation,
BackgroundMode: BackgroundMode,
BarcodeScanner: BarcodeScanner,
Base64ToGallery: Base64ToGallery,
BatteryStatus: BatteryStatus,
@ -156,9 +169,9 @@ window['IonicNative'] = {
BluetoothSerial: BluetoothSerial,
Calendar: Calendar,
Camera: Camera,
CameraPreview: CameraPreview,
CardIO: CardIO,
Clipboard: Clipboard,
Connection: Connection,
Contacts: Contacts,
DatePicker: DatePicker,
DBMeter: DBMeter,
@ -180,18 +193,23 @@ window['IonicNative'] = {
GoogleAnalytics: GoogleAnalytics,
Hotspot: Hotspot,
Httpd: Httpd,
IBeacon: IBeacon,
ImagePicker: ImagePicker,
InAppBrowser: InAppBrowser,
Keyboard: Keyboard,
LaunchNavigator: LaunchNavigator,
LocalNotifications: LocalNotifications,
MediaCapture: MediaCapture,
MediaPlugin: MediaPlugin,
NativeStorage: NativeStorage,
Network: Network,
Printer: Printer,
Push: Push,
OneSignal: OneSignal,
PinDialog: PinDialog,
SafariViewController: SafariViewController,
Screenshot: Screenshot,
Sim: Sim,
SMS: SMS,
SocialSharing: SocialSharing,
SpinnerDialog: SpinnerDialog,

View File

@ -203,7 +203,7 @@ export interface Config {
*/
@Plugin({
plugin: 'cordova-plugin-mauron85-background-geolocation',
pluginRef: 'plugins.backgroundGeoLocation',
pluginRef: 'backgroundGeolocation',
repo: 'https://github.com/mauron85/cordova-plugin-background-geolocation',
platforms: ['iOS', 'Android', 'Windows Phone 8']
})

View File

@ -26,7 +26,7 @@ import { Cordova, Plugin } from './plugin';
*
*/
@Plugin({
plugin: 'de.appplant.cordova.plugin.background-mode',
plugin: 'cordova-plugin-background-mode',
pluginRef: 'cordova.plugins.backgroundMode',
repo: 'https://github.com/katzer/cordova-plugin-background-mode',
platforms: ['Android', 'iOS', 'Windows Phone 8']

View File

@ -0,0 +1,129 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
export interface CameraPreviewOptions {
x: number;
y: number;
width: number;
height: number;
/**
* Choose the camera to use (front- or back-facing).
* 'front' for front camera
* 'rear' for rear camera
*/
camera: string;
/** Take photo on tap */
tapPhoto: boolean;
/** */
previewDrag: boolean;
/** */
toBack: boolean;
/** Alpha use when toBack is set to true */
alpha: number;
}
export interface CameraPreviewSize {
maxWidth: number;
maxHeight: number;
}
/**
* @name CameraPreview
* @description
* Showing camera preview in HTML
*
* Requires {@link module:driftyco/ionic-native} and the Cordova plugin: `cordova-plugin-camera-preview`. For more info, please see the [Cordova Camera Preview Plugin Docs](https://github.com/westonganger/cordova-plugin-camera-preview).
*
*/
@Plugin({
plugin: 'cordova-plugin-camera-preview',
pluginRef: 'cordova.plugins.camerapreview',
repo: 'https://github.com/westonganger/cordova-plugin-camera-preview',
platforms: ['Android', 'iOS']
})
export class CameraPreview {
/**
* Starts the camera preview instance.
* @param {CameraPreviewOptions} options for the preview
*/
@Cordova({
sync: true
})
static startCamera(options: CameraPreviewOptions): void {};
/**
* Stops the camera preview instance.
*/
@Cordova({
sync: true
})
static stopCamera(): void {};
/**
* Take the picture, the parameter size is optional
*/
@Cordova({
sync: true
})
static takePicture(size: CameraPreviewSize): void {};
/**
* Register a callback function that receives the original picture and the image captured from the preview box.
*/
@Cordova({
observable: true
})
static setOnPictureTakenHandler(): Observable<any> { return; };
/**
* Switch from the rear camera and front camera, if available.
*/
@Cordova({
sync: true
})
static switchCamera(): void {};
/**
* Show the camera preview box.
*/
@Cordova({
sync: true
})
static show(): void {};
/**
* Hide the camera preview box.
*/
@Cordova({
sync: true
})
static hide(): void {};
/**
* Set the default mode for the Flash.
*/
@Cordova({
sync: true
})
static setFlashMode(mode: number): void {};
/**
* Set camera color effect.
*/
@Cordova({
sync: true
})
static setColorEffect(effect: string): void {};
/**
* @private
* @enum {number}
*/
static FlashMode = {
OFF: 0,
ON: 1,
AUTO: 2
};
}

View File

@ -113,8 +113,8 @@ export interface CameraPopoverOptions {
export class Camera {
/**
* Take a picture or video, or load one from the library.
* @param {CameraOptions} options
* @return Returns a Promise that resolves with Base64 encoding of the image data, or the image file URI, depending on cameraOptions, otherwise rejects with an error.
* @param {CameraOptions} options Options that you want to pass to the camera. Encoding type, quality, etc.
* @return {Promise} Returns a Promise that resolves with Base64 encoding of the image data, or the image file URI, depending on cameraOptions, otherwise rejects with an error.
*/
@Cordova({
callbackOrder: 'reverse'
@ -132,6 +132,7 @@ export class Camera {
static cleanup() { };
/**
* @private
* @enum {number}
*/
static DestinationType = {
@ -144,6 +145,7 @@ export class Camera {
};
/**
* @private
* @enum {number}
*/
static EncodingType = {
@ -153,6 +155,7 @@ export class Camera {
PNG: 1
};
/**
* @private
* @enum {number}
*/
static MediaType = {
@ -165,6 +168,7 @@ export class Camera {
};
/**
* @private
* @enum {number}
*/
static PictureSourceType = {
@ -177,6 +181,7 @@ export class Camera {
};
/**
* @private
* Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover.
* @enum {number}
*/
@ -189,6 +194,7 @@ export class Camera {
};
/**
* @private
* @enum {number}
*/
static Direction = {

View File

@ -41,7 +41,7 @@ export class CardIO {
/**
* Scan a credit card with card.io.
* @param options
* @param {CardIOOptions} options Options for configuring the plugin
*/
@Cordova()
static scan(options?: CardIOOptions): Promise<any> { return; }

View File

@ -19,12 +19,12 @@ import { Cordova, Plugin } from './plugin';
*
* Clipboard.paste().then(
* (resolve : string) => {
* alert(resolve);
* },
* alert(resolve);
* },
* (reject : string) => {
* alert("Error: " + reject);
* }
* );
* );
* );
* ```
*/
@ -38,15 +38,15 @@ export class Clipboard {
/**
* Copies the given text
* @param text
* @returns {Promise<T>}
* @param {string} text Text that gets copied on the system clipboard
* @returns {Promise<T>} Returns a promise after the text has been copied
*/
@Cordova()
static copy(text: string): Promise<any> { return; }
/**
* Pastes the text stored in clipboard
* @returns {Promise<T>}
* @returns {Promise<T>} Returns a promise after the text has been pasted
*/
@Cordova()
static paste(): Promise<any> { return; }

View File

@ -283,9 +283,6 @@ export class Contacts {
/**
* Search for contacts in the Contacts list.
*
* Example: Contacts.find(['*'], { filter: 'Max' }) // will search for a displayName of 'Max'
*
* @param fields {string[]} Contact fields to be used as a search qualifier.
* A zero-length contactFields parameter is invalid and results in ContactError.INVALID_ARGUMENT_ERROR.
* A contactFields value of "*" searches all contact fields.

View File

@ -77,7 +77,6 @@ export interface DatePickerOptions {
* import {DatePicker} from 'ionic-native';
*
*
*
* DatePicker.show({
* date: new Date(),
* mode: 'date'
@ -97,9 +96,10 @@ export class DatePicker {
/**
* Shows the date and/or time picker dialog(s)
* @param options
* @param {DatePickerOptions} options Options for the date picker.
* @returns {Promise<Date>} Returns a promise that resolves with the picked date and/or time, or rejects with an error.
*/
@Cordova()
static show(options: DatePickerOptions): Promise<Date> { return; }
}

View File

@ -84,8 +84,8 @@ export class DeviceOrientation {
* Get the device current heading at a regular interval
*
* Stop the watch by unsubscribing from the observable
* @param options
* @returns {Observable<CompassHeading>}
* @param {CompassOptions} options Options for compass. Frequency and Filter. Optional
* @returns {Observable<CompassHeading>} Returns an observable that contains the compass heading
*/
@Cordova({
callbackOrder: 'reverse',

View File

@ -40,9 +40,9 @@ export class Dialogs {
/**
* Shows a custom alert or dialog box.
* @param message Dialog message. (String)
* @param title Dialog title. (String) (Optional, defaults to Alert)
* @param buttonName Button name. (String) (Optional, defaults to OK)
* @param {string} message Dialog message.
* @param {string} title Dialog title. (Optional, defaults to Alert)
* @param {string} buttonName Button name. (Optional, defaults to OK)
* @returns {Promise<any>} Returns a blank promise once the user has dismissed the alert.
*/
@Cordova({
@ -57,9 +57,9 @@ export class Dialogs {
/**
* Displays a customizable confirmation dialog box.
* @param message Dialog message. (String)
* @param title Dialog title. (String) (Optional, defaults to Confirm)
* @param buttonLabels Array of strings specifying button labels. (Array) (Optional, defaults to [OK,Cancel])
* @param {string} message Dialog message.
* @param {string} title Dialog title. (Optional, defaults to Confirm)
* @param {Array<string>} buttonLabels Array of strings specifying button labels. (Optional, defaults to [OK,Cancel])
* @returns {Promise<number>} Returns a promise that resolves the button index that was clicked. Note that the index use one-based indexing.
*/
@Cordova({
@ -74,10 +74,10 @@ export class Dialogs {
/**
* Displays a native dialog box that is more customizable than the browser's prompt function.
* @param message Dialog message. (String)
* @param title Dialog title (String) (Optional, defaults to Prompt)
* @param buttonLabels Array of strings specifying button labels (Array) (Optional, defaults to ["OK","Cancel"])
* @param defaultText Default textbox input value (String) (Optional, Default: empty string)
* @param {string} message Dialog message.
* @param {string} title Dialog title. (Optional, defaults to Prompt)
* @param {Array<string>} buttonLabels Array of strings specifying button labels. (Optional, defaults to ["OK","Cancel"])
* @param {string} defaultText Default textbox input value. (Optional, Default: empty string)
* @returns {Promise<any>} Returns a promise that resolves an object with the button index clicked and the text entered
*/
@Cordova({
@ -94,7 +94,7 @@ export class Dialogs {
/**
* The device plays a beep sound.
* @param times The number of times to repeat the beep. (Number)
* @param {numbers} times The number of times to repeat the beep.
*/
@Cordova({
sync: true

View File

@ -87,8 +87,8 @@ export class Facebook {
/**
* Browser wrapper
* @param appId
* @param version
* @param {number} appId Your Facebook AppID from their dashboard
* @param {string} version The version of API you may want to use. Optional
*/
@Cordova()
static browserInit(appId: number, version?: string): Promise<any> {

View File

@ -155,8 +155,7 @@ export class Geolocation {
static watchPosition(options?: GeolocationOptions): Observable<Geoposition> {
return new Observable<Geoposition>(
(observer: any) => {
let cb = (data: Geoposition) => observer.next(data);
let watchId = navigator.geolocation.watchPosition(cb, options);
let watchId = navigator.geolocation.watchPosition(observer.next.bind(observer), options);
return () => navigator.geolocation.clearWatch(watchId);
}
);

View File

@ -12,9 +12,9 @@ import { Cordova, Plugin } from './plugin';
* ```
*/
@Plugin({
plugin: 'cordova-plugin-globalization',
pluginRef: 'navigator.globalization',
repo: 'https://github.com/apache/cordova-plugin-globalization'
plugin: 'cordova-plugin-globalization',
pluginRef: 'navigator.globalization',
repo: 'https://github.com/apache/cordova-plugin-globalization'
})
export class Globalization {
@ -23,104 +23,112 @@ export class Globalization {
* @return {Promise<{value: string}>}
*/
@Cordova()
static getPreferredLanguage(): Promise<{value: string}> { return; }
static getPreferredLanguage(): Promise<{ value: string }> { return; }
/**
* Returns the BCP 47 compliant locale identifier string to the successCallback with a properties object as a parameter.
* @return {Promise<{value: string}>}
*/
@Cordova()
static getLocaleName(): Promise<{value: string}> { return; }
static getLocaleName(): Promise<{ value: string }> { return; }
/**
* Converts date to string
* @param date
* @param options
* @return {Promise<{value: string}>}
* @param {Date} date Date you wish to convert
* @param options Options for the converted date. Length, selector.
* @return {Promise<{value: string}>} Returns a promise when the date has been converted.
*/
@Cordova({
successIndex: 1,
errorIndex 2
})
static dateToString(date: Date, options: {formatLength: string, selector: string}): Promise<{value: string}> { return; }
static dateToString(date: Date, options: { formatLength: string, selector: string }): Promise<{ value: string }> { return; }
/**
*
* @param dateString
* Parses a date formatted as a string, according to the client's user preferences and calendar using the time zone of the client, and returns the corresponding date object.
* @param {string} dateString Date as a string to be converted
* @param options Options for the converted date. Length, selector.
* @return {Promise<{value: string}>} Returns a promise when the date has been converted.
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
static stringToDate(dateString: string, options: { formatLength: string, selector: string }): Promise<{ year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number }> { return; }
/**
* Returns a pattern string to format and parse dates according to the client's user preferences.
* @param options Object with the format length and selector
* @return {Promise<{value: string}>} Returns a promise.
*/
@Cordova({
callbackOrder: 'reverse'
})
static getDatePattern(options: { formatLength: string, selector: string }): Promise<{ pattern: string }> { return; }
/**
* Returns an array of the names of the months or days of the week, depending on the client's user preferences and calendar.
* @param options Object with type (narrow or wide) and item (month or days).
* @return {Promise<{value: string}>} Returns a promise.
*/
@Cordova({
callbackOrder: 'reverse'
})
static getDateNames(options: { type: string, item: string }): Promise<{ value: Array<string> }> { return; }
/**
* Indicates whether daylight savings time is in effect for a given date using the client's time zone and calendar.
* @param {data} date Date to process
* @returns {Promise<dst>} reutrns a promise with the value
*/
@Cordova()
static isDayLightSavingsTime(date: Date): Promise<{ dst: string }> { return; }
/**
* Returns the first day of the week according to the client's user preferences and calendar.
* @returns {Promise<value>} reutrns a promise with the value
*/
@Cordova()
static getFirstDayOfWeek(): Promise<{ value: string }> { return; }
/**
* Returns a number formatted as a string according to the client's user preferences.
* @param options
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
static stringToDate(dateString: string, options: {formatLength: string, selector: string}): Promise<{year: number, month: number, day: number, hour: number, minute: number, second: number, millisecond: number}> { return; }
static numberToString(options: { type: string }): Promise<{ value: string }> { return; }
/**
*
* @param options
*/
@Cordova({
callbackOrder: 'reverse'
})
static getDatePattern(options: {formatLength: string, selector: string}): Promise<{pattern: string}> { return; }
/**
*
* @param options
*/
@Cordova({
callbackOrder: 'reverse'
})
static getDateNames(options: {type: string, item: string}): Promise<{value: Array<string>}> { return; }
/**
* Check if day light saving is active
* @param date
*/
@Cordova()
static isDayLightSavingsTime(date: Date): Promise<{dst: string}> { return; }
/**
* Get first day of week
*/
@Cordova()
static getFirstDayOfWeek(): Promise<{value: string}> { return; }
/**
*
* @param options
* @param {string} stringToConvert String you want to conver to a number
* @param options The type of number you want to return. Can be decimal, percent, or currency.
* @returns {Promise} Returns a promise with the value.
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
static numberToString(options: {type: string}): Promise<{value: string}> { return; }
static stringToNumber(stringToConvert: string, options: { type: string }): Promise<{ value: number | string }> { return; }
/**
*
* @param stringToConvert
* @param options
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
static stringToNumber(stringToConvert: string, options: {type: string}): Promise<{value: number|string}> { return; }
/**
*
* @param options
* Returns a pattern string to format and parse numbers according to the client's user preferences.
* @param options Can be decimal, percent, or currency.
* @returns {Promise} returns a promise with the value.
*/
@Cordova({
callbackOrder: 'reverse'
})
static getNumberPattern(options: {type: string}): Promise<{pattern: string, symbol: string, fraction: number, rounding: number, positive: string, negative: string, decimal: string, grouping: string}> { return; }
static getNumberPattern(options: { type: string }): Promise<{ pattern: string, symbol: string, fraction: number, rounding: number, positive: string, negative: string, decimal: string, grouping: string }> { return; }
/**
*
* @param currencyCode
* Returns a pattern string to format and parse currency values according to the client's user preferences and ISO 4217 currency code.
* @param {string} currencyCode Currency Code.A
* @returns {Promise} returns a promise with the value
*/
@Cordova()
static getCurrencyPattern(currencyCode: string): Promise<{pattern: string, code: string, fraction: number, rounding: number, decimal: number, grouping: string}> { return; }
static getCurrencyPattern(currencyCode: string): Promise<{ pattern: string, code: string, fraction: number, rounding: number, decimal: number, grouping: string }> { return; }
}

View File

@ -80,8 +80,7 @@ export class GoogleMap {
on(event: any): Observable<any> {
return new Observable(
(observer) => {
let cb = data => observer.next(data);
this._objectInstance.on(event, cb);
this._objectInstance.on(event, observer.next.bind(observer));
return () => this._objectInstance.off(event);
}
);
@ -392,11 +391,8 @@ export class GoogleMapsMarker {
addEventListener(event: any): Observable<any> {
return new Observable(
(observer) => {
let cb = (data: any) => {
observer.next(data);
};
this._objectInstance.addEventListener(event, cb);
return () => this._objectInstance.removeEventListener(event, cb);
this._objectInstance.addEventListener(event, observer.next.bind(observer));
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
}
);
}
@ -540,9 +536,8 @@ export class GoogleMapsCircle {
addEventListener(event: any): Observable<any> {
return new Observable(
(observer) => {
let cb = data => observer.next(data);
this._objectInstance.addEventListener(event, cb);
return () => this._objectInstance.removeEventListener(event, cb);
this._objectInstance.addEventListener(event, observer.next.bind(observer));
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
}
);
}
@ -632,9 +627,8 @@ export class GoogleMapsPolyline {
addEventListener(event: any): Observable<any> {
return new Observable(
(observer) => {
let cb = data => observer.next(data);
this._objectInstance.addEventListener(event, cb);
return () => this._objectInstance.removeEventListener(event, cb);
this._objectInstance.addEventListener(event, observer.next.bind(observer));
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
}
);
}
@ -724,9 +718,8 @@ export class GoogleMapsPolygon {
addEventListener(event: any): Observable<any> {
return new Observable(
(observer) => {
let cb = data => observer.next(data);
this._objectInstance.addEventListener(event, cb);
return () => this._objectInstance.removeEventListener(event, cb);
this._objectInstance.addEventListener(event, observer.next.bind(observer));
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
}
);
}
@ -954,8 +947,9 @@ export class GoogleMapsKmlOverlay {
export class GoogleMapsLatLngBounds {
private _objectInstance: any;
constructor(public southwest: GoogleMapsLatLng, public northeast: GoogleMapsLatLng) {
this._objectInstance = new plugin.google.maps.LatLngBounds([southwest, northeast]);
constructor(public southwestOrArrayOfLatLng: GoogleMapsLatLng | GoogleMapsLatLng[], public northeast?: GoogleMapsLatLng) {
let args = !!northeast ? [southwestOrArrayOfLatLng, northeast] : southwestOrArrayOfLatLng;
this._objectInstance = new plugin.google.maps.LatLngBounds(args);
}
@CordovaInstance({ sync: true })
@ -1008,3 +1002,38 @@ export class GoogleMapsLatLng {
return this.lat.toFixed(precision) + ',' + this.lng.toFixed(precision);
}
}
/**
* @private
*/
export interface GeocoderRequest {
address?: string;
position?: { lat: number; lng: number };
}
/**
* @private
*/
export interface GeocoderResult {
position?: { lat: number; lng: number };
subThoroughfare?: string;
thoroughfare?: string;
locality?: string;
adminArea?: string;
postalCode?: string;
country?: string;
}
/**
* @private
*/
export class Geocoder {
/**
* Converts position to address and vice versa
* @param {GeocoderRequest} request Request object with either an address or a position
* @returns {Promise<GeocoderResult[]>}
*/
static geocode(request: GeocoderRequest): Promise<GeocoderResult[]> {
return new Promise<GeocoderResult[]>((resolve, reject) => {
if (!plugin || !plugin.google || !plugin.google.maps || !plugin.google.maps.Geocoder) reject({ error: 'plugin_not_installed' });
else plugin.google.maps.Geocoder.geocode(request, resolve);
});
}
}

703
src/plugins/ibeacon.ts Normal file
View File

@ -0,0 +1,703 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
declare var cordova: any;
export interface Beacon {
/**
* The physical device's identifier.
*/
uuid: string;
/**
* The beacon's major identifier number.
*/
major: number;
/**
* The beacon's major identifier number.
*/
minor: number;
/**
* The proximity of the beacon relative to the phone.
*
* Possible options are:
* ProximityImmediate
* ProximityNear
* ProximityFar
* ProximityUnknown
*/
proximity: 'ProximityImmediate' | 'ProximityNear' | 'ProximityFar' | 'ProximityUnknown';
/**
* Transmission Power of the beacon. A constant emitted by the beacon which indicates what's the expected RSSI at a distance of 1 meter to the beacon.
*/
tx: number;
/**
* Received Signal Strength Indicator. The strength of the beacon's signal when it reaches the device.
* RSSI ranges from aprox -26 (a few inches) to -100 (40-50 m distance).
*/
rssi: number;
/**
* The accuracy of the ranging.
*/
accuracy: number;
}
export interface BeaconRegion {
/**
* A unique identifier for this region.
*/
identifier: string;
/**
* The the beacon identifier the device will "watch" for. Many beacons can share the same uuid.
*/
uuid: string;
/**
* The beacon's major identifier number. Optional, of nothing is supplied
* the plugin will treat it as a wildcard.
*/
major?: number;
/**
* The beacon's minor identifier number. Optional, of nothing is supplied
* the plugin will treat it as a wildcard.
*/
minor?: number;
/**
* If set to true the device will scan for beacons and determine region state anytime
* the device's screen is turned on or off. Useful for debugging.
*/
notifyEntryStateOnDisplay?: boolean;
}
export interface CircularRegion {
/**
* A unique identifier for this region.
*/
identifier: string;
/**
* The latitude of this region.
*/
latitude: number;
/**
* The longitude of this region.
*/
longitude: number;
/**
* The radius of the geofence for this region.
*/
radius: number;
}
export type Region = BeaconRegion | CircularRegion;
export interface PluginResult {
/**
* The name of the delegate function that produced the PluginResult object.
*/
eventType: string;
/**
* The region that triggered the event.
*/
region: Region;
/**
* An array of beacon objects
*/
beacons: Beacon[];
/**
* The status of the location permission for iOS.
*/
authorizationStatus: string;
/**
* The state of the phone in relation to the region. Inside/outside for example.
*/
state: 'CLRegionStateInside' | 'CLRegionStateOutside';
/**
* Error message, used only with monitoringDidFailForRegionWithError delegate.
*/
error: string;
}
export interface Delegate {
/**
* An observable that publishes information about the location permission authorization status.
*
* @return Returns a string.
*/
didChangeAuthorizationStatus(): Observable<string>;
/**
* An Observable that publishes event data to it's subscribers
* when the native layer is able to determine the device's state.
*
* This event is called when the phone begins starts monitoring,
* when requestStateForRegion is called, etc.
*
* @return {PluginResult} Returns a PluginResult object with information about the event, region, and beacon(s).
*/
didDetermineStateForRegion(): Observable<PluginResult>;
/**
* An Observable that publishes event data to it's subscribers
* when the phone enters a region that it was asked to monitor.
*
* If the user has given the app Always-Location permission, this function
* will be called even when the app is not running on iOS.
* The app will run silently in the background for a small amount of time.
*
* @return {PluginResult} Returns a PluginResult object with information about the event, region, and beacon(s).
*/
didEnterRegion(): Observable<PluginResult>;
/**
* An Observable that publishes event data to it's subscribers
* when the phone exits a region that it was asked to monitor.
*
* If the user has given the app Always-Location permission, this function
* will be called even when the app is not running on iOS.
* The app will run silently in the background for a small amount of time.
*
* @return {PluginResult} Returns a PluginResult object with information about the event, region, and beacon(s).
*/
didExitRegion(): Observable<PluginResult>;
/**
* An Observable that publishes event data to it's subscribers
* each time that the device ranges beacons. Modern Android and iOS devices range
* aproximately once per second.
*
* @return {PluginResult} Returns a PluginResult object with information about the event, region, and beacon(s).
*/
didRangeBeaconsInRegion(): Observable<PluginResult>;
/**
* An Observable that publishes event data to it's subscribers
* when the device begins monitoring a region.
*
* @return {PluginResult} Returns a PluginResult object with information about the event, region, and beacon(s).
*/
didStartMonitoringForRegion(): Observable<PluginResult>;
/**
* An Observable that publishes event data to it's subscribers
* when the device fails to monitor a region.
*
* @return {PluginResult} Returns a PluginResult object with information about the event, region, and beacon(s).
*/
monitoringDidFailForRegionWithError(): Observable<PluginResult>;
/**
* An Observable that publishes event data to it's subscribers
* when the device begins advertising as an iBeacon.
*
* @return {PluginResult} Returns a PluginResult object with information about the event, region, and beacon(s).
*/
peripheralManagerDidStartAdvertising(): Observable<PluginResult>;
/**
* An Observable that publishes event data to it's subscribers
* when the state of the peripheral manager's state updates.
*
*
* @return {PluginResult} Returns a PluginResult object with information about the event, region, and beacon(s).
*/
peripheralManagerDidUpdateState(): Observable<PluginResult>;
}
/**
* @name IBeacon
* @description
* This plugin provides functions for working with iBeacons.
*
* The plugin's API closely mimics the one exposed through the [CLLocationManager](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html) introduced in iOS 7.
*
* @usage
*
* ```ts
* import {IBeacon} from 'ionic-native';
*
*
* // Request permission to use location on iOS
* IBeacon.requestAlwaysAuthorization();
* // create a new delegate and register it with the native layer
* let delegate = IBeacon.Delegate();
*
* // Subscribe to some of the delegate's event handlers
* delegate.didRangeBeaconsInRegion()
* .subscribe(
* data => {console.log('didRangeBeaconsInRegion: ', data)},
* error => console.error
* );
* delegate.didStartMonitoringForRegion()
* .subscribe(
* data => {console.log('didStartMonitoringForRegion: ', data)},
* error => console.error
* );
* delegate.didEnterRegion()
* .subscribe(
* data => {
* console.log('didEnterRegion: ', data);
* }
* );
*
* let beaconRegion = IBeacon.BeaconRegion('deskBeacon','F7826DA6-ASDF-ASDF-8024-BC5B71E0893E');
*
* IBeacon.startMonitoringForRegion(beaconRegion)
* .then(
* () => console.log('Native layer recieved the request to monitoring'),
* error => console.error('Native layer failed to begin monitoring: ', error)
* );
* ```
*/
@Plugin({
plugin: 'cordova-plugin-ibeacon',
pluginRef: 'cordova.plugins.locationManager',
repo: 'https://github.com/petermetz/cordova-plugin-ibeacon',
platforms: ['Android', 'iOS']
})
export class IBeacon {
/**
* Instances of this class are delegates between the {@link LocationManager} and
* the code that consumes the messages generated on in the native layer.
*
* @returns {Delegate} An instance of the type {@type Delegate}.
*/
static Delegate(): Delegate {
let delegate = new cordova.plugins.locationManager.Delegate();
delegate.didChangeAuthorizationStatus = (pluginResult?: PluginResult) => {
return new Observable<PluginResult>(
(observer: any) => {
let cb = (data: PluginResult) => observer.next(data);
return delegate.didChangeAuthorizationStatus = cb;
}
);
};
delegate.didDetermineStateForRegion = (pluginResult?: PluginResult) => {
return new Observable<PluginResult>(
(observer: any) => {
let cb = (data: PluginResult) => observer.next(data);
return delegate.didDetermineStateForRegion = cb;
}
);
};
delegate.didEnterRegion = (pluginResult?: PluginResult) => {
return new Observable<PluginResult>(
(observer: any) => {
let cb = (data: PluginResult) => observer.next(data);
return delegate.didEnterRegion = cb;
}
);
};
delegate.didExitRegion = (pluginResult?: PluginResult) => {
return new Observable<PluginResult>(
(observer: any) => {
let cb = (data: PluginResult) => observer.next(data);
return delegate.didExitRegion = cb;
}
);
};
delegate.didRangeBeaconsInRegion = (pluginResult?: PluginResult) => {
return new Observable<PluginResult>(
(observer: any) => {
let cb = (data: PluginResult) => observer.next(data);
return delegate.didRangeBeaconsInRegion = cb;
}
);
};
delegate.didStartMonitoringForRegion = (pluginResult?: PluginResult) => {
return new Observable<PluginResult>(
(observer: any) => {
let cb = (data: PluginResult) => observer.next(data);
return delegate.didStartMonitoringForRegion = cb;
}
);
};
delegate.monitoringDidFailForRegionWithError = (pluginResult?: PluginResult) => {
return new Observable<PluginResult>(
(observer: any) => {
let cb = (data: PluginResult) => observer.next(data);
return delegate.monitoringDidFailForRegionWithError = cb;
}
);
};
delegate.peripheralManagerDidStartAdvertising = (pluginResult?: PluginResult) => {
return new Observable<PluginResult>(
(observer: any) => {
let cb = (data: PluginResult) => observer.next(data);
return delegate.peripheralManagerDidStartAdvertising = cb;
}
);
};
delegate.peripheralManagerDidUpdateState = (pluginResult?: PluginResult) => {
return new Observable<PluginResult>(
(observer: any) => {
let cb = (data: PluginResult) => observer.next(data);
return delegate.peripheralManagerDidUpdateState = cb;
}
);
};
cordova.plugins.locationManager.setDelegate(delegate);
return delegate;
}
/**
* Creates a new BeaconRegion
*
* @param {String} identifier @see {CLRegion}
* @param {String} uuid The proximity ID of the beacon being targeted.
* This value must not be blank nor invalid as a UUID.
* @param {Number} major The major value that you use to identify one or more beacons.
* @param {Number} minor The minor value that you use to identify a specific beacon.
* @param {BOOL} notifyEntryStateOnDisplay
*
* @return Returns the BeaconRegion that was created
*/
static BeaconRegion(identifer: string, uuid: string, major?: number, minor?: number, notifyEntryStateOnDisplay?: boolean): BeaconRegion {
return new cordova.plugins.locationManager.BeaconRegion(identifer, uuid, major, minor, notifyEntryStateOnDisplay);
}
/**
* @return Returns the Delegate
*/
@Cordova()
static getDelegate(): Delegate { return; }
/**
* @param {Delegate} delegate An instance of a delegate to register with the native layer.
*
* @return Returns the Delegate
*/
@Cordova()
static setDelegate(delegate: Delegate): Delegate { return; }
/**
* Signals the native layer that the client side is ready to consume messages.
* Readiness here means that it has a {Delegate} set by the consumer javascript
* code.
*
* The {LocationManager.setDelegate()} will implicitly call this method as well,
* therefore the only case when you have to call this manually is if you don't
* wish to specify a {Delegate} of yours.
*
* The purpose of this signaling mechanism is to make the events work when the
* app is being woken up by the Operating System to give it a chance to handle
* region monitoring events for example.
*
* If you don't set a {Delegate} and don't call this method manually, an error
* message get emitted in the native runtime and the DOM as well after a certain
* period of time.
*
* @return Returns a promise which is resolved as soon as the
* native layer acknowledged the request and started to send events.
*/
@Cordova({sync: true})
static onDomDelegateReady(): Promise<void> { return; }
/**
* Determines if bluetooth is switched on, according to the native layer.
* @returns Returns a promise which is resolved with a {Boolean}
* indicating whether bluetooth is active.
*/
@Cordova({sync: true})
static isBluetoothEnabled(): Promise<boolean> { return; }
/**
* Enables Bluetooth using the native Layer. (ANDROID ONLY)
*
* @returns Returns a promise which is resolved when Bluetooth
* could be enabled. If not, the promise will be rejected with an error.
*/
@Cordova({sync: true})
static enableBluetooth(): Promise<void> { return; }
/**
* Disables Bluetooth using the native Layer. (ANDROID ONLY)
*
* @returns Returns a promise which is resolved when Bluetooth
* could be enabled. If not, the promise will be rejected with an error.
*/
@Cordova({sync: true})
static disableBluetooth(): Promise<void> { return; }
/**
* Start monitoring the specified region.
*
* If a region of the same type with the same identifier is already being
* monitored for this application,
* it will be removed from monitoring. For circular regions, the region
* monitoring service will prioritize
* regions by their size, favoring smaller regions over larger regions.
*
* This is done asynchronously and may not be immediately reflected in monitoredRegions.
*
* @param {Region} region An instance of {Region} which will be monitored
* by the operating system.
*
* @return Returns a promise which is resolved as soon as the
* native layer acknowledged the dispatch of the monitoring request.
*/
@Cordova({sync: true})
static startMonitoringForRegion(region: BeaconRegion): Promise<string> { return; }
/**
* Stop monitoring the specified region. It is valid to call
* stopMonitoringForRegion: for a region that was registered for monitoring
* with a different location manager object, during this or previous
* launches of your application.
*
* This is done asynchronously and may not be immediately reflected in monitoredRegions.
*
* @param {Region} region An instance of {Region} which will be monitored
* by the operating system.
*
* @return Returns a promise which is resolved as soon as the
* native layer acknowledged the dispatch of the request to stop monitoring.
*/
@Cordova({sync: true})
static stopMonitoringForRegion(region: BeaconRegion): Promise<void> { return; }
/**
* Request state the for specified region. When result is ready
* didDetermineStateForRegion is triggered. This can be any region,
* also those which is not currently monitored.
*
* This is done asynchronously and may not be immediately reflected in monitoredRegions.
*
* @param {Region} region An instance of {Region} which will be monitored
* by the operating system.
*
* @return Returns a promise which is resolved as soon as the
* native layer acknowledged the dispatch of the request to stop monitoring.
*/
@Cordova({sync: true})
static requestStateForRegion(region: Region): Promise<void> { return; }
/**
* Start ranging the specified beacon region.
*
* If a region of the same type with the same identifier is already being
* monitored for this application, it will be removed from monitoring.
*
* This is done asynchronously and may not be immediately reflected in rangedRegions.
*
* @param {Region} region An instance of {BeaconRegion} which will be monitored
* by the operating system.
*
* @return Returns a promise which is resolved as soon as the
* native layer acknowledged the dispatch of the monitoring request.
*/
@Cordova({sync: true})
static startRangingBeaconsInRegion(region: BeaconRegion): Promise<void> { return; }
/**
* Stop ranging the specified region. It is valid to call
* stopMonitoringForRegion: for a region that was registered for ranging
* with a different location manager object, during this or previous
* launches of your application.
*
* This is done asynchronously and may not be immediately reflected in rangedRegions.
*
* @param {Region} region An instance of {BeaconRegion} which will be monitored
* by the operating system.
*
* @return Returns a promise which is resolved as soon as the
* native layer acknowledged the dispatch of the request to stop monitoring.
*/
@Cordova({sync: true})
static stopRangingBeaconsInRegion(region: BeaconRegion): Promise<void> { return; }
/**
* Queries the native layer to determine the current authorization in effect.
*
* @returns Returns a promise which is resolved with the
* requested authorization status.
*/
@Cordova({sync: true})
static getAuthorizationStatus(): Promise<any> { return; }
/**
* For iOS 8 and above only. The permission model has changed by Apple in iOS 8, making it necessary for apps to
* explicitly request permissions via methods like these:
* <a href="https://developer.apple.com/library/prerelease/iOS/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestWhenInUseAuthorization">requestWhenInUseAuthorization</a>
* <a href="https://developer.apple.com/library/prerelease/iOS/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestAlwaysAuthorization">requestAlwaysAuthorization</a>
*
* If you are using this plugin on Android devices only, you will never have to use this, nor {@code requestAlwaysAuthorization}
* @returns Returns a promise that is resolved when the request dialog is shown.
*/
@Cordova({sync: true})
static requestWhenInUseAuthorization(): Promise<void> { return; }
/**
* See the docuemntation of {@code requestWhenInUseAuthorization} for further details.
*
* @returns Returns a promise which is resolved when the native layer
* shows the request dialog.
*/
@Cordova({sync: true})
static requestAlwaysAuthorization(): Promise<void> { return; }
/**
*
* @returns Returns a promise which is resolved with an {Array}
* of {Region} instances that are being monitored by the native layer.
*/
@Cordova({sync: true})
static getMonitoredRegions(): Promise<Region[]> { return; }
/**
*
* @returns Returns a promise which is resolved with an {Array}
* of {Region} instances that are being ranged by the native layer.
*/
@Cordova({sync: true})
static getRangedRegions(): Promise<Region[]> { return; }
/**
* Determines if ranging is available or not, according to the native layer.
* @returns Returns a promise which is resolved with a {Boolean}
* indicating whether ranging is available or not.
*/
@Cordova({sync: true})
static isRangingAvailable(): Promise<boolean> { return; }
/**
* Determines if region type is supported or not, according to the native layer.
*
* @param {Region} region An instance of {Region} which will be checked
* by the operating system.
*
* @returns Returns a promise which is resolved with a {Boolean}
* indicating whether the region type is supported or not.
*/
@Cordova({sync: true})
static isMonitoringAvailableForClass(region: Region): Promise<boolean> { return; }
/**
* Start advertising the specified region.
*
* If a region a different identifier is already being advertised for
* this application, it will be replaced with the new identifier.
*
* This call will accept a valid beacon even when no BlueTooth is available,
* and will start when BlueTooth is powered on. See {Delegate.}
*
* @param {Region} region An instance of {Region} which will be advertised
* by the operating system.
* @param {Integer} measuredPower: Optional parameter, if left empty, the device will
* use it's own default value.
*
* @return Returns a promise which is resolved as soon as the
* native layer acknowledged the dispatch of the advertising request.
*/
@Cordova({sync: true})
static startAdvertising(region: Region, measuredPower: number): Promise<void> { return; }
/**
* Stop advertising as a beacon.
*
* This is done asynchronously and may not be immediately reflected in isAdvertising.
*
* @return Returns a promise which is resolved as soon as the
* native layer acknowledged the dispatch of the request to stop advertising.
*/
@Cordova({sync: true})
static stopAdvertising(region: Region): Promise<void> { return; }
/**
* Determines if advertising is available or not, according to the native layer.
* @returns Returns a promise which is resolved with a {Boolean}
* indicating whether advertising is available or not.
*/
@Cordova({sync: true})
static isAdvertisingAvailable(): Promise<boolean> { return; }
/**
* Determines if advertising is currently active, according to the native layer.
* @returns Returns a promise which is resolved with a {Boolean}
* indicating whether advertising is active.
*/
@Cordova({sync: true})
static isAdvertising(): Promise<boolean> { return; }
/**
* Disables debug logging in the native layer. Use this method if you want
* to prevent this plugin from writing to the device logs.
*
* @returns Returns a promise which is resolved as soon as the
* native layer has set the logging level accordingly.
*/
@Cordova({sync: true})
static disableDebugLogs(): Promise<void> { return; }
/**
* Enables the posting of debug notifications in the native layer. Use this method if you want
* to allow the plugin the posting local notifications.
* This can be very helpful when debugging how to apps behave when launched into the background.
*
* @returns Returns a promise which is resolved as soon as the
* native layer has set the flag to enabled.
*/
@Cordova({sync: true})
static enableDebugNotifications(): Promise<void> { return; }
/**
* Disables the posting of debug notifications in the native layer. Use this method if you want
* to prevent the plugin from posting local notifications.
*
* @returns Returns a promise which is resolved as soon as the
* native layer has set the flag to disabled.
*/
@Cordova({sync: true})
static disableDebugNotifications(): Promise<void> { return; }
/**
* Enables debug logging in the native layer. Use this method if you want
* a debug the inner workings of this plugin.
*
* @returns Returns a promise which is resolved as soon as the
* native layer has set the logging level accordingly.
*/
@Cordova({sync: true})
static enableDebugLogs(): Promise<void> { return; }
/**
* Appends the provided [message] to the device logs.
* Note: If debug logging is turned off, this won't do anything.
*
* @param {String} message The message to append to the device logs.
*
* @returns Returns a promise which is resolved with the log
* message received by the native layer for appending. The returned message
* is expected to be equivalent to the one provided in the original call.
*/
@Cordova({sync: true})
static appendToDeviceLog(message: string): Promise<void> { return; }
}

View File

@ -3,47 +3,58 @@ import {Plugin, Cordova} from './plugin';
export interface LaunchNavigatorOptions {
/**
* iOS, Android, Windows
* If true, the plugin will NOT attempt to use the geolocation plugin to determine the current device position when the start location parameter is omitted. Defaults to false.
* name of the navigation app to use for directions. Specify using launchnavigator.APP constants. If not specified, defaults to User Selection.
*/
disableAutoGeolocation?: boolean;
app?: string;
/**
* nickname to display in app for destination. e.g. "Bob's House".
*/
destinationName?: string;
/**
* Start point of the navigation
*/
start?: string|number[];
/**
* nickname to display in app for start . e.g. "My House".
*/
startName?: string;
/**
* iOS, Android, Windows
* Transportation mode for navigation: "driving", "walking" or "transit". Defaults to "driving" if not specified.
*/
transportMode?: string;
/**
* iOS
* If true, plugin will attempt to launch Google Maps instead of Apple Maps. If Google Maps is not available, it will fall back to Apple Maps.
*/
preferGoogleMaps?: boolean;
/**
* iOS
* If using Google Maps and the app has a URL scheme, passing this to Google Maps will display a button which returns to the app.
*/
urlScheme?: string;
/**
* iOS
* If using Google Maps with a URL scheme, this specifies the text of the button in Google Maps which returns to the app. Defaults to "Back" if not specified.
*/
backButtonText?: string;
/**
* iOS
* If true, debug log output will be generated by the plugin. Defaults to false.
*/
enableDebug?: boolean;
/**
* Android
* Navigation mode in which to open Google Maps app: "maps" or "turn-by-turn". Defaults to "maps" if not specified.
* a key/value map of extra app-specific parameters. For example, to tell Google Maps on Android to display Satellite view in "maps" launch mode: `{"t": "k"}`
*/
navigationMode?: string;
extras?: any;
/**
* (Android only) mode in which to open Google Maps app: "maps" or "turn-by-turn". Defaults to "maps" if not specified. Specify using launchnavigator.LAUNCH_MODE constants.
*/
launchMode?: string;
/**
* text to display in the native picker which enables user to select which navigation app to launch. Defaults to "Select app for navigation" if not specified.
*/
appSelectionDialogHeader?: string;
/**
* text to display for the cancel button in the native picker which enables user to select which navigation app to launch. Defaults to "Cancel" if not specified.
*/
appSelectionCancelButton?: string;
successCallback?: Function;
errorCallback?: Function;
}
/**
@ -52,12 +63,17 @@ export interface LaunchNavigatorOptions {
* Requires Cordova plugin: uk.co.workingedge.phonegap.plugin.launchnavigator. For more info, please see the [LaunchNavigator plugin docs](https://github.com/dpa99c/phonegap-launch-navigator).
*
* @usage
* Please refer to the plugin's repo for detailed usage. This docs page only explains the Native wrapper.
*
* ```js
* import {LaunchNavigator} from 'ionic-native';
* import {LaunchNavigator, LaunchNavigatorOptions} from 'ionic-native';
*
* let options: LaunchNavigatorOptions = {
* start: 'London, ON',
* app: LaunchNavigator.APPS.UBER
* };
*
*
* LaunchNavigator.navigate("Toronto, ON", "London, ON")
* LaunchNavigator.navigate("Toronto, ON", options)
* .then(
* success => console.log("Launched navigator"),
* error => console.log("Error launching navigator", error)
@ -73,19 +89,109 @@ export class LaunchNavigator {
/**
* Launches navigator app
* @param destination Location name or coordinates
* @param start Location name or coordinates
* @param options
* @param destination {string|number[]} Location name or coordinates (as string or array)
* @param options {LaunchNavigatorOptions}
* @returns {Promise<any>}
*/
@Cordova({
successIndex: 2,
errorIndex: 3
successIndex: 1,
errorIndex: 2
})
static navigate(
destination: any,
start: any = null,
destination: string|number[],
options?: LaunchNavigatorOptions
): Promise<any> { return; }
/**
* Determines if the given app is installed and available on the current device.
* @param app {string}
*/
@Cordova()
static isAppAvailable(app: string): Promise<any> {return; }
/**
* Returns a list indicating which apps are installed and available on the current device.
*/
@Cordova()
static availableApps(): Promise<string[]> {return; }
/**
* Returns the display name of the specified app.
* @param app {string}
*/
@Cordova({sync: true})
static getAppDisplayName(app: string): string {return; }
/**
* Returns list of supported apps on a given platform.
* @param platform {string}
*/
@Cordova({sync: true})
static getAppsForPlatform(platform: string): string[] {return; }
/**
* Indicates if an app on a given platform supports specification of transport mode.
* @param app {string} specified as a string, you can use one of the constants, e.g `LaunchNavigator.APP.GOOGLE_MAPS`
* @param platform {string}
*/
@Cordova({sync: true})
static supportsTransportMode(app: string, platform: string): boolean {return; }
/**
* Returns the list of transport modes supported by an app on a given platform.
* @param app {string}
* @param platform {string}
*/
@Cordova({sync: true})
static getTransportModes(app: string, platform: string): string[] {return; }
/**
* Indicates if an app on a given platform supports specification of launch mode.
* Note that currently only Google Maps on Android does.
* @param app {string}
* @param platform {string}
*/
@Cordova({sync: true})
static supportsLaunchMode(app: string, platform: string): boolean {return; }
/**
* Indicates if an app on a given platform supports specification of start location.
* @param app {string}
* @param platform {string}
*/
@Cordova({sync: true})
static supportsStart(app: string, platform: string): boolean {return; }
@Cordova({sync: true})
static supportsStartName(app: string, platform: string): boolean {return; }
@Cordova({sync: true})
static supportsDestName(app: string, platform: string): boolean {return; }
@Cordova({sync: true})
static userSelect(destination: string|number[], options: LaunchNavigatorOptions): void { }
static APP: any = {
USER_SELECT: 'user_select',
APPLE_MAPS: 'apple_maps',
GOOGLE_MAPS: 'google_maps',
WAZE: 'waze',
CITYMAPPER: 'citymapper',
NAVIGON: 'navigon',
TRANSIT_APP: 'transit_app',
YANDEX: 'yandex',
UBER: 'uber',
TOMTOM: 'tomtom',
BING_MAPS: 'bing_maps',
SYGIC: 'sygic',
HERE_MAPS: 'here_maps',
MOOVIT: 'moovit'
};
static TRANSPORT_MODE: any = {
DRIVING: 'driving',
WALKING: 'walking',
BICYCLING: 'bicycling',
TRANSIT: 'transit'
};
}

View File

@ -0,0 +1,219 @@
import {Plugin, Cordova, CordovaProperty} from './plugin';
import {Observable} from 'rxjs/Rx';
declare var navigator: any;
/**
* @name Media Capture
* @description
* @usage
* ```typescript
* import {MediaCapture} from 'ionic-native';
*
* ...
*
* let options: CaptureImageOptions = { limit: 3 };
* MediaCapture.captureImage(options)
* .then(
* (data: MediaFile[]) => console.log(data),
* (err: CaptureError) => console.error(err)
* );
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-media-capture',
pluginRef: 'navigator.device.capture',
repo: 'https://github.com/apache/cordova-plugin-media-capture'
})
export class MediaCapture {
/**
* The audio recording formats supported by the device.
* @returns {ConfigurationData[]}
*/
@CordovaProperty
static get supportedImageModes(): ConfigurationData[] {
return <ConfigurationData[]>navigator.device.capture.supportedImageModes;
}
/**
* The recording image sizes and formats supported by the device.
* @returns {ConfigurationData[]}
*/
@CordovaProperty
static get supportedAudioModes(): ConfigurationData[] {
return <ConfigurationData[]>navigator.device.capture.supportedAudioModes;
}
/**
* The recording video resolutions and formats supported by the device.
* @returns {ConfigurationData[]}
*/
@CordovaProperty
static get supportedVideoModes(): ConfigurationData[] {
return <ConfigurationData[]>navigator.device.capture.supportedVideoModes;
}
/**
* Start the audio recorder application and return information about captured audio clip files.
* @param options
*/
@Cordova({
callbackOrder: 'reverse'
})
static captureAudio(options?: CaptureAudioOptions): Promise<MediaFile[]|CaptureError> {return; }
/**
* Start the camera application and return information about captured image files.
* @param options
*/
@Cordova({
callbackOrder: 'reverse'
})
static captureImage(options?: CaptureImageOptions): Promise<MediaFile[]|CaptureError> {return; }
/**
* Start the video recorder application and return information about captured video clip files.
* @param options
*/
@Cordova({
callbackOrder: 'reverse'
})
static captureVideo(options?: CaptureVideoOptions): Promise<MediaFile[]|CaptureError> {return; }
/**
* is fired if the capture call is successful
*/
@Cordova({
eventObservable: true,
event: 'pendingcaptureresult'
})
static onPendingCaptureResult(): Observable<MediaFile[]> {return; }
/**
* is fired if the capture call is unsuccessful
*/
@Cordova({
eventObservable: true,
event: 'pendingcaptureerror'
})
static onPendingCaptureError(): Observable<CaptureError> {return; }
}
/**
* Encapsulates properties of a media capture file.
*/
export interface MediaFile {
/**
* The name of the file, without path information.
*/
name: string;
/**
* The full path of the file, including the name.
*/
fullPath: string;
/**
* The file's mime type
*/
type: string;
/**
* The date and time when the file was last modified.
*/
lastModifiedDate: Date;
/**
* The size of the file, in bytes.
*/
size: number;
/**
* Retrieves the format information of the media file.
* @param {Function} successCallback
* @param {Function} errorCallback
*/
getFormatData(successCallback: (data: MediaFileData) => any, errorCallback?: (err: any) => any);
}
/**
* Encapsulates format information about a media file.
*/
export interface MediaFileData {
/**
* The actual format of the audio and video content.
*/
codecs: string;
/**
* The average bitrate of the content. The value is zero for images.
*/
bitrate: number;
/**
* The height of the image or video in pixels. The value is zero for audio clips.
*/
height: number;
/**
* The width of the image or video in pixels. The value is zero for audio clips.
*/
width: number;
/**
* The length of the video or sound clip in seconds. The value is zero for images.
*/
duration: number;
}
/**
* Encapsulates the error code resulting from a failed media capture operation.
*/
export interface CaptureError {
code: string;
}
/**
* Encapsulates audio capture configuration options.
*/
export interface CaptureAudioOptions {
/**
* Maximum number of audio clips. Defaults to 1.
* On iOS you can only record one file.
*/
limit?: number;
/**
* Maximum duration of an audio sound clip, in seconds. This does not work on Android devices.
*/
duration?: number;
}
/**
* Encapsulates image capture configuration options.
*/
export interface CaptureImageOptions {
/**
* Maximum number of images to capture. This limit is not supported on iOS, only one image will be taken per invocation.
*/
limit?: number;
}
/**
* Encapsulates video capture configuration options.
*/
export interface CaptureVideoOptions {
/**
* Maximum number of video clips to record. This value is ignored on iOS, only one video clip can be taken per invocation.
*/
limit?: number;
/**
* Maximum duration per video clip. This will be ignored on BlackBerry.
*/
duration?: number;
/**
* Quality of the video. This parameter can only be used with Android.
*/
quality?: number;
}
/**
* Encapsulates a set of media capture parameters that a device supports.
*/
export interface ConfigurationData {
/**
* The ASCII-encoded lowercase string representing the media type.
*/
type: string;
/**
* The height of the image or video in pixels. The value is zero for sound clips.
*/
height: number;
/**
* The width of the image or video in pixels. The value is zero for sound clips.
*/
width: number;
}

View File

@ -0,0 +1,56 @@
import {Plugin, Cordova} from './plugin';
/**
* @name Native Storage
* @description
*
* @usage
* ```typescript
* import {NativeStorage} from 'ionic-native';
*
* 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)
* );
* ```
*/
@Plugin({
plugin: 'cordova-plugin-nativestorage',
pluginRef: 'NativeStorage',
repo: 'https://github.com/TheCocoaProject/cordova-plugin-nativestorage'
})
export class NativeStorage {
/**
* Stores a value
* @param reference
* @param value
*/
@Cordova()
static setItem(reference: string, value: any): Promise<any> {return; }
/**
* Gets a stored item
* @param reference
*/
@Cordova()
static getItem(reference: string): Promise<any> {return; }
/**
* Removes a single stored item
* @param reference
*/
@Cordova()
static remove(reference: string): Promise<any> {return; }
/**
* Removes all stored values.
*/
@Cordova()
static clear(): Promise<any> {return; }
}

View File

@ -10,7 +10,7 @@ declare var navigator: any;
*
* @usage
* ```js
* import {Network, Connection} from 'ionic-native';
* import {Network} from 'ionic-native';
*
* // watch network for a disconnect
* let disconnectSubscription = Network.onDisconnect().subscribe(() => {
@ -28,8 +28,7 @@ declare var navigator: any;
*// before we determine the connection type. Might need to wait
* // prior to doing any api requests as well.
* setTimeout(() => {
* console.log(Network.connection);
* if (Network.connection === Connection.WIFI) {
* if (Network.connection === 'wifi') {
* console.log('we got a wifi connection, woohoo!');
* }
* }, 3000);
@ -39,6 +38,8 @@ declare var navigator: any;
* connectSubscription.unsubscribe();
*
* ```
* @advanced
* The `connection` property will return one of the following connection types: `unknown`, `ethernet`, `wifi`, `2g`, `3g`, `4g`, `cellular`, `none`
*/
@Plugin({
plugin: 'cordova-plugin-network-information',
@ -52,7 +53,7 @@ export class Network {
* Return the network connection type
*/
@CordovaProperty
static get connection(): Connection { return navigator.connection.type; }
static get connection(): String { return navigator.connection.type; }
/**
* Get notified when the device goes offline
@ -75,14 +76,3 @@ export class Network {
static onConnect(): Observable<any> { return; }
}
export class Connection {
static get UNKNOWN() { return 'unknown'; }
static get ETHERNET() { return 'ethernet'; }
static get WIFI() { return 'wifi'; }
static get CELL_2G() { return '2g'; }
static get CELL_3G() { return '3g'; }
static get CELL_4G() { return '4g'; }
static get CELL() { return 'cellular'; }
static get NONE() { return 'none'; }
}

37
src/plugins/pin-dialog.ts Normal file
View File

@ -0,0 +1,37 @@
import {Plugin, Cordova} from './plugin';
/**
* @name Pin Dialog
* @description
*
* @usage
* ```typescript
* import {PinDialog} from 'ionic-native';
*
* ...
*
* PinDialog.prompt('Enter your PIN', 'Verify PIN', ['OK', 'Cancel'])
* .then(
* (result: any) => {
* if(result.buttonIndex == 1) console.log('User clicked OK, value is: ', result.input1);
* else if(result.buttonIndex == 2) console.log('User cancelled');
* }
* );
* ```
*/
@Plugin({
plugin: 'cordova-plugin-pin-dialog',
pluginRef: 'plugins.pinDialog',
repo: 'https://github.com/Paldom/PinDialog'
})
export class PinDialog {
/**
* Show pin dialog
* @param {string} message Message to show the user
* @param {string} title Title of the dialog
* @param {string[]} buttons Buttons to show
*/
@Cordova({
successIndex: 1
})
static prompt(message: string, title: string, buttons: string[]): Promise<{buttonIndex: number, input1: string}> {return; }
}

View File

@ -142,6 +142,7 @@ function callInstance(pluginObj: any, methodName: string, args: any[], opts: any
function wrapInstance (pluginObj: any, methodName: string, opts: any = {}) {
return (...args) => {
if (opts.sync) {
// Sync doesn't wrap the plugin with a promise or observable, it returns the result as-is
return callInstance(pluginObj, methodName, args, opts);
} else if (opts.observable) {
return new Observable(observer => {
@ -173,9 +174,8 @@ function wrapInstance (pluginObj: any, methodName: string, opts: any = {}) {
*/
function wrapEventObservable (event: string): Observable<any> {
return new Observable(observer => {
let callback = (status: any) => observer.next(status);
window.addEventListener(event, callback, false);
return () => window.removeEventListener(event, callback, false);
window.addEventListener(event, observer.next.bind(observer), false);
return () => window.removeEventListener(event, observer.next.bind(observer), false);
});
}
@ -190,6 +190,7 @@ export const wrap = function(pluginObj: any, methodName: string, opts: any = {}
return (...args) => {
if (opts.sync)
// Sync doesn't wrap the plugin with a promise or observable, it returns the result as-is
return callCordovaPlugin(pluginObj, methodName, args, opts);
else if (opts.observable)

View File

@ -191,24 +191,24 @@ export interface IOSPushOptions {
* The data required in order to enable Action Buttons for iOS.
* Action Buttons on iOS - https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons-1
*/
categories?: CategoryArray
categories?: CategoryArray;
}
export interface CategoryArray {
[name: string]: CategoryAction
[name: string]: CategoryAction;
}
export interface CategoryAction {
yes?: CategoryActionData
no?: CategoryActionData
maybe?: CategoryActionData
yes?: CategoryActionData;
no?: CategoryActionData;
maybe?: CategoryActionData;
}
export interface CategoryActionData {
callback: string
title: string
foreground: boolean
destructive: boolean
callback: string;
title: string;
foreground: boolean;
destructive: boolean;
}
export interface AndroidPushOptions {

View File

@ -41,7 +41,7 @@ import {Plugin, Cordova} from './plugin';
@Plugin({
plugin: 'cordova-plugin-safariviewcontroller',
pluginRef: 'SafariViewController',
platforms: ['iOS'],
platforms: ['iOS', 'Android'],
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller'
})
export class SafariViewController {
@ -56,17 +56,13 @@ export class SafariViewController {
* Shows Safari View Controller
* @param options
*/
@Cordova({
callbackOrder: 'reverse'
})
@Cordova()
static show(options?: SafariViewControllerOptions): Promise<any> {return; }
/**
* Hides Safari View Controller
*/
@Cordova({
sync: true
})
@Cordova()
static hide(): void {}
/**

35
src/plugins/sim.ts Normal file
View File

@ -0,0 +1,35 @@
import {Plugin, Cordova} from './plugin';
/**
* @name Sim
* @description
* Gets info from the Sim card like the carrier name, mcc, mnc and country code and other system dependent info.
*
* Requires Cordova plugin: `cordova-plugin-sim`. For more info, please see the [Cordova Sim docs](https://github.com/pbakondy/cordova-plugin-sim).
*
* @usage
* ```js
* import {Sim} from 'ionic-native';
*
*
* Sim.getSimInfo().then(
* (info) => console.log('Sim info:', info),
* (err) => console.log('Unable to get sim info:', err)
* );
* ```
*/
@Plugin({
plugin: 'cordova-plugin-sim',
pluginRef: 'plugins.sim',
repo: 'https://github.com/pbakondy/cordova-plugin-sim',
platforms: ['Android', 'iOS', 'Windows Phone']
})
export class Sim {
/**
* Returns info from the SIM card.
* @returns {Promise}
*/
@Cordova()
static getSimInfo(): Promise<any> { return; }
}

View File

@ -28,10 +28,8 @@ export class SocialSharing {
* @param file {string|Array<string>} URL(s) to file(s) or image(s), local path(s) to file(s) or image(s), or base64 data of an image. Only the first file/image will be used on Windows Phone.
* @param url {string} A URL to share
*/
@Cordova({
sync: true
})
static share (message?: string, subject?: string, file?: string|Array<string>, url?: string): void {}
@Cordova()
static share (message?: string, subject?: string, file?: string|Array<string>, url?: string): Promise<any> {return; }
/**
* Shares using the share sheet with additional options and returns a result object or an error message (requires plugin version 5.1.0+)
@ -58,10 +56,9 @@ export class SocialSharing {
* @param url
*/
@Cordova({
sync: true,
platforms: ['iOS', 'Android']
})
static shareViaTwitter (message: string, image?: string, url?: string): void {}
static shareViaTwitter (message: string, image?: string, url?: string): Promise<any> {return; }
/**
* Shares directly to Facebook

View File

@ -27,7 +27,7 @@ export class SpinnerDialog {
* Shows the spinner dialog
* @param title {string} Spinner title (shows on Android only)
* @param message {string} Spinner message
* @param cancelCallback {boolean|function} Set to false to set spinner not cancelable. Or provide a function to call when the user cancels the spinner.
* @param cancelCallback {boolean|function} Set to true to set spinner not cancelable. Or provide a function to call when the user cancels the spinner.
* @param iOSOptions {object} Options for iOS only
*/
@Cordova({
@ -50,4 +50,4 @@ export interface SpinnerDialogIOSOptions {
textColorRed?: number;
textColorGreen?: number;
textColorBlue?: number;
}
}

View File

@ -53,7 +53,7 @@ export class SQLite {
* import { SQLite } from 'ionic-native';
*
* let db = new SQLite();
* db.openDatabse({
* db.openDatabase({
* name: 'data.db',
* location: 'default' // the location field is required
* }).then(() => {

View File

@ -53,7 +53,7 @@ export class TouchID {
* @return {Promise} Returns a Promise that resolves if yes, rejects if no.
*/
@Cordova()
isAvailable(): Promise<any> { return; }
static isAvailable(): Promise<any> { return; }
/**
* Show TouchID dialog and wait for a fingerprint scan. If user taps 'Enter Password' button, brings up standard system passcode screen.