Compare commits

...

19 Commits

Author SHA1 Message Date
Ibby Hadeed
e55c0c3e15 declare navigator to get rid of errors 2016-07-17 02:44:10 -04:00
Ibby Hadeed
1dbfd70724 chore(): update changelog 2016-07-17 02:43:05 -04:00
Ibby Hadeed
4059035050 1.3.5 2016-07-17 02:40:58 -04:00
Ibby Hadeed
b4b3ec0d2a fix(safari-view-controller): fix wrappers 2016-07-17 02:39:29 -04:00
Ibby Hadeed
d03ff962e3 docs(nativestorage): add usage 2016-07-17 02:35:31 -04:00
Ibby Hadeed
af5d4ad87f feat(nativestorage): add NativeStorage plugin wrapper 2016-07-17 02:32:19 -04:00
Ibby Hadeed
453374d4e7 docs(sqlite): fix usage typo 2016-07-17 02:11:52 -04:00
Ibrahim Hadeed
daa6d4cbb9 feat(media-capture): add media capture plugin (#293)
closes #272
2016-07-17 02:07:59 -04:00
Ibrahim Hadeed
2996da65c3 feat(googlemaps): add Geocoder class (#292)
closes #280
2016-07-17 02:07:46 -04:00
Markus Wagner
b5a2ffc6a5 fix(ibeacon): minor fixes
* Order of major/minor parameters for BeaconRegion creater fixed

* Property PluginResult.error added

* comment for BeaconRegion.minor fixed
2016-07-15 23:28:05 -04:00
Ibrahim Hadeed
2fe37c461c feat(pin-dialog): add pin dialog plugin (#291) 2016-07-15 00:44:03 -04:00
Max Lynch
be1725d2eb chore(comments): explain sync 2016-07-14 10:42:56 -05:00
Max Lynch
a1ce39dfda Changelog 2016-07-14 10:14:34 -05:00
Max Lynch
0cb79d1cd1 revert(changelog): old changelog 2016-07-14 09:59:41 -05:00
Max Lynch
e8f4b08f66 chore(changelog): Update changelog 2016-07-14 09:50:00 -05:00
Max Lynch
cdf9cdef54 Update CONTRIBUTING.md 2016-07-14 09:45:55 -05:00
Max Lynch
72ec500ffd version bump 2016-07-14 09:43:49 -05:00
Max Lynch
c23f5e90dc fix(touchid): make isAvailable static 2016-07-14 09:42:04 -05:00
Nick Kenens
0315e63782 Update spinnerdialog.ts to fix wrong documentation (#287)
Just implemented the SpinnerDialog into my app to use with Ionic Deploy.

The cancelCallback still happens when set to "false", when setting it to "true, the cancelCallback doesn't get called and therefore the SpinnerDialog doesn't hide on Android.
2016-07-13 17:36:23 -04:00
14 changed files with 410 additions and 17 deletions

View File

@@ -1,3 +1,37 @@
<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)

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.3",
"version": "1.3.5",
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
"main": "dist/index.js",
"files": [

View File

@@ -51,9 +51,12 @@ 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} 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';
@@ -90,6 +93,7 @@ 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';
@@ -126,8 +130,10 @@ export {
Hotspot,
Insomnia,
Keyboard,
NativeStorage,
Network,
OneSignal,
PinDialog,
Screenshot,
SocialSharing,
Splashscreen,
@@ -188,11 +194,14 @@ window['IonicNative'] = {
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,
SMS: SMS,

View File

@@ -1005,3 +1005,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);
});
}
}

View File

@@ -65,7 +65,7 @@ export interface BeaconRegion {
major?: number;
/**
* The beacon's major identifier number. Optional, of nothing is supplied
* The beacon's minor identifier number. Optional, of nothing is supplied
* the plugin will treat it as a wildcard.
*/
minor?: number;
@@ -125,6 +125,11 @@ export interface PluginResult {
* 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 {
/**
@@ -372,8 +377,8 @@ export class IBeacon {
*
* @return Returns the BeaconRegion that was created
*/
static BeaconRegion(identifer: string, uuid: string, minor?: number, major?: number, notifyEntryStateOnDisplay?: boolean): BeaconRegion {
return new cordova.plugins.locationManager.BeaconRegion(identifer, uuid, minor, major, notifyEntryStateOnDisplay);
static BeaconRegion(identifer: string, uuid: string, major?: number, minor?: number, notifyEntryStateOnDisplay?: boolean): BeaconRegion {
return new cordova.plugins.locationManager.BeaconRegion(identifer, uuid, major, minor, notifyEntryStateOnDisplay);
}
/**

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; }
}

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 => {
@@ -190,6 +191,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

@@ -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 {}
/**

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.