Compare commits

...

49 Commits

Author SHA1 Message Date
Ibby
78fcdc8d80 chore(): update changelog 2017-02-07 11:32:53 -05:00
Ibby
53f7056b16 2.5.1 2017-02-07 11:32:28 -05:00
Ibby
b7701cdb16 fix(pin-dialog): add missing errorIndex 2017-02-07 10:19:32 -05:00
Ibby
94a4519f2b chore(): update changelog 2017-02-07 07:27:35 -05:00
Ibby
6fe52b610b 2.5.0 2017-02-07 07:27:16 -05:00
Ibby Hadeed
434a6c8ad3 Update stepcounter.ts 2017-02-06 08:33:10 -05:00
Tom Sundstrom
97489ba573 feat(barcodescanner): add option disableSuccessBeep (#1035)
https://github.com/phonegap/phonegap-plugin-barcodescanner/pull/408
2017-02-05 05:41:49 -05:00
Ibby Hadeed
f525a25b49 refractor(google-maps): use Observable.fromEvent instead of addEventListener (#1032) 2017-02-04 04:32:41 -05:00
Ibby
add49e8b4d refractor(): use Observable.fromEvent in wrapEventObservable 2017-02-04 04:16:57 -05:00
Eds
4ab87d8abb feat(inappbrowser): add hide function (#1018) 2017-02-01 01:42:07 -05:00
Prateek Kathal
69ff7afb48 docs(file): add link to additional information (#1022)
Adding a link to **cordova plugin file** for ease of understanding file management using cordova.

It took me almost a day to figure out how to properly save things like a pdf/image in a publicly accessible directory. Having a link to the main **cordova file** documentation will save a lot of time.
2017-02-01 01:40:55 -05:00
Ibby
62a30c7d8f Merge branch 'master' of github.com:driftyco/ionic-native 2017-01-31 04:14:40 -05:00
Ibby
dc37d8f71c fix(safari-view-controller): fix issue caused by calling show without options 2017-01-31 04:14:28 -05:00
Huan LI
8864d1360a docs(streaming-media): add missing method name (#1016) 2017-01-31 01:39:21 -05:00
Ibby
613141998a docs(header-color): fix doc name 2017-01-30 11:45:36 -05:00
Ibby
c2fbb4fb64 docs(geolocation): update watchPosition example 2017-01-30 11:43:58 -05:00
Josh Strange
f0cf86076c feat(background-geolocation): add missing properties for Android 2017-01-30 05:45:42 -05:00
Ibby
a03afcf0fa fix(pinterest): fix PinterestPin interface 2017-01-29 06:49:28 -05:00
Ibby
3abe0bb97d Merge branch 'master' of github.com:driftyco/ionic-native 2017-01-26 20:30:51 -05:00
Ibby
a5b4632ceb fix(file-transfer): fix return type of upload method
fixes #1002
2017-01-26 20:30:44 -05:00
Ibby Hadeed
1c78f77c0f docs(stepcounter): update repo and plugin
closes #1003
2017-01-25 22:22:05 -05:00
Ibby
cb7d3ef3e0 chore(): update changelog 2017-01-24 15:14:36 -05:00
Ibby
5e83a09056 2.4.1 2017-01-24 15:14:07 -05:00
Ibby
b85393de89 chore(): add CordovaOptions interface 2017-01-24 15:12:35 -05:00
Ibby
68c535fd79 style(): missing semicolon 2017-01-24 15:00:43 -05:00
Ibby
1c09ee1fbc fix(screen-orientation): lockOrientation returns a promise
closes #939
2017-01-24 15:00:20 -05:00
Ibby
8b921165bb fix merge conflict 2017-01-24 00:49:14 -05:00
Ibby
0c837de499 chore(): update changelog 2017-01-24 00:48:42 -05:00
Ibby
a44500d206 2.4.0 2017-01-24 00:48:07 -05:00
Ibby
e063613c8c 2.3.3 2017-01-24 00:46:51 -05:00
Ibby
416071a5a1 fix(google-maps): fix event listeners
fixes #999
2017-01-24 00:46:37 -05:00
Ibby
93fdb7eabb fix typo 2017-01-23 23:00:56 -05:00
Ibby
466437a683 feat(pinterest): add pinterest plugin 2017-01-23 22:59:37 -05:00
Ibby
a34723b53c legal name change 2017-01-23 22:22:19 -05:00
Ibby
b9bd5100a2 chore(): update changelog 2017-01-23 22:20:09 -05:00
Ibby
51bafccf38 2.3.2 2017-01-23 22:19:48 -05:00
Ibby
c3127d35bb fix(googlemaps): fix GoogleMapsLaLngBounds
closes #972
2017-01-23 22:02:31 -05:00
Ibby
1322c1b089 test(): fix test plugin meta 2017-01-22 17:37:04 -05:00
Ibby
9bf7895386 chore(): update changelog 2017-01-22 17:34:13 -05:00
Ibby
538dcb98eb 2.3.1 2017-01-22 17:33:59 -05:00
Ibby
3da0efe38e fix(battery-status): add missing pluginRef 2017-01-22 17:27:52 -05:00
Ibby
b983de2145 feat(core): add PluginConfig interface
closes #996
2017-01-22 17:24:43 -05:00
Guille
9f98f8ef46 feat(google-maps): add base class functions (#993) 2017-01-22 17:17:13 -05:00
Ibby
3e2964b385 Merge branch 'master' of github.com:driftyco/ionic-native 2017-01-22 17:13:59 -05:00
Guille
77ab2c21da refractor(): name to pluginName (#994) 2017-01-22 17:13:42 -05:00
guille
94025a7fd2 fix(plugin): adds subscribe() and unsubscribe() 2017-01-22 17:13:13 -05:00
guille
8c021bcaa0 fix(): add clearAllNotifications() 2017-01-22 17:13:13 -05:00
Ibby
da7a3707fa fix(core): fix plugin check 2017-01-22 17:12:24 -05:00
Peter Kelly
cb293639bc fix(core): fix exception in CordovaProperty (#998)
This reverts part of commit 67adb23, which moved the call to getPlugin()
from within CordovaProperty() to a point where it was called too early.

When the CordovaProperty decorator is called on a property, the class
containing that call has not yet had its Plugin decorator called. Only
when the latter happens does pluginRef get set. Thus, attempting to
access pluginRef within CordovaProperty at the time of the call will
give undefined, and attemping to call getPlugin with an undefined value
will throw an exception:

    Runtime Error
    Cannot read property 'split' of undefined

    TypeError: Cannot read property 'split' of undefined
        at get
        at getPlugin
        at CordovaProperty
        at __decorate
        ...

The above message can be seen in the browser after running the 'ionic
serve' command.

This commit moves the getPlugin call back to the getters and setters
established by CordovaProperty, which are only called *after* the Plugin
decorator has finished executing.

closes #992
2017-01-22 17:11:52 -05:00
24 changed files with 1265 additions and 55 deletions

View File

@@ -1,3 +1,92 @@
<a name="2.5.1"></a>
## [2.5.1](https://github.com/driftyco/ionic-native/compare/v2.5.0...v2.5.1) (2017-02-07)
### Bug Fixes
* **pin-dialog:** add missing errorIndex ([b7701cd](https://github.com/driftyco/ionic-native/commit/b7701cd))
<a name="2.5.0"></a>
# [2.5.0](https://github.com/driftyco/ionic-native/compare/v2.4.1...v2.5.0) (2017-02-07)
### Bug Fixes
* **file-transfer:** fix return type of upload method ([a5b4632](https://github.com/driftyco/ionic-native/commit/a5b4632)), closes [#1002](https://github.com/driftyco/ionic-native/issues/1002)
* **pinterest:** fix PinterestPin interface ([a03afcf](https://github.com/driftyco/ionic-native/commit/a03afcf))
* **safari-view-controller:** fix issue caused by calling show without options ([dc37d8f](https://github.com/driftyco/ionic-native/commit/dc37d8f))
### Features
* **background-geolocation:** add missing properties for Android ([f0cf860](https://github.com/driftyco/ionic-native/commit/f0cf860))
* **barcodescanner:** add option disableSuccessBeep ([#1035](https://github.com/driftyco/ionic-native/issues/1035)) ([97489ba](https://github.com/driftyco/ionic-native/commit/97489ba))
* **inappbrowser:** add hide function ([#1018](https://github.com/driftyco/ionic-native/issues/1018)) ([4ab87d8](https://github.com/driftyco/ionic-native/commit/4ab87d8))
<a name="2.4.1"></a>
## [2.4.1](https://github.com/driftyco/ionic-native/compare/v2.4.0...v2.4.1) (2017-01-24)
### Bug Fixes
* **screen-orientation:** lockOrientation returns a promise ([1c09ee1](https://github.com/driftyco/ionic-native/commit/1c09ee1)), closes [#939](https://github.com/driftyco/ionic-native/issues/939)
<a name="2.4.0"></a>
# [2.4.0](https://github.com/driftyco/ionic-native/compare/v2.3.3...v2.4.0) (2017-01-24)
<a name="2.3.3"></a>
## [2.3.3](https://github.com/driftyco/ionic-native/compare/v2.3.2...v2.3.3) (2017-01-24)
### Bug Fixes
* **google-maps:** fix event listeners ([416071a](https://github.com/driftyco/ionic-native/commit/416071a)), closes [#999](https://github.com/driftyco/ionic-native/issues/999)
### Features
* **pinterest:** add pinterest plugin ([466437a](https://github.com/driftyco/ionic-native/commit/466437a))
<a name="2.3.2"></a>
## [2.3.2](https://github.com/driftyco/ionic-native/compare/v2.3.1...v2.3.2) (2017-01-24)
### Bug Fixes
* **googlemaps:** fix GoogleMapsLaLngBounds ([c3127d3](https://github.com/driftyco/ionic-native/commit/c3127d3)), closes [#972](https://github.com/driftyco/ionic-native/issues/972)
<a name="2.3.1"></a>
## [2.3.1](https://github.com/driftyco/ionic-native/compare/v2.3.0...v2.3.1) (2017-01-22)
### Bug Fixes
* add clearAllNotifications() ([8c021bc](https://github.com/driftyco/ionic-native/commit/8c021bc))
* **battery-status:** add missing pluginRef ([3da0efe](https://github.com/driftyco/ionic-native/commit/3da0efe))
* **core:** fix exception in CordovaProperty ([#998](https://github.com/driftyco/ionic-native/issues/998)) ([cb29363](https://github.com/driftyco/ionic-native/commit/cb29363)), closes [#992](https://github.com/driftyco/ionic-native/issues/992)
* **core:** fix plugin check ([da7a370](https://github.com/driftyco/ionic-native/commit/da7a370))
* **plugin:** adds subscribe() and unsubscribe() ([94025a7](https://github.com/driftyco/ionic-native/commit/94025a7))
### Features
* **core:** add PluginConfig interface ([b983de2](https://github.com/driftyco/ionic-native/commit/b983de2)), closes [#996](https://github.com/driftyco/ionic-native/issues/996)
* **google-maps:** add base class functions ([#993](https://github.com/driftyco/ionic-native/issues/993)) ([9f98f8e](https://github.com/driftyco/ionic-native/commit/9f98f8e))
<a name="2.3.0"></a>
# [2.3.0](https://github.com/driftyco/ionic-native/compare/v2.2.17...v2.3.0) (2017-01-20)

View File

@@ -86,7 +86,7 @@ Let us know or submit a PR! Take a look at [the Developer Guide](https://github.
# Credits
Ibrahim Hadeed - [@ihadeed](http://github.com/ihadeed)
Ibby Hadeed - [@ihadeed](http://github.com/ihadeed)
Tim Lancina - [@timlancina](http://twitter.com/timlancina)

View File

@@ -1,6 +1,6 @@
{
"name": "ionic-native",
"version": "2.3.0",
"version": "2.5.1",
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
"main": "dist/es5/index.js",
"module": "dist/esm/index.js",

View File

@@ -91,6 +91,7 @@ import { PhotoViewer } from './plugins/photo-viewer';
import { ScreenOrientation } from './plugins/screen-orientation';
import { PayPal } from './plugins/pay-pal';
import { PinDialog } from './plugins/pin-dialog';
import { Pinterest } from './plugins/pinterest';
import { PowerManagement } from './plugins/power-management';
import { Printer } from './plugins/printer';
import { Push } from './plugins/push';
@@ -211,6 +212,7 @@ export * from './plugins/onesignal';
export * from './plugins/pay-pal';
export * from './plugins/photo-viewer';
export * from './plugins/pin-dialog';
export * from './plugins/pinterest';
export * from './plugins/plugin';
export * from './plugins/power-management';
export * from './plugins/printer';
@@ -336,6 +338,7 @@ window['IonicNative'] = {
PhotoViewer,
ScreenOrientation,
PinDialog,
Pinterest,
PowerManagement,
Rollbar,
SafariViewController,

View File

@@ -126,10 +126,14 @@ export interface BackgroundGeolocationConfig {
/**
* ANDROID, WP8 ONLY
* The minimum time interval between location updates in seconds.
* When using BackgroundGeolocation.LocationProvider.ANDROID_DISTANCE_FILTER_PROVIDER:
* The minimum time interval between location updates in milliseconds.
* @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
* When using BackgroundGeolocation.LocationProvider.ANDROID_ACTIVITY_PROVIDER:
* Rate in milliseconds at which your app prefers to receive location updates.
* @see Android docs (https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#getInterval())
*/
interval?: number;
@@ -225,6 +229,28 @@ export interface BackgroundGeolocationConfig {
* Defaults to 10000
*/
maxLocations?: number;
/**
* ANDROID ONLY with BackgroundGeolocation.LocationProvider.ANDROID_ACTIVITY_PROVIDER
*
* Fastest rate in milliseconds at which your app can handle location updates.
* @see Android docs (https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html#getFastestInterval())
*/
fastestInterval?: number;
/**
* ANDROID ONLY with BackgroundGeolocation.LocationProvider.ANDROID_ACTIVITY_PROVIDER
*
* Rate in milliseconds at which activity recognition occurs. Larger values will result in fewer activity detections while improving battery life.
*/
activitiesInterval?: number;
/**
* ANDROID ONLY with BackgroundGeolocation.LocationProvider.ANDROID_ACTIVITY_PROVIDER
*
* stop() is forced, when the STILL activity is detected (default is true)
*/
stopOnStillActivity?: boolean;
}
/**

View File

@@ -22,6 +22,11 @@ export interface BarcodeScannerOptions {
*/
disableAnimations?: boolean;
/**
* Disable success beep. Supported on iOS only.
*/
disableSuccessBeep?: boolean;
/**
* Prompt text. Supported on Android only.
*/

View File

@@ -42,6 +42,7 @@ export interface BatteryStatusResponse {
@Plugin({
pluginName: 'BatteryStatus',
plugin: 'cordova-plugin-battery-status',
pluginRef: 'navigator.battery',
repo: 'https://github.com/apache/cordova-plugin-battery-status',
platforms: ['Amazon Fire OS', 'iOS', 'Android', 'BlackBerry 10', 'Windows Phone 7', 'Windows Phone 8', 'Windows', 'Firefox OS', 'Browser']
})

View File

@@ -173,6 +173,10 @@ export interface FileTransferError {
* cd files
* ls
* ```
*
* To store files in a different/publicly accessible directory, please refer to the following link
* https://github.com/apache/cordova-plugin-file#where-to-store-files
*
* @interfaces
* FileUploadOptions
* FileUploadResult
@@ -223,7 +227,7 @@ export class Transfer {
successIndex: 2,
errorIndex: 3
})
upload(fileUrl: string, url: string, options?: FileUploadOptions, trustAllHosts?: boolean): Promise<FileUploadResult | FileTransferError> {
upload(fileUrl: string, url: string, options?: FileUploadOptions, trustAllHosts?: boolean): Promise<FileUploadResult> {
return;
}

View File

@@ -167,7 +167,7 @@ export class Geolocation {
*
* ```typescript
* var subscription = Geolocation.watchPosition()
* .filter((p) => p.code === undefined) //Filter Out Errors
* .filter((p) => p.coords !== undefined) //Filter Out Errors
* .subscribe(position => {
* console.log(position.coords.longitude + ' ' + position.coords.latitude);
* });

View File

@@ -1,5 +1,6 @@
import { Cordova, CordovaInstance, Plugin, InstanceProperty, getPlugin, pluginWarn } from './plugin';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromEvent';
declare var plugin: any;
@@ -119,7 +120,7 @@ export class GoogleMap {
@Cordova()
static isAvailable(): Promise<boolean> { return; }
constructor(element: string|HTMLElement, options?: any) {
constructor(element: string | HTMLElement, options?: any) {
if (!!getPlugin('plugin.google.maps.Map')) {
if (typeof element === 'string') {
element = document.getElementById(<string>element);
@@ -133,12 +134,50 @@ export class GoogleMap {
}
}
/**
* Adds an event listener.
*
* @returns {Observable<any>}
*/
addEventListener(eventName: string): Observable<any> {
return Observable.fromEvent(this._objectInstance, eventName);
}
/**
* Adds an event listener that works once.
*
* @returns {Promise<any>}
*/
addListenerOnce(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.addListenerOnce(eventName, resolve)
);
}
/**
* Gets a value
* @param key
*/
@CordovaInstance({ sync: true })
get(key: string): any { return; }
/**
* Sets a value
* @param key
* @param value
*/
@CordovaInstance({ sync: true })
set(key: string, value: any): void { }
/**
* Listen to a map event.
*
* @returns {Observable<any>}
*/
on(event: any): Observable<any> {
on(eventName: string): Observable<any> {
if (!this._objectInstance) {
return new Observable((observer) => {
observer.error({ error: 'plugin_not_installed' });
@@ -147,7 +186,7 @@ export class GoogleMap {
return new Observable(
(observer) => {
this._objectInstance.on(event, observer.next.bind(observer));
this._objectInstance.on(eventName, observer.next.bind(observer));
return () => this._objectInstance.off(event);
}
);
@@ -158,15 +197,21 @@ export class GoogleMap {
*
* @returns {Promise<any>}
*/
one(event: any): Promise<any> {
one(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.one(event, resolve)
resolve => this._objectInstance.one(eventName, resolve)
);
}
/**
* Clears all stored values
*/
@CordovaInstance({ sync: true })
empty(): void { }
@CordovaInstance({ sync: true })
setDebuggable(isDebuggable: boolean): void { }
@@ -576,12 +621,26 @@ export class GoogleMapsMarker {
constructor(private _objectInstance: any) { }
addEventListener(event: any): Observable<any> {
return new Observable(
(observer) => {
this._objectInstance.addEventListener(event, observer.next.bind(observer));
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
}
/**
* Adds an event listener.
*
* @returns {Observable<any>}
*/
addEventListener(eventName: string): Observable<any> {
return Observable.fromEvent(this._objectInstance, eventName);
}
/**
* Adds an event listener that works once.
*
* @returns {Promise<any>}
*/
addListenerOnce(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.addListenerOnce(eventName, resolve)
);
}
@@ -589,7 +648,7 @@ export class GoogleMapsMarker {
* Gets a value
* @param key
*/
@CordovaInstance({sync: true})
@CordovaInstance({ sync: true })
get(key: string): any { return; }
/**
@@ -597,9 +656,49 @@ export class GoogleMapsMarker {
* @param key
* @param value
*/
@CordovaInstance({sync: true})
@CordovaInstance({ sync: true })
set(key: string, value: any): void { }
/**
* Listen to a map event.
*
* @returns {Observable<any>}
*/
on(eventName: string): Observable<any> {
if (!this._objectInstance) {
return new Observable((observer) => {
observer.error({ error: 'plugin_not_installed' });
});
}
return new Observable(
(observer) => {
this._objectInstance.on(eventName, observer.next.bind(observer));
return () => this._objectInstance.off(event);
}
);
}
/**
* Listen to a map event only once.
*
* @returns {Promise<any>}
*/
one(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.one(eventName, resolve)
);
}
/**
* Clears all stored values
*/
@CordovaInstance({ sync: true })
empty(): void { }
/**
* Return true if the marker is visible
*/
@@ -797,15 +896,84 @@ export class GoogleMapsCircle {
constructor(private _objectInstance: any) { }
addEventListener(event: any): Observable<any> {
/**
* Adds an event listener.
*
* @returns {Observable<any>}
*/
addEventListener(eventName: string): Observable<any> {
return Observable.fromEvent(this._objectInstance, eventName);
}
/**
* Adds an event listener that works once.
*
* @returns {Promise<any>}
*/
addListenerOnce(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.addListenerOnce(eventName, resolve)
);
}
/**
* Gets a value
* @param key
*/
@CordovaInstance({ sync: true })
get(key: string): any { return; }
/**
* Sets a value
* @param key
* @param value
*/
@CordovaInstance({ sync: true })
set(key: string, value: any): void { }
/**
* Listen to a map event.
*
* @returns {Observable<any>}
*/
on(eventName: string): Observable<any> {
if (!this._objectInstance) {
return new Observable((observer) => {
observer.error({ error: 'plugin_not_installed' });
});
}
return new Observable(
(observer) => {
this._objectInstance.addEventListener(event, observer.next.bind(observer));
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
this._objectInstance.on(eventName, observer.next.bind(observer));
return () => this._objectInstance.off(event);
}
);
}
/**
* Listen to a map event only once.
*
* @returns {Promise<any>}
*/
one(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.one(eventName, resolve)
);
}
/**
* Clears all stored values
*/
@CordovaInstance({ sync: true })
empty(): void { }
@CordovaInstance({ sync: true })
getCenter(): GoogleMapsLatLng { return; }
@@ -867,15 +1035,84 @@ export interface GoogleMapsPolylineOptions {
export class GoogleMapsPolyline {
constructor(private _objectInstance: any) { }
addEventListener(event: any): Observable<any> {
/**
* Adds an event listener.
*
* @returns {Observable<any>}
*/
addEventListener(eventName: string): Observable<any> {
return Observable.fromEvent(this._objectInstance, eventName);
}
/**
* Adds an event listener that works once.
*
* @returns {Promise<any>}
*/
addListenerOnce(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.addListenerOnce(eventName, resolve)
);
}
/**
* Gets a value
* @param key
*/
@CordovaInstance({ sync: true })
get(key: string): any { return; }
/**
* Sets a value
* @param key
* @param value
*/
@CordovaInstance({ sync: true })
set(key: string, value: any): void { }
/**
* Listen to a map event.
*
* @returns {Observable<any>}
*/
on(eventName: string): Observable<any> {
if (!this._objectInstance) {
return new Observable((observer) => {
observer.error({ error: 'plugin_not_installed' });
});
}
return new Observable(
(observer) => {
this._objectInstance.addEventListener(event, observer.next.bind(observer));
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
this._objectInstance.on(eventName, observer.next.bind(observer));
return () => this._objectInstance.off(event);
}
);
}
/**
* Listen to a map event only once.
*
* @returns {Promise<any>}
*/
one(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.one(eventName, resolve)
);
}
/**
* Clears all stored values
*/
@CordovaInstance({ sync: true })
empty(): void { }
@CordovaInstance({ sync: true })
getPoints(): Array<GoogleMapsLatLng> { return; }
@@ -938,15 +1175,84 @@ export class GoogleMapsPolygon {
constructor(private _objectInstance: any) { }
addEventListener(event: any): Observable<any> {
/**
* Adds an event listener.
*
* @returns {Observable<any>}
*/
addEventListener(eventName: string): Observable<any> {
return Observable.fromEvent(this._objectInstance, eventName);
}
/**
* Adds an event listener that works once.
*
* @returns {Promise<any>}
*/
addListenerOnce(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.addListenerOnce(eventName, resolve)
);
}
/**
* Gets a value
* @param key
*/
@CordovaInstance({ sync: true })
get(key: string): any { return; }
/**
* Sets a value
* @param key
* @param value
*/
@CordovaInstance({ sync: true })
set(key: string, value: any): void { }
/**
* Listen to a map event.
*
* @returns {Observable<any>}
*/
on(eventName: string): Observable<any> {
if (!this._objectInstance) {
return new Observable((observer) => {
observer.error({ error: 'plugin_not_installed' });
});
}
return new Observable(
(observer) => {
this._objectInstance.addEventListener(event, observer.next.bind(observer));
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
this._objectInstance.on(eventName, observer.next.bind(observer));
return () => this._objectInstance.off(event);
}
);
}
/**
* Listen to a map event only once.
*
* @returns {Promise<any>}
*/
one(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.one(eventName, resolve)
);
}
/**
* Clears all stored values
*/
@CordovaInstance({ sync: true })
empty(): void { }
@CordovaInstance({ sync: true })
getPoints(): Array<GoogleMapsLatLng> { return; }
@@ -1011,6 +1317,84 @@ export class GoogleMapsTileOverlay {
constructor(private _objectInstance: any) { }
/**
* Adds an event listener.
*
* @returns {Observable<any>}
*/
addEventListener(eventName: string): Observable<any> {
return Observable.fromEvent(this._objectInstance, eventName);
}
/**
* Adds an event listener that works once.
*
* @returns {Promise<any>}
*/
addListenerOnce(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.addListenerOnce(eventName, resolve)
);
}
/**
* Gets a value
* @param key
*/
@CordovaInstance({ sync: true })
get(key: string): any { return; }
/**
* Sets a value
* @param key
* @param value
*/
@CordovaInstance({ sync: true })
set(key: string, value: any): void { }
/**
* Listen to a map event.
*
* @returns {Observable<any>}
*/
on(eventName: string): Observable<any> {
if (!this._objectInstance) {
return new Observable((observer) => {
observer.error({ error: 'plugin_not_installed' });
});
}
return new Observable(
(observer) => {
this._objectInstance.on(eventName, observer.next.bind(observer));
return () => this._objectInstance.off(event);
}
);
}
/**
* Listen to a map event only once.
*
* @returns {Promise<any>}
*/
one(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.one(eventName, resolve)
);
}
/**
* Clears all stored values
*/
@CordovaInstance({ sync: true })
empty(): void { }
@CordovaInstance({ sync: true })
getVisible(): boolean { return; }
@@ -1062,6 +1446,84 @@ export class GoogleMapsGroundOverlay {
constructor(private _objectInstance: any) { }
/**
* Adds an event listener.
*
* @returns {Observable<any>}
*/
addEventListener(eventName: string): Observable<any> {
return Observable.fromEvent(this._objectInstance, eventName);
}
/**
* Adds an event listener that works once.
*
* @returns {Promise<any>}
*/
addListenerOnce(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.addListenerOnce(eventName, resolve)
);
}
/**
* Gets a value
* @param key
*/
@CordovaInstance({ sync: true })
get(key: string): any { return; }
/**
* Sets a value
* @param key
* @param value
*/
@CordovaInstance({ sync: true })
set(key: string, value: any): void { }
/**
* Listen to a map event.
*
* @returns {Observable<any>}
*/
on(eventName: string): Observable<any> {
if (!this._objectInstance) {
return new Observable((observer) => {
observer.error({ error: 'plugin_not_installed' });
});
}
return new Observable(
(observer) => {
this._objectInstance.on(eventName, observer.next.bind(observer));
return () => this._objectInstance.off(event);
}
);
}
/**
* Listen to a map event only once.
*
* @returns {Promise<any>}
*/
one(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.one(eventName, resolve)
);
}
/**
* Clears all stored values
*/
@CordovaInstance({ sync: true })
empty(): void { }
@CordovaInstance({ sync: true })
setBearing(bearing: number): void { }
@@ -1104,6 +1566,84 @@ export class GoogleMapsKmlOverlay {
constructor(private _objectInstance: any) { }
/**
* Adds an event listener.
*
* @returns {Observable<any>}
*/
addEventListener(eventName: string): Observable<any> {
return Observable.fromEvent(this._objectInstance, eventName);
}
/**
* Adds an event listener that works once.
*
* @returns {Promise<any>}
*/
addListenerOnce(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.addListenerOnce(eventName, resolve)
);
}
/**
* Gets a value
* @param key
*/
@CordovaInstance({ sync: true })
get(key: string): any { return; }
/**
* Sets a value
* @param key
* @param value
*/
@CordovaInstance({ sync: true })
set(key: string, value: any): void { }
/**
* Listen to a map event.
*
* @returns {Observable<any>}
*/
on(eventName: string): Observable<any> {
if (!this._objectInstance) {
return new Observable((observer) => {
observer.error({ error: 'plugin_not_installed' });
});
}
return new Observable(
(observer) => {
this._objectInstance.on(eventName, observer.next.bind(observer));
return () => this._objectInstance.off(event);
}
);
}
/**
* Listen to a map event only once.
*
* @returns {Promise<any>}
*/
one(eventName: string): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.one(eventName, resolve)
);
}
/**
* Clears all stored values
*/
@CordovaInstance({ sync: true })
empty(): void { }
@CordovaInstance({ sync: true })
remove(): void { }
@@ -1117,9 +1657,9 @@ export class GoogleMapsKmlOverlay {
export class GoogleMapsLatLngBounds {
private _objectInstance: any;
@InstanceProperty get northeast(): GoogleMapsLatLng { return; }
@InstanceProperty get southwest(): GoogleMapsLatLng { return; }
@InstanceProperty get type(): string { return; }
@InstanceProperty northeast: GoogleMapsLatLng;
@InstanceProperty southwest: GoogleMapsLatLng;
@InstanceProperty type: string;
constructor(southwestOrArrayOfLatLng: GoogleMapsLatLng | GoogleMapsLatLng[], northeast?: GoogleMapsLatLng) {
let args = !!northeast ? [southwestOrArrayOfLatLng, northeast] : southwestOrArrayOfLatLng;

View File

@@ -1,7 +1,7 @@
import { Plugin, Cordova } from './plugin';
/**
* @name Headerolor
* @name HeaderColor
* @description
* Cordova plugin to change color of header in multitask view
*
@@ -13,7 +13,7 @@ import { Plugin, Cordova } from './plugin';
* ```
*/
@Plugin({
name: 'HeaderColor',
pluginName: 'HeaderColor',
plugin: 'cordova-plugin-headercolor',
pluginRef: 'plugins.headerColor',
repo: 'https://github.com/tomloprod/cordova-plugin-headercolor',

View File

@@ -72,6 +72,13 @@ export class InAppBrowser {
@CordovaInstance({sync: true})
close(): void { }
/**
* Hides an InAppBrowser window that is currently shown. Calling this has no effect
* if the InAppBrowser was already hidden.
*/
@CordovaInstance({sync: true})
hide(): void { }
/**
* Injects JavaScript code into the InAppBrowser window.
* @param script {Object} Details of the script to run, specifying either a file or code key.

View File

@@ -23,7 +23,7 @@ import { Plugin, Cordova } from './plugin';
* NativeGeocoderForwardResult
*/
@Plugin({
name: 'NativeGeocoder',
pluginName: 'NativeGeocoder',
plugin: 'cordova-plugin-nativegeocoder',
pluginRef: 'nativegeocoder',
repo: 'https://github.com/sebastianbaar/cordova-plugin-nativegeocoder',

View File

@@ -16,7 +16,7 @@ import { Cordova, Plugin } from './plugin';
* ```
*/
@Plugin({
name: 'NavigationBar',
pluginName: 'NavigationBar',
plugin: 'cordova-plugin-navigationbar',
pluginRef: 'navigationbar',
repo: 'https://github.com/cranberrygame/cordova-plugin-navigationbar',

View File

@@ -34,7 +34,8 @@ export class PinDialog {
* @returns {Promise<{ buttonIndex: number, input1: string }>}
*/
@Cordova({
successIndex: 1
successIndex: 1,
errorIndex: 4 // no error callback
})
static prompt(message: string, title: string, buttons: string[]): Promise<{ buttonIndex: number, input1: string }> { return; }

361
src/plugins/pinterest.ts Normal file
View File

@@ -0,0 +1,361 @@
import { Plugin, Cordova, CordovaProperty } from './plugin';
export interface PinterestUser {
/**
* The unique string of numbers and letters that identifies the user on Pinterest.
*/
id?: string;
/**
* The users Pinterest username.
*/
username?: string;
/**
* The users first name.
*/
first_name?: string;
/**
* The users last name.
*/
last_name?: string;
/**
* The text in the users “About you” section in their profile.
*/
bio?: string;
/**
* The date the user created their account in ISO 8601 format
*/
created_at?: string;
/**
* The users stats, including how many Pins, follows, boards and likes they have.
*/
counts?: any;
/**
* The users profile image. The response returns the images URL, width and height.
*/
image?: any;
}
export interface PinterestBoard {
/**
* The unique string of numbers and letters that identifies the board on Pinterest.
*/
id?: string;
/**
* The name of the board.
*/
name?: string;
/**
* The link to the board.
*/
url?: string;
/**
* The user-entered description of the board.
*/
description?: string;
/**
* The first and last name, ID and profile URL of the user who created the board.
*/
creator?: PinterestUser;
/**
* The date the user created the board.
*/
created_at?: string;
/**
* The boards stats, including how many Pins, followers, user's following and collaborators it has.
*/
counts?: any;
/**
* The users profile image. The response returns the images URL, width and height.
*/
image?: any;
}
export interface PinterestPin {
/**
* The unique string of numbers and letters that identifies the Pin on Pinterest.
*/
id?: string;
/**
* The URL of the webpage where the Pin was created.
*/
link?: string;
/**
* The URL of the Pin on Pinterest.
*/
url?: string;
/**
* The first and last name, ID and profile URL of the user who created the board.
*/
creator?: PinterestUser;
/**
* The board that the Pin is on.
*/
board?: PinterestBoard;
/**
* The date the Pin was created.
*/
created_at?: string;
/**
* The user-entered description of the Pin.
*/
note?: string;
/**
* The dominant color of the Pins image in hex code format.
*/
color?: string;
/**
* The Pins stats, including the number of repins, comments and likes.
*/
counts?: any;
/**
* The media type of the Pin (image or video).
*/
media?: any;
/**
* The source data for videos, including the title, URL, provider, author name, author URL and provider name.
*/
attribution?: any;
/**
* The Pins image. The default response returns the images URL, width and height.
*/
image?: any;
/**
* Extra information about the Pin for Rich Pins. Includes the Pin type (e.g., article, recipe) and related information (e.g., ingredients, author).
*/
metadata?: any;
}
/**
* @beta
* @name Pinterest
* @description
* Cordova plugin for Pinterest
*
* @usage
* ```
* import { Pinterest, PinterestUser, PinterestPin, PinterestBoard } from 'ionic-native';
*
* const scopes = [
* Pinterest.SCOPES.READ_PUBLIC,
* Pinterest.SCOPES.WRITE_PUBLIC,
* Pinterest.SCOPES.READ_RELATIONSHIPS,
* Pinterest.SCOPES.WRITE_RELATIONSHIPS
* ];
*
* Pinterest.login(scopes)
* .then(res => console.log('Logged in!', res))
* .catch(err => console.error('Error loggin in', err));
*
* Pinterest.getMyPins()
* .then((pins: Array<PinterestPin>) => console.log(pins))
* .catch(err => console.error(err));
*
* Pinterest.getMe()
* .then((user: PinterestUser) => console.log(user));
*
* Pinterest.getMyBoards()
* .then((boards: Array<PinterestBoard>) => console.log(boards));
*
* ```
* @interfaces
* PinterestUser
* PinterestBoard
* PinterestPin
*/
@Plugin({
pluginName: 'Pinterest',
plugin: 'cordova-plugin-pinterest',
pluginRef: 'cordova.plugins.Pinterest',
repo: 'https://github.com/zyramedia/cordova-plugin-pinterest',
install: 'ionic plugin add cordova-plugin-pinterest --variable APP_ID=YOUR_APP_ID',
platforms: ['Android', 'iOS']
})
export class Pinterest {
/**
* Convenience constant for authentication scopes
*/
@CordovaProperty
SCOPES: {
READ_PUBLIC: string;
WRITE_PUBLIC: string;
READ_RELATIONSHIPS: string;
WRITE_RELATIONSHIPS: string;
};
/**
* Logs the user in using their Pinterest account.
* @param scopes {Array<string>} Array of scopes that you need access to. You can use Pinterest.SCOPES constant for convenience.
* @returns {Promise<any>} The response object will contain the user's profile data, as well as the access token (if you need to use it elsewhere, example: send it to your server and perform actions on behalf of the user).
*/
@Cordova()
static login(scopes: string[]): Promise<any> { return; }
/**
* Gets the authenticated user's profile
* @param fields {string} Fields to retrieve, separated by commas. Defaults to all available fields.
* @returns {Promise<PinterestUser>} Returns a promise that resolves with the user's object
*/
@Cordova({
callbackOrder: 'reverse'
})
static getMe(fields?: string): Promise<PinterestUser> { return; }
/**
*
* @param fields {string} Optional fields separated by comma
* @param limit {number} Optional limit, defaults to 100, maximum is 100.
* @returns {Promise<Array<PinterestPin>>}
*/
@Cordova({
callbackOrder: 'reverse'
})
static getMyPins(fields?: string, limit?: number): Promise<Array<PinterestPin>> { return; }
/**
*
* @param fields {string} Optional fields separated by comma
* @param limit {number} Optional limit, defaults to 100, maximum is 100.
* @returns {Promise<Array<PinterestBoard>>}
*/
@Cordova({
callbackOrder: 'reverse'
})
static getMyBoards(fields?: string, limit?: number): Promise<Array<PinterestBoard>> { return; }
/**
* Get the authenticated user's likes.
* @param fields {string} Optional fields separated by comma
* @param limit {number} Optional limit, defaults to 100, maximum is 100.
* @returns {Promise<Array<PinterestPin>>}
*/
@Cordova({
callbackOrder: 'reverse'
})
static getMyLikes(fields?: string, limit?: number): Promise<Array<PinterestPin>> { return; }
/**
* Get the authenticated user's followers.
* @param fields {string} Optional fields separated by comma
* @param limit {number} Optional limit, defaults to 100, maximum is 100.
* @returns {Promise<Array<PinterestUser>>}
*/
@Cordova({
callbackOrder: 'reverse'
})
static getMyFollowers(fields?: string, limit?: number): Promise<Array<PinterestUser>> { return; }
/**
* Get the authenticated user's followed boards.
* @param fields {string} Optional fields separated by comma
* @param limit {number} Optional limit, defaults to 100, maximum is 100.
* @returns {Promise<Array<PinterestBoard>>}
*/
@Cordova({
callbackOrder: 'reverse'
})
static getMyFollowedBoards(fields?: string, limit?: number): Promise<Array<PinterestBoard>> { return; }
/**
* Get the authenticated user's followed interests.
* @param fields {string} Optional fields separated by comma
* @param limit {number} Optional limit, defaults to 100, maximum is 100.
* @returns {Promise<any>}
*/
@Cordova({
callbackOrder: 'reverse'
})
static getMyFollowedInterests(fields?: string, limit?: number): Promise<any> { return; }
/**
* Get a user's profile.
* @param username
* @param fields
* @returns {Promise<PinterestUser>}
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
static getUser(username: string, fields?: string): Promise<PinterestUser> { return; }
/**
* Get a board's data.
* @param boardId
* @param fields
* @returns {Promise<PinterestBoard>}
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
static getBoard(boardId: string, fields?: string): Promise<PinterestBoard> { return; }
/**
* Get Pins of a specific board.
* @param boardId {string} The ID of the board
* @param fields {string} Optional fields separated by comma
* @param limit {number} Optional limit, defaults to 100, maximum is 100.
* @returns {Promise<Array<PinterestPin>>}
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
static getBoardPins(boardId: string, fields?: string, limit?: number): Promise<Array<PinterestPin>> { return; }
/**
* Delete a board.
* @param boardId {string} The ID of the board
* @returns {Promise<PinterestUser>}
*/
@Cordova()
static deleteBoard(boardId: string): Promise<any> { return; }
/**
* Create a new board for the authenticated user.
* @param name {string} Name of the board
* @param desc {string} Optional description of the board
* @returns {Promise<PinterestBoard>}
*/
@Cordova({
successIndex: 2,
errorIndex: 3
})
static createBoard(name: string, desc?: string): Promise<PinterestBoard> { return; }
/**
* Get a Pin by ID.
* @param pinId {string} The ID of the Pin
* @param fields {string} Optional fields separated by comma
* @returns {Promise<PinterestPin>}
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
static getPin(pinId: string, fields?: string): Promise<PinterestPin> { return; }
/**
* Deletes a pin
* @param pinId {string} The ID of the pin
* @returns {Promise<any>}
*/
@Cordova()
static deletePin(pinId: string): Promise<any> { return; }
/**
* Creates a Pin
* @param note {string} Note/Description of the pin
* @param boardId {string} Board ID to put the Pin under
* @param imageUrl {string} URL of the image to share
* @param link {string} Optional link to share
* @returns {Promise<PinterestPin>}
*/
@Cordova({
successIndex: 4,
errorIndex: 5
})
static createPin(note: string, boardId: string, imageUrl: string, link?: string): Promise<PinterestPin> { return; }
}

View File

@@ -1,9 +1,106 @@
import { get } from '../util';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/fromEvent';
declare var window;
declare var Promise;
/**
* @private
*/
export interface PluginConfig {
/**
* Plugin name, this should match the class name
*/
pluginName: string;
/**
* Plugin NPM package name
*/
plugin: string;
/**
* Plugin object reference
*/
pluginRef: string;
/**
* Github repository URL
*/
repo: string;
/**
* Custom install command
*/
install?: string;
/**
* Supported platforms
*/
platforms?: string[];
}
/**
* @private
*/
export interface CordovaOptions {
/**
* Set to true if the wrapped method is a sync function
*/
sync?: boolean;
/**
* Callback order. Set to reverse if the success/error callbacks are the first 2 arguments that the wrapped method takes.
*/
callbackOrder?: 'reverse';
/**
* Callback style
*/
callbackStyle?: 'node' | 'object';
/**
* Set a custom index for the success callback function. This doesn't work if callbackOrder or callbackStyle are set.
*/
successIndex?: number;
/**
* Set a custom index for the error callback function. This doesn't work if callbackOrder or callbackStyle are set.
*/
errorIndex?: number;
/**
* Success function property name. This must be set if callbackStyle is set to object.
*/
successName?: string;
/**
* Error function property name. This must be set if callbackStyle is set to object.
*/
errorName?: string;
/**
* Set to true to return an observable
*/
observable?: boolean;
/**
* If observable is set to true, this can be set to a different function name that will cancel the observable.
*/
clearFunction?: string;
/**
* This can be used if clearFunction is set. Set this to true to call the clearFunction with the same arguments used in the initial function.
*/
clearWithArgs?: boolean;
/**
* Creates an observable that wraps a global event. Replaces document.addEventListener
*/
eventObservable?: boolean;
/**
* Event name, this must be set if eventObservable is set to true
*/
event?: string;
/**
* Element to attach the event listener to, this is optional, defaults to `window`
*/
element?: any;
/**
* Set to true if the wrapped method returns a promise
*/
otherPromise?: boolean;
/**
* Supported platforms
*/
platforms?: string[];
}
/**
* @private
* @param pluginRef
@@ -245,14 +342,12 @@ function wrapInstance(pluginObj: any, methodName: string, opts: any = {}) {
/**
* Wrap the event with an observable
* @param event
* @param event even name
* @param element The element to attach the event listener to
* @returns {Observable}
*/
function wrapEventObservable(event: string): Observable<any> {
return new Observable(observer => {
window.addEventListener(event, observer.next.bind(observer), false);
return () => window.removeEventListener(event, observer.next.bind(observer), false);
});
function wrapEventObservable(event: string, element: any = window): Observable<any> {
return Observable.fromEvent(element, event);
}
/**
@@ -303,7 +398,7 @@ function overrideFunction(pluginObj: any, methodName: string, args: any[], opts:
* @param opts
* @returns {function(...[any]): (undefined|*|Observable|*|*)}
*/
export const wrap = function(pluginObj: any, methodName: string, opts: any = {}) {
export const wrap = function(pluginObj: any, methodName: string, opts: CordovaOptions = {}) {
return (...args) => {
if (opts.sync) {
// Sync doesn't wrap the plugin with a promise or observable, it returns the result as-is
@@ -311,7 +406,7 @@ export const wrap = function(pluginObj: any, methodName: string, opts: any = {})
} else if (opts.observable) {
return wrapObservable(pluginObj, methodName, args, opts);
} else if (opts.eventObservable && opts.event) {
return wrapEventObservable(opts.event);
return wrapEventObservable(opts.event, opts.element);
} else if (opts.otherPromise) {
return wrapOtherPromise(pluginObj, methodName, args, opts);
} else {
@@ -320,6 +415,7 @@ export const wrap = function(pluginObj: any, methodName: string, opts: any = {})
};
};
/**
* @private
*
@@ -339,7 +435,7 @@ export const wrap = function(pluginObj: any, methodName: string, opts: any = {})
* }
* ```
*/
export function Plugin(config) {
export function Plugin(config: PluginConfig) {
return function(cls) {
// Add these fields to the class
@@ -375,7 +471,7 @@ export function Plugin(config) {
* Wrap a stub function in a call to a Cordova plugin, checking if both Cordova
* and the required plugin are installed.
*/
export function Cordova(opts: any = {}) {
export function Cordova(opts: CordovaOptions = {}) {
return (target: Object, methodName: string, descriptor: TypedPropertyDescriptor<any>) => {
return {
value: function(...args: any[]) {
@@ -407,9 +503,9 @@ export function CordovaInstance(opts: any = {}) {
* Before calling the original method, ensure Cordova and the plugin are installed.
*/
export function CordovaProperty(target: any, key: string) {
const pluginInstance = getPlugin(target.pluginRef);
const exists = () => {
if (!pluginInstance || pluginInstance[key] === 'undefined') {
let pluginInstance = getPlugin(target.pluginRef);
if (!pluginInstance || typeof pluginInstance[key] === 'undefined') {
pluginWarn(target, key);
return false;
}
@@ -419,14 +515,14 @@ export function CordovaProperty(target: any, key: string) {
Object.defineProperty(target, key, {
get: () => {
if (exists()) {
return pluginInstance[key];
return getPlugin(target.pluginRef)[key];
} else {
return null;
}
},
set: (value) => {
if (exists()) {
pluginInstance[key] = value;
getPlugin(target.pluginRef)[key] = value;
}
}
});

View File

@@ -110,6 +110,25 @@ export interface PushNotification {
unregister(successHandler: () => any, errorHandler?: () => any): void;
/**
* The subscribe method is used when the application wants to subscribe a new topic to receive push notifications.
* @param {string} topic: Topic to subscribe to.
* @param successHandler
* @param errorHandler
*/
subscribe(topic: string, successHandler: () => any, errorHandler?: () => any): void;
/**
* The unsubscribe method is used when the application no longer wants to receive push notifications
* from a specific topic but continue to receive other push messages.
* @param {string} topic: Topic to subscribe to.
* @param successHandler
* @param errorHandler
*/
unsubscribe(topic: string, successHandler: () => any, errorHandler?: () => any): void;
/**
* iOS & android only
*
* Set the badge count visible when the app is not running
*
* The count is an integer indicating what number should show up in the badge.
@@ -121,6 +140,8 @@ export interface PushNotification {
*/
setApplicationIconBadgeNumber(successHandler: () => any, errorHandler: () => any, count?: number): void;
/**
* iOS only
*
* Get the current badge count visible when the app is not running
* successHandler gets called with an integer which is the current badge count
* @param successHandler
@@ -130,6 +151,7 @@ export interface PushNotification {
/**
* iOS only
*
* Tells the OS that you are done processing a background push notification.
* successHandler gets called when background push processing is successfully completed.
* @param successHandler
@@ -137,6 +159,16 @@ export interface PushNotification {
* @param id
*/
finish(successHandler: () => any, errorHandler: () => any, id?: string): void;
/**
* iOS & android only
*
* Tells the OS to clear all notifications from the Notification Center.
* successHandler gets called when the api successfully clears the notifications
* @param successHandler
* @param errorHandler
*/
clearAllNotifications(successHandler: () => any, errorHandler: () => any): void;
}
export interface IOSPushOptions {

View File

@@ -71,7 +71,10 @@ export class SafariViewController {
* @param options {SafariViewControllerOptions} optional
* @returns {Promise<any>}
*/
@Cordova()
@Cordova({
successIndex: 1,
errorIndex: 2
})
static show(options?: SafariViewControllerOptions): Promise<any> { return; }
/**

View File

@@ -49,9 +49,10 @@ export class ScreenOrientation {
* Lock the orientation to the passed value.
* See below for accepted values
* @param orientation {string} The orientation which should be locked. Accepted values see table below.
* @returns {Promise<any>} returns a promise that resolves when the screen orientation is locked, and rejects when an error occurs.
*/
@Cordova({ sync: true })
static lockOrientation(orientation: string): void { }
@Cordova({ otherPromise: true })
static lockOrientation(orientation: string): Promise<string> { return; }
/**
* Unlock and allow all orientations.

View File

@@ -21,9 +21,9 @@ import { Plugin, Cordova } from './plugin';
*/
@Plugin({
pluginName: 'Stepcounter',
plugin: 'https://github.com/texh/cordova-plugin-stepcounter',
plugin: 'https://github.com/Slidee/cordova-plugin-stepcounter',
pluginRef: 'stepcounter',
repo: 'https://github.com/texh/cordova-plugin-stepcounter',
repo: 'https://github.com/Slidee/cordova-plugin-stepcounter',
platforms: ['Android']
})
export class Stepcounter {

View File

@@ -30,7 +30,7 @@ export interface StreamingAudioOptions {
* orientation: 'landscape'
* };
*
* StreamingMedia.('https://path/to/video/stream', options);
* StreamingMedia.playVideo('https://path/to/video/stream', options);
*
* ```
* @interfaces

View File

@@ -9,6 +9,7 @@ window.plugins = {
};
const testPluginMeta = {
pluginName: 'Test',
plugin: 'cordova-plugin-test',
pluginRef: 'plugins.test',
repo: 'https://github.com/apache/cordova-plugin-test',

View File

@@ -0,0 +1,40 @@
import { GoogleMapsLatLngBounds, GoogleMapsLatLng } from '../../src/plugins/googlemap';
declare var window: any;
class LatLngBounds {
public southwest: GoogleMapsLatLng;
public northeast: GoogleMapsLatLng;
constructor(latLngArray: GoogleMapsLatLng[]) {
this.southwest = latLngArray[0];
this.northeast = latLngArray[1];
}
}
window.plugin = {
google: {
maps: {
LatLngBounds
}
}
};
describe('GoogleMapsLatLngBounds', () => {
const southwest = new GoogleMapsLatLng(1,1);
const northeast = new GoogleMapsLatLng(4,4);
let object;
it('should create an object', () => {
object = new GoogleMapsLatLngBounds([southwest, northeast]);
expect(object).toBeDefined();
});
it('northwest property should be defined', () => expect(object.northeast).toBeDefined());
it('southwest property should be defined', () => expect(object.southwest).toBeDefined());
});