This commit is contained in:
Ibrahim Hadeed 2016-08-26 08:17:47 -04:00
commit bde47eb37b
No known key found for this signature in database
GPG Key ID: 0431793F665481A4
100 changed files with 6573 additions and 2693 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
.DS_Store
node_modules/
.idea
dist/
scripts/ionic-native-bower

View File

@ -1,3 +1,203 @@
<a name="1.3.17"></a>
## [1.3.17](https://github.com/driftyco/ionic-native/compare/v1.3.16...v1.3.17) (2016-08-23)
### Bug Fixes
* add the reject function at the expected errorIndex position in the args array ([#436](https://github.com/driftyco/ionic-native/issues/436)) ([4e87ac7](https://github.com/driftyco/ionic-native/commit/4e87ac7))
* **camera-preview:** changes implementation to match Cordova plugin ([#441](https://github.com/driftyco/ionic-native/issues/441)) ([55ba65a](https://github.com/driftyco/ionic-native/commit/55ba65a))
* **file:** fixes exclusive option ([#459](https://github.com/driftyco/ionic-native/issues/459)) ([14e41a3](https://github.com/driftyco/ionic-native/commit/14e41a3)), closes [#459](https://github.com/driftyco/ionic-native/issues/459)
* **file:** initialize writeFile options ([#468](https://github.com/driftyco/ionic-native/issues/468)) ([16628a4](https://github.com/driftyco/ionic-native/commit/16628a4))
* **nativeaudio:** fix plugin reference ([2510c5f](https://github.com/driftyco/ionic-native/commit/2510c5f))
### Features
* **instagram:** add instagram sharing plugin ([#453](https://github.com/driftyco/ionic-native/issues/453)) ([f3e698f](https://github.com/driftyco/ionic-native/commit/f3e698f)), closes [#307](https://github.com/driftyco/ionic-native/issues/307)
* **VideoEditor:** add video editor plugin. ([#457](https://github.com/driftyco/ionic-native/issues/457)) ([7a53013](https://github.com/driftyco/ionic-native/commit/7a53013)), closes [#316](https://github.com/driftyco/ionic-native/issues/316)
<a name="1.3.16"></a>
## [1.3.16](https://github.com/driftyco/ionic-native/compare/v1.3.15...v1.3.16) (2016-08-15)
### Bug Fixes
* **photo-viewer:** method is static ([8bc499f](https://github.com/driftyco/ionic-native/commit/8bc499f))
<a name="1.3.15"></a>
## [1.3.15](https://github.com/driftyco/ionic-native/compare/v1.3.14...v1.3.15) (2016-08-15)
### Features
* **google-analytics:** add missing functions ([689bfd9](https://github.com/driftyco/ionic-native/commit/689bfd9))
* **TTS:** add tts plugin ([#431](https://github.com/driftyco/ionic-native/issues/431)) ([dcf3ab2](https://github.com/driftyco/ionic-native/commit/dcf3ab2)), closes [#311](https://github.com/driftyco/ionic-native/issues/311)
<a name="1.3.14"></a>
## [1.3.14](https://github.com/driftyco/ionic-native/compare/v1.3.13...v1.3.14) (2016-08-15)
### Bug Fixes
* **datepicker:** date now accepts Date, string, or number ([#428](https://github.com/driftyco/ionic-native/issues/428)) ([aaddd9e](https://github.com/driftyco/ionic-native/commit/aaddd9e)), closes [#354](https://github.com/driftyco/ionic-native/issues/354)
### Features
* **native-audio:** Add native audio plugin ([#427](https://github.com/driftyco/ionic-native/issues/427)) ([8cd6686](https://github.com/driftyco/ionic-native/commit/8cd6686)), closes [#315](https://github.com/driftyco/ionic-native/issues/315)
* **shake:** add Shake plugin ([#426](https://github.com/driftyco/ionic-native/issues/426)) ([203d4c7](https://github.com/driftyco/ionic-native/commit/203d4c7)), closes [#313](https://github.com/driftyco/ionic-native/issues/313)
* **zip:** add zip plugin ([#430](https://github.com/driftyco/ionic-native/issues/430)) ([e34f94e](https://github.com/driftyco/ionic-native/commit/e34f94e)), closes [#421](https://github.com/driftyco/ionic-native/issues/421)
<a name="1.3.13"></a>
## [1.3.13](https://github.com/driftyco/ionic-native/compare/v1.3.12...v1.3.13) (2016-08-13)
### Bug Fixes
* **inappbrowser:** fix event listener ([4b08d85](https://github.com/driftyco/ionic-native/commit/4b08d85))
<a name="1.3.12"></a>
## [1.3.12](https://github.com/driftyco/ionic-native/compare/v1.3.10...v1.3.12) (2016-08-13)
### Bug Fixes
* **backgroundGeolocation:** update config and move to sync. Fixes [#331](https://github.com/driftyco/ionic-native/issues/331) ([4e20681](https://github.com/driftyco/ionic-native/commit/4e20681)), closes [#331](https://github.com/driftyco/ionic-native/issues/331)
* **camera:** camera options should be optional. Fixes [#413](https://github.com/driftyco/ionic-native/issues/413) ([#417](https://github.com/driftyco/ionic-native/issues/417)) ([c60c3b7](https://github.com/driftyco/ionic-native/commit/c60c3b7)), closes [#413](https://github.com/driftyco/ionic-native/issues/413) [#417](https://github.com/driftyco/ionic-native/issues/417)
* **inappbrowser:** fix event listener ([618d866](https://github.com/driftyco/ionic-native/commit/618d866))
* **index:** export Geolocation interfaces. ([#404](https://github.com/driftyco/ionic-native/issues/404)) ([0c486b0](https://github.com/driftyco/ionic-native/commit/0c486b0))
* **ng1:** Copy object properly. Fixes [#357](https://github.com/driftyco/ionic-native/issues/357) ([9ca38cd](https://github.com/driftyco/ionic-native/commit/9ca38cd)), closes [#357](https://github.com/driftyco/ionic-native/issues/357)
### Features
* **file:** alternate file implementation ([#283](https://github.com/driftyco/ionic-native/issues/283)) ([6ed32ef](https://github.com/driftyco/ionic-native/commit/6ed32ef))
* **GoogleAnalytics:** Add campaign measurement tracking ([#405](https://github.com/driftyco/ionic-native/issues/405)) ([cf3f0f6](https://github.com/driftyco/ionic-native/commit/cf3f0f6))
* **GoogleMaps:** Allow specify enableHighAccuracy option that attempt to get your location with highest accuracy ([#410](https://github.com/driftyco/ionic-native/issues/410)) ([43e8a6d](https://github.com/driftyco/ionic-native/commit/43e8a6d))
* **ibeacon:** using option otherPromise instead of sync ([#388](https://github.com/driftyco/ionic-native/issues/388)) ([306cb5d](https://github.com/driftyco/ionic-native/commit/306cb5d))
* **inappbrowser:** implement instance based wrapper ([#305](https://github.com/driftyco/ionic-native/issues/305)) ([4b8ab4a](https://github.com/driftyco/ionic-native/commit/4b8ab4a))
* **keyboard:** enable hideKeyboardAccessoryBar function ([#398](https://github.com/driftyco/ionic-native/issues/398)) ([7a84262](https://github.com/driftyco/ionic-native/commit/7a84262)), closes [#394](https://github.com/driftyco/ionic-native/issues/394)
* **photo-viewer:** add wrapper for plugin ([#359](https://github.com/driftyco/ionic-native/issues/359)) ([154c029](https://github.com/driftyco/ionic-native/commit/154c029))
* **video-player:** Added video player plugin ([#391](https://github.com/driftyco/ionic-native/issues/391)) ([cabeeb8](https://github.com/driftyco/ionic-native/commit/cabeeb8)), closes [#342](https://github.com/driftyco/ionic-native/issues/342)
<a name="1.3.10"></a>
## [1.3.10](https://github.com/driftyco/ionic-native/compare/v1.3.9...v1.3.10) (2016-08-01)
### Bug Fixes
* **brightness:** use correct pluginRef ([e20c411](https://github.com/driftyco/ionic-native/commit/e20c411))
* **diagnostics:** Corrects isEnabled functions to isAvailable ([#373](https://github.com/driftyco/ionic-native/issues/373)) ([ccf7fb5](https://github.com/driftyco/ionic-native/commit/ccf7fb5))
* **ng1:** use $q promises instead of the native Promise ([#378](https://github.com/driftyco/ionic-native/issues/378)) ([817a434](https://github.com/driftyco/ionic-native/commit/817a434))
* **one-signal:** return Observable instead of promise ([#352](https://github.com/driftyco/ionic-native/issues/352)) ([08fe04e](https://github.com/driftyco/ionic-native/commit/08fe04e))
### Features
* **crop:** add crop plugin ([#284](https://github.com/driftyco/ionic-native/issues/284)) ([41c9adf](https://github.com/driftyco/ionic-native/commit/41c9adf))
* **screen-orientation:** Added Screen Orientation Plugin [#342](https://github.com/driftyco/ionic-native/issues/342) ([#366](https://github.com/driftyco/ionic-native/issues/366)) ([bd9366b](https://github.com/driftyco/ionic-native/commit/bd9366b)), closes [#342](https://github.com/driftyco/ionic-native/issues/342)
<a name="1.3.9"></a>
## [1.3.9](https://github.com/driftyco/ionic-native/compare/v1.3.8...v1.3.9) (2016-07-23)
### Bug Fixes
* **file:** readAsText() and adds readAsDataURL() in File plugin ([#346](https://github.com/driftyco/ionic-native/issues/346)) ([77d31cd](https://github.com/driftyco/ionic-native/commit/77d31cd))
### Features
* **android-fingerprint-auth:** add wrapper for plugin ([df326f7](https://github.com/driftyco/ionic-native/commit/df326f7)), closes [#334](https://github.com/driftyco/ionic-native/issues/334)
* **secure-storage:** Add Secure Storage Wrapper ([#347](https://github.com/driftyco/ionic-native/issues/347)) ([075842d](https://github.com/driftyco/ionic-native/commit/075842d))
<a name="1.3.8"></a>
## [1.3.8](https://github.com/driftyco/ionic-native/compare/v1.3.7...v1.3.8) (2016-07-20)
### Bug Fixes
* **base64togallery:** update plugin wrapper to match latest version ([d4bee49](https://github.com/driftyco/ionic-native/commit/d4bee49)), closes [#335](https://github.com/driftyco/ionic-native/issues/335)
* **sqlite:** fix method attribute typo ([#324](https://github.com/driftyco/ionic-native/issues/324)) ([006bc70](https://github.com/driftyco/ionic-native/commit/006bc70)), closes [#324](https://github.com/driftyco/ionic-native/issues/324)
### Features
* **facebook:** add FacebookLoginResponse interface ([8b27bed](https://github.com/driftyco/ionic-native/commit/8b27bed))
* **otherPromise:** can work better with plugins that return promises ([#304](https://github.com/driftyco/ionic-native/issues/304)) ([0aee6c8](https://github.com/driftyco/ionic-native/commit/0aee6c8))
* **social-sharing:** add canShareViaEmail ([#333](https://github.com/driftyco/ionic-native/issues/333)) ([5807dd7](https://github.com/driftyco/ionic-native/commit/5807dd7))
* **twitter-connect:** add twitter connect plugin ([979838f](https://github.com/driftyco/ionic-native/commit/979838f)), closes [#308](https://github.com/driftyco/ionic-native/issues/308)
<a name="1.3.7"></a>
## [1.3.7](https://github.com/driftyco/ionic-native/compare/v1.3.6...v1.3.7) (2016-07-18)
### Bug Fixes
* **contacts:** missing name property, types ([#320](https://github.com/driftyco/ionic-native/issues/320)) ([074d166](https://github.com/driftyco/ionic-native/commit/074d166))
* **geolocation:** handle errors on watchPosition ([1b161d8](https://github.com/driftyco/ionic-native/commit/1b161d8)), closes [#322](https://github.com/driftyco/ionic-native/issues/322)
### Features
* **sim:** Add sim plugin ([#317](https://github.com/driftyco/ionic-native/issues/317)) ([4f85110](https://github.com/driftyco/ionic-native/commit/4f85110))
<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)
@ -46,28 +246,12 @@
<a name="1.3.1"></a>
## [1.3.1](https://github.com/driftyco/ionic-native/compare/v1.3.0...v1.3.1) (2016-06-26)
## [1.3.1](https://github.com/driftyco/ionic-native/compare/v1.2.4...v1.3.1) (2016-06-26)
### Bug Fixes
* **3dtouch:** fix implementation for onHomeIconPressed function ([d2b2be6](https://github.com/driftyco/ionic-native/commit/d2b2be6)), closes [#232](https://github.com/driftyco/ionic-native/issues/232)
* **sqlite:** resolve race condition, add comments ([#235](https://github.com/driftyco/ionic-native/issues/235)) ([f1c8ce3](https://github.com/driftyco/ionic-native/commit/f1c8ce3)), closes [#235](https://github.com/driftyco/ionic-native/issues/235)
### Features
* **googlemaps:** add GoogleMapsLatLngBounds class ([17da427](https://github.com/driftyco/ionic-native/commit/17da427))
* **printer:** add printer plugin ([#225](https://github.com/driftyco/ionic-native/issues/225)) ([48ffcae](https://github.com/driftyco/ionic-native/commit/48ffcae))
<a name="1.3.0"></a>
# [1.3.0](https://github.com/driftyco/ionic-native/compare/v1.2.3...v1.3.0) (2016-06-13)
### Bug Fixes
* **barcodescanner:** add missing options param ([4fdcbb5](https://github.com/driftyco/ionic-native/commit/4fdcbb5)), closes [#180](https://github.com/driftyco/ionic-native/issues/180)
* **base64togallery:** method is now static ([be7b9e2](https://github.com/driftyco/ionic-native/commit/be7b9e2)), closes [#212](https://github.com/driftyco/ionic-native/issues/212)
* **batterystatus:** correct plugin name on npm ([66b7fa6](https://github.com/driftyco/ionic-native/commit/66b7fa6))
@ -76,6 +260,7 @@
* **deviceorientation:** cancelFunction renamed to clearFunction ([8dee02e](https://github.com/driftyco/ionic-native/commit/8dee02e))
* **geolocation:** fix watchPosition() ([4a8650e](https://github.com/driftyco/ionic-native/commit/4a8650e)), closes [#164](https://github.com/driftyco/ionic-native/issues/164)
* **googlemaps:** isAvailable() returns boolean, not an instance of GoogleMap ([a53ae8f](https://github.com/driftyco/ionic-native/commit/a53ae8f))
* **sqlite:** resolve race condition, add comments ([#235](https://github.com/driftyco/ionic-native/issues/235)) ([f1c8ce3](https://github.com/driftyco/ionic-native/commit/f1c8ce3)), closes [#235](https://github.com/driftyco/ionic-native/issues/235)
### Features
@ -83,6 +268,13 @@
* **angular1:** Support Angular 1 ([af8fbde](https://github.com/driftyco/ionic-native/commit/af8fbde))
* **barcodescanner:** add encode function ([e73f57f](https://github.com/driftyco/ionic-native/commit/e73f57f)), closes [#115](https://github.com/driftyco/ionic-native/issues/115)
* **deeplinks:** Add Ionic Deeplinks Plugin ([c93cbed](https://github.com/driftyco/ionic-native/commit/c93cbed))
* **googlemaps:** add GoogleMapsLatLngBounds class ([17da427](https://github.com/driftyco/ionic-native/commit/17da427))
* **printer:** add printer plugin ([#225](https://github.com/driftyco/ionic-native/issues/225)) ([48ffcae](https://github.com/driftyco/ionic-native/commit/48ffcae))
<a name="1.2.4"></a>
## [1.2.4](https://github.com/driftyco/ionic-native/compare/v1.2.3...v1.2.4) (2016-06-01)

View File

@ -5,6 +5,16 @@ This is a short guide on creating new plugin wrappers for Ionic Native.
## Creating Plugin Wrappers
First, let's start by creating a new plugin wrapper from template.
```
// Call this command, and replace PluginName with the name of the plugin you wish to add
// Make sure to capitalize the first letter, or use CamelCase if necessary.
gulp plugin:create -n PluginName
```
Let's take a look at the existing plugin wrapper for Geolocation to see what goes into an Ionic Native plugin (comments have been removed for clarity):
```
@ -92,14 +102,95 @@ The `@Cordova` decorator has a few more options now.
`clearFunction` is used in conjunction with the `observable` option and indicates the function to be called when the Observable is disposed.
### Updating index.ts
For new plugins, you will need to update `/src/index.ts` to properly export your plugin and make it available for use.
1. Import the plugin class into `index.ts`:
`import {PluginClassName} from ./plugins/filenameForPlugin`
No need to put the `.ts` extension on the filename.
2. Add the plugin class name to the list in the `export` object:
```
export {
ActionSheet,
AdMob,
AndroidFingerprintAuth,
YourPluginClassName,
...
}
```
3. Add the plugin class name to the `window['IonicNative']` object:
```
window['IonicNative'] = {
ActionSheet: ActionSheet,
AdMob: AdMob,
AndroidFingerprintAuth: AndroidFingerprintAuth,
YourPluginClassName: YourPluginClassName,
...
```
4. If your plugin exports any other objects outside of the plugin class, add an export statement for the file:
`export * from './plugins/filenameForPlugin';`
No need to put the `.ts` extension on the filename.
For example, `googlemaps.ts` exports a const outside of the plugin's main `GoogleMap` class:
```
export const GoogleMapsAnimation = {
BOUNCE: 'BOUNCE',
DROP: 'DROP'
};
```
To properly export `GoogleMapsAnimation`, `index.ts` is updated with:
`export * from './plugins/googlemaps';`
### Testing your changes
You need to run `npm run build` in the `ionic-native` project, this will create a `dist` directory. Then, you must go to your ionic application folder and replace your current `node_modules/ionic-native/dist/` with the newly generated one.
### Cleaning the code
You need to run `npm run tslint` to analyze the code and ensure it's consistency with the repository style. Fix any errors before submitting a PR.
You need to run `npm run lint` to analyze the code and ensure it's consistency with the repository style. Fix any errors before submitting a PR.
### 'Wrapping' Up
That's it! The only thing left to do is rigorously document the plugin and it's usage. Take a look at some of the other plugins for good documentation styles.
## Commit Message Format
We have very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history. But also, we use the git commit messages to generate the our change log. (Ok you got us, it's basically Angular's commit message format).
`type(scope): subject`
#### Type
Must be one of the following:
* **fix**: A bug fix
* **feat**: A new feature
* **docs**: Documentation only changes
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
* **refactor**: A code change that neither fixes a bug nor adds a feature
* **perf**: A code change that improves performance
* **test**: Adding missing tests
* **chore**: Changes to the build process or auxiliary tools and libraries such as documentation generation
#### Scope
The scope could be anything specifying place of the commit change. For example, the name of the plugin being changed
#### Subject
The subject contains succinct description of the change:
* use the imperative, present tense: "change" not "changed" nor "changes"
* do not capitalize first letter
* do not place a period (.) at the end
* entire length of the commit message must not go over 50 characters

View File

@ -17,9 +17,9 @@ For the full Ionic Native documentation, please visit [http://ionicframework.com
Ionic Native wraps plugin callbacks in a Promise or [Observable](https://gist.github.com/staltz/868e7e9bc2a7b8c1f754), providing a common interface for all plugins and ensuring that native events trigger change detection in Angular 2.
```
import {Geolocation} from 'ionic-native';
import { Geolocation } from 'ionic-native';
Geolocation.getCurrentPosition().then(pos => {
Geolocation.getCurrentPosition().then(pos => {
console.log('lat: ' + pos.coords.latitude + ', lon: ' + pos.coords.longitude);
});
@ -31,13 +31,50 @@ let watch = Geolocation.watchPosition().subscribe(pos => {
watch.unsubscribe();
```
### Angular 1
Ionic Native works as a stand-in for [ngCordova](http://ngcordova.com/). In many cases, the usage is identical, but we import `ionic.native` instead of `ngCordova` as our module.
As a rule of thumb: take the ES6 class name of the plugin and add `$cordova` to get the service name. For example, `Geolocation` would be `$cordovaGeolocation`, and `Camera` will be `$cordovaCamera`:
```javascript
angular.module('myApp', ['ionic', 'ionic.native'])
.controller('MyCtrl', function($scope, $cordovaCamera) {
$scope.takePicture = function() {
$cordovaCamera.getPicture(opts).then(function(p) {
}, function(err) {
});
};
});
```
For services that return observables, the Angular 1 digest cycle must be done manually (currently):
```javascript
angular.module('myApp', ['ionic', 'ionic.native'])
.controller('MyCtrl', function($scope, $cordovaGeolocation) {
$scope.takePicture = function() {
$cordovaGeolocation.watchPosition(opts).subscribe(function(p) {
$scope.$apply(function() {
$scope.position = p.coords;
});
}, function(err) {
});
};
});
```
### Runtime Diagnostics
Spent way too long diagnosing an issue only to realize a plugin wasn't firing or installed? Ionic Native lets you know what the issue is and how you can resolve it.
![img](http://ionic-io-assets.s3.amazonaws.com/ionic-native-console.png)
## Installation
Run following commmand to install ionic-native in your project.
Run following commmand to install ionic-native in your project.
```
npm install ionic-native --save
```

50
TEMPLATE Normal file
View File

@ -0,0 +1,50 @@
/**
* This is a template for new plugin wrappers
*
* TODO:
* - Add/Change information below
* - Document usage (importing, executing main functionality)
* - Remove any imports that you are not using
* - Add this file to /src/index.ts (follow style of other plugins)
* - Remove all the comments included in this template, EXCEPT the @Plugin wrapper docs.
* - Remove this note
*
*/
import {Plugin, Cordova, CordovaProperty, CordovaInstance, InstanceProperty} from './plugin';
import {Observable} from 'rxjs/Observable';
/**
* @name PluginName
* @description
* This plugin does something
*
* @usage
* ```
* import {PluginName} from 'ionic-native';
*
* PluginName.functionName('Hello', 123)
* .then((something: any) => doSomething(something))
* .catch((error: any) => console.log(error));
*
* ```
*/
@Plugin({
plugin: '', // npm package name, example: cordova-plugin-camera
pluginRef: '', // the variable reference to call the plugin, example: navigator.geolocation
repo: '', // the github repository URL for the plugin
install: '' // OPTIONAL install command, in case the plugin requires variables
})
export class PluginName {
/**
* This function does something
* @param arg1 {string} Some param to configure something
* @param arg2 {number} Another param to configure something
* @return {Promise<any>} Returns a promise that resolves when something happens
*/
@Cordova()
static functionName(arg1: string, arg2: number): Promise<any> {
return; // We add return; here to avoid any IDE / Compiler errors
}
}

View File

@ -2,7 +2,9 @@ var gulp = require('gulp');
var minimist = require('minimist');
var uglify = require('gulp-uglify');
var rename = require("gulp-rename");
var tslint = require('gulp-tslint');
var tslint = require('ionic-gulp-tslint');
var decamelize = require('decamelize');
var replace = require('gulp-replace');
var flagConfig = {
string: ['port', 'version', 'ngVersion', 'animations'],
@ -25,8 +27,17 @@ gulp.task("minify:dist", function(){
.pipe(gulp.dest('./dist'));
});
gulp.task("tslint", function(){
gulp.src("src/**/*.ts")
.pipe(tslint())
.pipe(tslint.report('verbose'));
gulp.task('lint', function() {
tslint({src: 'src/**/*.ts'});
});
gulp.task('plugin:create', function(){
if(flags.n && flags.n !== ''){
return gulp.src('./TEMPLATE')
.pipe(replace('PluginName', flags.n))
.pipe(rename(decamelize(flags.n, '-') + '.ts'))
.pipe(gulp.dest('./src/plugins/'));
} else {
console.log("Usage is: gulp plugin:create -n PluginName");
}
});

View File

@ -1,6 +1,6 @@
{
"name": "ionic-native",
"version": "1.3.4",
"version": "1.3.17",
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
"main": "dist/index.js",
"files": [
@ -16,13 +16,16 @@
"conventional-github-releaser": "^1.1.3",
"cpr": "^1.0.0",
"cz-conventional-changelog": "^1.1.6",
"decamelize": "^1.2.0",
"dgeni": "^0.4.2",
"dgeni-packages": "^0.10.18",
"glob": "^6.0.4",
"gulp": "^3.9.1",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-tslint": "^5.0.0",
"gulp-uglify": "^1.5.4",
"ionic-gulp-tslint": "^1.0.0",
"lodash": "3.10.1",
"minimist": "^1.1.3",
"mkdirp": "^0.5.1",
@ -30,18 +33,19 @@
"q": "1.4.1",
"semver": "^5.0.1",
"tslint": "^3.8.1",
"tslint-eslint-rules": "^1.3.0",
"tslint-ionic-rules": "0.0.5",
"typescript": "^1.8.10"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"tslint": "./node_modules/.bin/gulp tslint",
"lint": "./node_modules/.bin/gulp lint",
"watch": "./node_modules/.bin/tsc -w",
"build": "npm run tslint && npm run build:js && npm run build:bundle && npm run build:minify",
"build": "npm run lint && npm run build:js && npm run build:bundle && npm run build:minify",
"build:js": "./node_modules/.bin/tsc",
"build:bundle": "./node_modules/.bin/browserify dist/index.js > dist/ionic.native.js",
"build:minify": "./node_modules/.bin/gulp minify:dist",
"changelog": "./node_modules/.bin/conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
"changelog": "./node_modules/.bin/conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
"plugin:create": "gulp plugin:create"
},
"repository": {
"type": "git",

26
scripts/bower.json Normal file
View File

@ -0,0 +1,26 @@
{
"name": "ionic-native",
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
"main": [
"ionic.native.js"
],
"authors": [
"Max Lynch <max@ionic.io>"
],
"license": "MIT",
"keywords": [
"ionic",
"native",
"html5",
"hybrid",
"mobile"
],
"homepage": "https://github.com/driftyco/ionic-native-bower",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}

28
scripts/bower.sh Normal file
View File

@ -0,0 +1,28 @@
#!/bin/bash
set -e
# readJsonProp(jsonFile, property)
# - restriction: property needs to be on an own line!
function readJsonProp {
echo $(sed -En 's/.*"'$2'"[ ]*:[ ]*"(.*)".*/\1/p' $1)
}
VERSION=$(readJsonProp "package.json" "version")
echo "BOWERING IONIC-NATIVE VERSION $VERSION. FOR GREAT JUSTICE..."
DIR="scripts/ionic-native-bower"
rm -rf $DIR
mkdir $DIR
cp dist/ionic.native.js dist/ionic.native.min.js $DIR
cd $DIR
git init
git remote add origin git@github.com:driftyco/ionic-native-bower.git
cp ../bower.json .
git add .
git commit -m "Bower release"
git tag -f -m v$VERSION v$VERSION
git push -f --tags origin master
echo "BOWERING COMPLETED SOMEWHAT SUCCESSFULLY"

View File

@ -1,76 +1,97 @@
import {initAngular1} from './ng1';
import { initAngular1 } from './ng1';
const DEVICE_READY_TIMEOUT = 2000;
declare var window;
import {ActionSheet} from './plugins/actionsheet';
import {AdMob} from './plugins/admob';
import {AppAvailability} from './plugins/appavailability';
import {AppRate} from './plugins/apprate';
import {AppVersion} from './plugins/appversion';
import {Badge} from './plugins/badge';
import {BackgroundGeolocation} from './plugins/background-geolocation';
import {BackgroundMode} from './plugins/backgroundmode';
import {BarcodeScanner} from './plugins/barcodescanner';
import {Base64ToGallery} from './plugins/base64togallery';
import {BatteryStatus} from './plugins/batterystatus';
import {Brightness} from './plugins/brightness';
import {BLE} from './plugins/ble';
import {BluetoothSerial} from './plugins/bluetoothserial';
import {Calendar} from './plugins/calendar';
import {Camera} from './plugins/camera';
import {CardIO} from './plugins/card-io';
import {Clipboard} from './plugins/clipboard';
import {Contacts} from './plugins/contacts';
import {DatePicker} from './plugins/datepicker';
import {DBMeter} from './plugins/dbmeter';
import {Deeplinks} from './plugins/deeplinks';
import {Device} from './plugins/device';
import {DeviceAccounts} from './plugins/deviceaccounts';
import {DeviceMotion} from './plugins/devicemotion';
import {DeviceOrientation} from './plugins/deviceorientation';
import {Diagnostic} from './plugins/diagnostic';
import {Dialogs} from './plugins/dialogs';
import {EmailComposer} from './plugins/emailcomposer';
import {Facebook} from './plugins/facebook';
import {File} from './plugins/file';
import {Transfer} from './plugins/filetransfer';
import {Flashlight} from './plugins/flashlight';
import {Geolocation} from './plugins/geolocation';
import {Globalization} from './plugins/globalization';
import {GooglePlus} from './plugins/google-plus';
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 {InAppPurchase} from './plugins/inapppurchase';
import {Insomnia} from './plugins/insomnia';
import {Keyboard} from './plugins/keyboard';
import {LaunchNavigator} from './plugins/launchnavigator';
import {LocalNotifications} from './plugins/localnotifications';
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';
import {Screenshot} from './plugins/screenshot';
import {SMS} from './plugins/sms';
import {SocialSharing} from './plugins/socialsharing';
import {SpinnerDialog} from './plugins/spinnerdialog';
import {Splashscreen} from './plugins/splashscreen';
import {SQLite} from './plugins/sqlite';
import {StatusBar} from './plugins/statusbar';
import {ThreeDeeTouch} from './plugins/3dtouch';
import {Toast} from './plugins/toast';
import {TouchID} from './plugins/touchid';
import {Vibration} from './plugins/vibration';
import {WebIntent} from './plugins/webintent';
import { ActionSheet } from './plugins/actionsheet';
import { AdMob } from './plugins/admob';
import { AndroidFingerprintAuth } from './plugins/android-fingerprint-auth';
import { AppAvailability } from './plugins/appavailability';
import { AppRate } from './plugins/apprate';
import { AppVersion } from './plugins/appversion';
import { Badge } from './plugins/badge';
import { BackgroundGeolocation } from './plugins/background-geolocation';
import { BackgroundMode } from './plugins/backgroundmode';
import { BarcodeScanner } from './plugins/barcodescanner';
import { Base64ToGallery } from './plugins/base64togallery';
import { BatteryStatus } from './plugins/batterystatus';
import { Brightness } from './plugins/brightness';
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';
import { Crop } from './plugins/crop';
import { DatePicker } from './plugins/datepicker';
import { DBMeter } from './plugins/dbmeter';
import { Deeplinks } from './plugins/deeplinks';
import { Device } from './plugins/device';
import { DeviceAccounts } from './plugins/deviceaccounts';
import { DeviceMotion } from './plugins/devicemotion';
import { DeviceOrientation } from './plugins/deviceorientation';
import { Diagnostic } from './plugins/diagnostic';
import { Dialogs } from './plugins/dialogs';
import { EmailComposer } from './plugins/emailcomposer';
import { EstimoteBeacons } from './plugins/estimote-beacons';
import { Facebook } from './plugins/facebook';
import { File } from './plugins/file';
import { Transfer } from './plugins/filetransfer';
import { Flashlight } from './plugins/flashlight';
import { Geofence } from './plugins/geofence';
import { Geolocation } from './plugins/geolocation';
import { Globalization } from './plugins/globalization';
import { GooglePlus } from './plugins/google-plus';
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 { ImageResizer } from './plugins/imageresizer';
import { InAppBrowser } from './plugins/inappbrowser';
import { InAppPurchase } from './plugins/inapppurchase';
import { Insomnia } from './plugins/insomnia';
import { Instagram } from './plugins/instagram';
import { IsDebug } from './plugins/is-debug';
import { Keyboard } from './plugins/keyboard';
import { LaunchNavigator } from './plugins/launchnavigator';
import { LocalNotifications } from './plugins/localnotifications';
import { MediaCapture } from './plugins/media-capture';
import { NativeAudio } from './plugins/native-audio';
import { NativeStorage } from './plugins/nativestorage';
import { MediaPlugin } from './plugins/media';
import { Network } from './plugins/network';
import { OneSignal } from './plugins/onesignal';
import { PhotoViewer } from './plugins/photo-viewer';
import { ScreenOrientation } from './plugins/screen-orientation';
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 { SecureStorage } from './plugins/securestorage';
import { Shake } from './plugins/shake';
import { Sim } from './plugins/sim';
import { SMS } from './plugins/sms';
import { SocialSharing } from './plugins/socialsharing';
import { SpinnerDialog } from './plugins/spinnerdialog';
import { Splashscreen } from './plugins/splashscreen';
import { SQLite } from './plugins/sqlite';
import { StatusBar } from './plugins/statusbar';
import { ThreeDeeTouch } from './plugins/3dtouch';
import { Toast } from './plugins/toast';
import { TouchID } from './plugins/touchid';
import { TextToSpeech } from './plugins/text-to-speech';
import { TwitterConnect } from './plugins/twitter-connect';
import { Vibration } from './plugins/vibration';
import { VideoEditor } from './plugins/video-editor';
import { VideoPlayer } from './plugins/video-player';
import { WebIntent } from './plugins/webintent';
import { Zip } from './plugins/zip';
export * from './plugins/3dtouch';
export * from './plugins/background-geolocation';
export * from './plugins/backgroundmode';
@ -83,24 +104,33 @@ export * from './plugins/datepicker';
export * from './plugins/device';
export * from './plugins/devicemotion';
export * from './plugins/deviceorientation';
export * from './plugins/facebook';
export * from './plugins/file';
export * from './plugins/filetransfer';
export * from './plugins/geolocation';
export * from './plugins/googlemaps';
export * from './plugins/httpd';
export * from './plugins/ibeacon';
export * from './plugins/imagepicker';
export * from './plugins/imageresizer';
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';
export * from './plugins/sms';
export * from './plugins/spinnerdialog';
export * from './plugins/toast';
export * from './plugins/twitter-connect';
export * from './plugins/video-editor';
export * from './plugins/video-player';
export {
ActionSheet,
AdMob,
AndroidFingerprintAuth,
AppAvailability,
AppRate,
AppVersion,
@ -111,36 +141,48 @@ export {
Brightness,
BLE,
BluetoothSerial,
CameraPreview,
Clipboard,
Crop,
DBMeter,
Deeplinks,
DeviceAccounts,
Dialogs,
Diagnostic,
EmailComposer,
Facebook,
EstimoteBeacons,
File,
Flashlight,
Geolocation,
Geofence,
Globalization,
GooglePlus,
GoogleAnalytics,
Hotspot,
InAppPurchase,
Insomnia,
Instagram,
Keyboard,
NativeAudio,
NativeStorage,
Network,
OneSignal,
PhotoViewer,
ScreenOrientation,
PinDialog,
Screenshot,
SecureStorage,
Shake,
SocialSharing,
Sim,
Splashscreen,
SQLite,
StatusBar,
TouchID,
Transfer,
TextToSpeech,
Vibration,
WebIntent
WebIntent,
Zip
}
export * from './plugins/plugin';
@ -149,6 +191,7 @@ export * from './plugins/plugin';
window['IonicNative'] = {
ActionSheet: ActionSheet,
AdMob: AdMob,
AndroidFingerprintAuth: AndroidFingerprintAuth,
AppAvailability: AppAvailability,
AppRate: AppRate,
AppVersion: AppVersion,
@ -163,9 +206,11 @@ window['IonicNative'] = {
BluetoothSerial: BluetoothSerial,
Calendar: Calendar,
Camera: Camera,
CameraPreview: CameraPreview,
CardIO: CardIO,
Clipboard: Clipboard,
Contacts: Contacts,
Crop: Crop,
DatePicker: DatePicker,
DBMeter: DBMeter,
Deeplinks: Deeplinks,
@ -176,9 +221,11 @@ window['IonicNative'] = {
Dialogs: Dialogs,
Diagnostic: Diagnostic,
EmailComposer: EmailComposer,
EstimoteBeacons: EstimoteBeacons,
Facebook: Facebook,
File: File,
Flashlight: Flashlight,
Geofence: Geofence,
Geolocation: Geolocation,
Globalization: Globalization,
GooglePlus: GooglePlus,
@ -188,19 +235,30 @@ window['IonicNative'] = {
Httpd: Httpd,
IBeacon: IBeacon,
ImagePicker: ImagePicker,
ImageResizer: ImageResizer,
InAppBrowser: InAppBrowser,
InAppPurchase: InAppPurchase,
Instagram: Instagram,
IsDebug: IsDebug,
Keyboard: Keyboard,
LaunchNavigator: LaunchNavigator,
LocalNotifications: LocalNotifications,
MediaCapture: MediaCapture,
MediaPlugin: MediaPlugin,
NativeAudio: NativeAudio,
NativeStorage: NativeStorage,
Network: Network,
Printer: Printer,
Push: Push,
OneSignal: OneSignal,
PhotoViewer: PhotoViewer,
ScreenOrientation: ScreenOrientation,
PinDialog: PinDialog,
SafariViewController: SafariViewController,
Screenshot: Screenshot,
SecureStorage: SecureStorage,
Shake: Shake,
Sim: Sim,
SMS: SMS,
SocialSharing: SocialSharing,
SpinnerDialog: SpinnerDialog,
@ -211,8 +269,13 @@ window['IonicNative'] = {
Toast: Toast,
TouchID: TouchID,
Transfer: Transfer,
TextToSpeech: TextToSpeech,
TwitterConnect: TwitterConnect,
VideoEditor: VideoEditor,
VideoPlayer: VideoPlayer,
Vibration: Vibration,
WebIntent: WebIntent
WebIntent: WebIntent,
Zip: Zip
};
initAngular1(window['IonicNative']);

View File

@ -3,7 +3,7 @@ declare var window;
/**
* Initialize the ionic.native Angular module if we're running in ng1.
* This iterates through the list of registered plugins and dynamically
* creates Angular 1 services of the form $cordovaSERVICE, ex: $cordovStatusBar.
* creates Angular 1 services of the form $cordovaSERVICE, ex: $cordovaStatusBar.
*/
export function initAngular1(plugins) {
if (window.angular) {
@ -15,14 +15,11 @@ export function initAngular1(plugins) {
(function(serviceName, cls, name) {
window.angular.module('ionic.native').service(serviceName, [function() {
let funcs = {};
for (var k in cls) {
funcs[k] = cls[k];
}
funcs['name'] = name;
var funcs = window.angular.copy(cls);
funcs.prototype['name'] = name;
return funcs;
}]);
})(serviceName, cls, name);
}
}
}
}

View File

@ -1,19 +1,22 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
declare var window: any;
/**
* @name 3DTouch
* @description
* @usage
* Please do refer to the original plugin's repo for detailed usage. The usage example here might not be sufficient.
* ```
* import {ThreeDeeTouch} from 'ionic-native';
* import { ThreeDeeTouch } from 'ionic-native';
*
* // import for type completion on variables
* import {ThreeDeeTouchQuickAction, ThreeDeeTouchForceTouch} from 'ionic-native';
* import { ThreeDeeTouchQuickAction, ThreeDeeTouchForceTouch } from 'ionic-native';
* ...
*
* ThreeDeeTouch.isAvailable().then(isAvailable => console.log("3D Touch available? " + isAvailable)):
* ThreeDeeTouch.isAvailable().then(isAvailable => console.log("3D Touch available? " + isAvailable));
*
* ThreeDeeTouch.watchForceTouches()
* .subscribe(
@ -54,7 +57,7 @@ declare var window: any;
* ThreeDeeTouchForceTouch.onHomeIconPressed().subscribe(
* (payload) => {
* // returns an object that is the button you presed
* console.log(`Pressed the ${payload.title} button`)
* console.log('Pressed the ${payload.title} button')
* console.log(payload.type)
*
* }
@ -62,81 +65,85 @@ declare var window: any;
* ```
*/
@Plugin({
plugin: 'cordova-plugin-3dtouch',
pluginRef: 'ThreeDeeTouch',
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-3dtouch',
platforms: ['iOS']
plugin: 'cordova-plugin-3dtouch',
pluginRef: 'ThreeDeeTouch',
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-3dtouch',
platforms: ['iOS']
})
export class ThreeDeeTouch {
/**
* You need an iPhone 6S or some future tech to use the features of this plugin, so you can check at runtime if the user's device is supported.
* @returns {Promise<boolean>} returns a promise that resolves with a boolean that indicates whether the plugin is available or not
*/
@Cordova()
static isAvailable(): Promise<boolean> {return; }
/**
* You need an iPhone 6S or some future tech to use the features of this plugin, so you can check at runtime if the user's device is supported.
* @returns {Promise<boolean>} returns a promise that resolves with a boolean that indicates whether the plugin is available or not
*/
@Cordova()
static isAvailable(): Promise<boolean> { return; }
/**
* You can get a notification when the user force touches the webview. The plugin defines a Force Touch when at least 75% of the maximum force is applied to the screen. Your app will receive the x and y coordinates, so you have to figure out which UI element was touched.
* @returns {Observable<ThreeDeeTouchForceTouch>} Returns an observable that sends a `ThreeDeeTouchForceTouch` object
*/
@Cordova({
observable: true
})
static watchForceTouches(): Observable<ThreeDeeTouchForceTouch> {return; }
/**
* You can get a notification when the user force touches the webview. The plugin defines a Force Touch when at least 75% of the maximum force is applied to the screen. Your app will receive the x and y coordinates, so you have to figure out which UI element was touched.
* @returns {Observable<ThreeDeeTouchForceTouch>} Returns an observable that sends a `ThreeDeeTouchForceTouch` object
*/
@Cordova({
observable: true
})
static watchForceTouches(): Observable<ThreeDeeTouchForceTouch> { return; }
/**
* setup the 3D-touch actions, takes an array of objects with the following
* @param {string} type (optional) A type that can be used `onHomeIconPressed` callback
* @param {string} title Title for your action
* @param {string} subtitle (optional) A short description for your action
* @param {string} iconType (optional) Choose between Prohibit, Contact, Home, MarkLocation, Favorite, Love, Cloud, Invitation, Confirmation, Mail, Message, Date, Time, CapturePhoto, CaptureVideo, Task, TaskCompleted, Alarm, Bookmark, Shuffle, Audio, Update
*/
@Cordova({
sync: true
})
static configureQuickActions(quickActions: Array<ThreeDeeTouchQuickAction>): void {}
/**
* setup the 3D-touch actions, takes an array of objects with the following
* @param {string} type (optional) A type that can be used `onHomeIconPressed` callback
* @param {string} title Title for your action
* @param {string} subtitle (optional) A short description for your action
* @param {string} iconType (optional) Choose between Prohibit, Contact, Home, MarkLocation, Favorite, Love, Cloud, Invitation, Confirmation, Mail, Message, Date, Time, CapturePhoto, CaptureVideo, Task, TaskCompleted, Alarm, Bookmark, Shuffle, Audio, Update
*/
@Cordova({
sync: true
})
static configureQuickActions(quickActions: Array<ThreeDeeTouchQuickAction>): void { }
/**
* When a home icon is pressed, your app launches and this JS callback is invoked.
* @returns {Observable<any>} returns an observable that notifies you when he user presses on the home screen icon
*/
static onHomeIconPressed(): Observable<any> {
return new Observable(observer => {
if (window.ThreeDeeTouch && window.ThreeDeeTouch.onHomeIconPressed) window.ThreeDeeTouch.onHomeIconPressed = observer.next.bind(observer);
else {
observer.error('3dTouch plugin is not available.');
observer.complete();
}
});
}
/**
* When a home icon is pressed, your app launches and this JS callback is invoked.
* @returns {Observable<any>} returns an observable that notifies you when he user presses on the home screen icon
*/
static onHomeIconPressed(): Observable<any> {
return new Observable(observer => {
if (window.ThreeDeeTouch && window.ThreeDeeTouch.onHomeIconPressed) {
window.ThreeDeeTouch.onHomeIconPressed = observer.next.bind(observer);
} else {
observer.error('3dTouch plugin is not available.');
observer.complete();
}
});
}
/**
* Enable Link Preview.
* UIWebView and WKWebView (the webviews powering Cordova apps) don't allow the fancy new link preview feature of iOS9.
*/
@Cordova({
sync: true
})
static enableLinkPreview(): void {}
/**
* Enable Link Preview.
* UIWebView and WKWebView (the webviews powering Cordova apps) don't allow the fancy new link preview feature of iOS9.
*/
@Cordova({
sync: true
})
static enableLinkPreview(): void { }
/**
* Disabled the link preview feature, if enabled.
*/
@Cordova({
sync: true
})
static disableLinkPreview(): void { }
/**
* Disabled the link preview feature, if enabled.
*/
@Cordova({
sync: true
})
static disableLinkPreview(): void {}
}
export interface ThreeDeeTouchQuickAction {
type?: string;
title: string;
subtitle?: string;
iconType?: string;
type?: string;
title: string;
subtitle?: string;
iconType?: string;
}
export interface ThreeDeeTouchForceTouch {
force: number;
timestamp: number;
x: number;
y: number;
force: number;
timestamp: number;
x: number;
y: number;
}

View File

@ -1,4 +1,5 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Action Sheet
@ -8,8 +9,9 @@ import {Plugin, Cordova} from './plugin';
* Requires Cordova plugin: `cordova-plugin-actionsheet`. For more info, please see the [ActionSheet plugin docs](https://github.com/EddyVerbruggen/cordova-plugin-actionsheet).
*
* @usage
* ```ts
* import {ActionSheet} from 'ionic-native';
* ```typescript
* import { ActionSheet } from 'ionic-native';
*
*
* let buttonLabels = ['Share via Facebook', 'Share via Twitter'];
* ActionSheet.show({
@ -17,8 +19,8 @@ import {Plugin, Cordova} from './plugin';
* 'buttonLabels': buttonLabels,
* 'addCancelButtonWithLabel': 'Cancel',
* 'addDestructiveButtonWithLabel' : 'Delete'
* }).then(buttonIndex => {
* console.log('Button pressed: ' + buttonLabels[buttonIndex - 1]);
* }).then((buttonIndex: number) => {
* console.log('Button pressed: ' + buttonIndex);
* });
* ```
*
@ -71,4 +73,5 @@ export class ActionSheet {
*/
@Cordova()
static hide(options?: any): Promise<any> { return; }
}

View File

@ -1,5 +1,5 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @name AdMob
@ -22,7 +22,7 @@ export class AdMob {
* @param adIdOrOptions
*/
@Cordova()
static createBanner(adIdOrOptions: any): Promise<any> {return; }
static createBanner(adIdOrOptions: any): Promise<any> { return; }
/**
*
@ -30,7 +30,7 @@ export class AdMob {
@Cordova({
sync: true
})
static removeBanner(): void {}
static removeBanner(): void { }
/**
*
@ -39,7 +39,7 @@ export class AdMob {
@Cordova({
sync: true
})
static showBanner(position: any): void {}
static showBanner(position: any): void { }
/**
*
@ -49,7 +49,7 @@ export class AdMob {
@Cordova({
sync: true
})
static showBannerAtXY(x: number, y: number): void {}
static showBannerAtXY(x: number, y: number): void { }
/**
*
@ -57,14 +57,14 @@ export class AdMob {
@Cordova({
sync: true
})
static hideBanner(): void {}
static hideBanner(): void { }
/**
*
* @param adIdOrOptions
*/
@Cordova()
static prepareInterstitial(adIdOrOptions: any): Promise<any> {return; }
static prepareInterstitial(adIdOrOptions: any): Promise<any> { return; }
/**
* Show interstitial
@ -72,20 +72,20 @@ export class AdMob {
@Cordova({
sync: true
})
static showInterstitial(): void {}
static showInterstitial(): void { }
/**
*
*/
@Cordova()
static isInterstitialReady (): Promise<boolean> {return; }
static isInterstitialReady(): Promise<boolean> { return; }
/**
* Prepare a reward video ad
* @param adIdOrOptions
*/
@Cordova()
static prepareRewardVideoAd(adIdOrOptions: any): Promise<any> {return; }
static prepareRewardVideoAd(adIdOrOptions: any): Promise<any> { return; }
/**
* Show a reward video ad
@ -100,14 +100,14 @@ export class AdMob {
* @param options Returns a promise that resolves if the options are set successfully
*/
@Cordova()
static setOptions(options: any): Promise<any> {return; }
static setOptions(options: any): Promise<any> { return; }
/**
* Get user ad settings
* @returns {Promise<any>} Returns a promise that resolves with the ad settings
*/
@Cordova()
static getAdSettings(): Promise<any> {return; }
static getAdSettings(): Promise<any> { return; }
// Events
@ -115,65 +115,65 @@ export class AdMob {
eventObservable: true,
event: 'onBannerFailedToReceive'
})
static onBannerFailedToReceive (): Observable<any> {return; }
static onBannerFailedToReceive(): Observable<any> { return; }
@Cordova({
eventObservable: true,
event: 'onBannerReceive'
})
static onBannerReceive (): Observable<any> {return; }
static onBannerReceive(): Observable<any> { return; }
@Cordova({
eventObservable: true,
event: 'onBannerPresent'
})
static onBannerPresent (): Observable<any> {return; }
static onBannerPresent(): Observable<any> { return; }
@Cordova({
eventObservable: true,
event: 'onBannerLeaveApp'
})
static onBannerLeaveApp (): Observable<any> {return; }
static onBannerLeaveApp(): Observable<any> { return; }
@Cordova({
eventObservable: true,
event: 'onBannerDismiss'
})
static onBannerDismiss (): Observable<any> {return; }
static onBannerDismiss(): Observable<any> { return; }
@Cordova({
eventObservable: true,
event: 'onInterstitialFailedToReceive'
})
static onInterstitialFailedToReceive (): Observable<any> {return; }
static onInterstitialFailedToReceive(): Observable<any> { return; }
@Cordova({
eventObservable: true,
event: 'onInterstitialReceive'
})
static onInterstitialReceive (): Observable<any> {return; }
static onInterstitialReceive(): Observable<any> { return; }
@Cordova({
eventObservable: true,
event: 'onInterstitialPresent'
})
static onInterstitialPresent (): Observable<any> {return; }
static onInterstitialPresent(): Observable<any> { return; }
@Cordova({
eventObservable: true,
event: 'onInterstitialLeaveApp'
})
static onInterstitialLeaveApp (): Observable<any> {return; }
static onInterstitialLeaveApp(): Observable<any> { return; }
@Cordova({
eventObservable: true,
event: 'onInterstitialDismiss'
})
static onInterstitialDismiss (): Observable<any> {return; }
static onInterstitialDismiss(): Observable<any> { return; }
}

View File

@ -0,0 +1,77 @@
import { Cordova, Plugin } from './plugin';
/**
* @name Android Fingerprint Auth
* @description
* This plugin will open a native dialog fragment prompting the user to authenticate using their fingerprint. If the device has a secure lockscreen (pattern, PIN, or password), the user may opt to authenticate using that method as a backup.
* @usage
* ```typescript
* import { AndroidFingerprintAuth } from 'ionic-native';
*
* AndroidFingerprintAuth.isAvailable()
* .then((result)=> {
* if(result.isAvailable){
* // it is available
*
* AndroidFingerprintAuth.show({ clientId: "myAppName", clientSecret: "so_encrypted_much_secure_very_secret" })
* .then(result => {
* if(result.withFingerprint) {
* console.log('Successfully authenticated with fingerprint!');
* } else if(result.withPassword) {
* console.log('Successfully authenticated with backup password!');
* } else console.log('Didn\'t authenticate!');
* })
* .catch(error => console.error(error));
*
* } else {
* // fingerprint auth isn't available
* }
* })
* .catch(error => console.error(error));
* ```
*/
@Plugin({
plugin: 'cordova-plugin-android-fingerprint-auth',
pluginRef: 'FingerprintAuth',
repo: 'https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth'
})
export class AndroidFingerprintAuth {
/**
* Opens a native dialog fragment to use the device hardware fingerprint scanner to authenticate against fingerprints registered for the device.
* @param params {any}
*/
@Cordova()
static show(params: {
/**
* Used as the alias for your key in the Android Key Store.
*/
clientId: string;
/**
* Used to encrypt the token returned upon successful fingerprint authentication.
*/
clientSecret: string;
/**
* Set to true to remove the "USE BACKUP" button
*/
disableBackup?: boolean;
/**
* Change the language. (en_US or es)
*/
locale?: string
}): Promise<{
/**
* Base64 encoded string
*/
withFingerprint: string;
/**
*
*/
withPassword: boolean;
}> {return; }
/**
* Check if service is available
*/
@Cordova()
static isAvailable(): Promise<{isAvailable: boolean}> {return; }
}

View File

@ -1,4 +1,4 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name App Availability
@ -8,22 +8,22 @@ import {Plugin, Cordova} from './plugin';
* Requires Cordova plugin: cordova-plugin-appavailability. For more info, please see the [AppAvailability plugin docs](https://github.com/ohh2ahh/AppAvailability).
*
* @usage
* ```js
* import {AppAvailability} from 'ionic-native';
* ```typescript
* import { AppAvailability } from 'ionic-native';
*
*
* var app;
* let app;
*
* if(device.platform === 'iOS') {
* if (device.platform === 'iOS') {
* app = 'twitter://';
* }else if(device.platform === 'Android'){
* } else if (device.platform === 'Android') {
* app = 'com.twitter.android';
* }
*
* AppAvailability.check(app)
* .then(
* yes => console.log(app + " is available"),
* no => console.log(app + " is NOT available")
* (yes: string) => console.log(app + ' is available'),
* (no: string) => console.log(app + ' is NOT available')
* );
* ```
*/

View File

@ -1,4 +1,5 @@
import {Plugin, Cordova, CordovaProperty} from './plugin';
import { Cordova, CordovaProperty, Plugin } from './plugin';
declare var window;
@ -10,14 +11,14 @@ declare var window;
* Requires Cordova plugin: cordova-plugin-apprate. For more info, please see the [AppRate plugin docs](https://github.com/pushandplay/cordova-plugin-apprate).
*
* @usage
* ```js
* import {AppRate} from 'ionic-native';
* ```typescript
* import { AppRate } from 'ionic-native';
*
* AppRate.preferences.storeAppURL = {
* ios: '<my_app_id>',
* android: 'market://details?id=<package_name>',
* };
*
* AppRate.preferences.storeAppURL.ios = '<my_app_id>';
* AppRate.preferences.storeAppURL.android = 'market://details?id=<package_name>';
* AppRate.preferences.storeAppURL.blackberry = 'appworld://content/[App Id]/';
* AppRate.preferences.storeAppURL.windows8 = 'ms-windows-store:Review?name=<the Package Family Name of the application>';
* AppRate.promptForRating();
* ```
*
@ -62,6 +63,6 @@ export class AppRate {
* @param {boolean} immediately Show the rating prompt immediately.
*/
@Cordova()
static promptForRating(immediately: boolean): void {};
static promptForRating(immediately: boolean): void { };
}

View File

@ -1,4 +1,4 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name App Version
@ -8,8 +8,8 @@ import {Plugin, Cordova} from './plugin';
* Requires Cordova plugin: `cordova-plugin-app-version`. For more info, please see the [Cordova App Version docs](https://github.com/whiteoctober/cordova-plugin-app-version).
*
* @usage
* ```js
* import {AppVersion} from 'ionic-native';
* ```typescript
* import { AppVersion } from 'ionic-native';
*
*
* AppVersion.getAppName();

View File

@ -1,5 +1,4 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
declare var window;
@ -88,7 +87,7 @@ export interface Config {
* When enabled, the plugin will emit sounds for life-cycle events of
* background-geolocation! See debugging sounds table.
*/
debug: boolean;
debug?: boolean;
/**
* The minimum distance (measured in meters) a device must move horizontally
@ -99,7 +98,9 @@ export interface Config {
/**
* IOS, ANDROID ONLY
* Enable this in order to force a stop() when the application terminated
* (e.g. on iOS, double-tap home button, swipe away the app).
* (e.g. on iOS, double-tap home button, swipe away the app).o
*
* Defaults to true
*/
stopOnTerminate?: boolean;
@ -110,7 +111,7 @@ export interface Config {
* and the MS doc (http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.geolocation.geolocator.reportinterval)
* for more information
*/
locationTimeout?: number;
interval?: number;
/**
* ANDROID ONLY
@ -141,7 +142,7 @@ export interface Config {
* ANDROID ONLY
* Set location service provider @see wiki (https://github.com/mauron85/cordova-plugin-background-geolocation/wiki/Android-providers)
*/
locationService?: number;
locationProvider?: number;
/**
* IOS ONLY
@ -161,9 +162,8 @@ export interface Config {
*
* @usage
*
* ```ts
* import {BackgroundGeolocation} from 'ionic-native';
*
* ```typescript
* import { BackgroundGeolocation } from 'ionic-native';
*
*
* // When device is ready :
@ -178,18 +178,19 @@ export interface Config {
* stopOnTerminate: false, // enable this to clear background location settings when the app terminates
* };
*
* BackgroundGeolocation.configure(config)
* .then((location) => {
* console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude);
*
* // IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished,
* // and the background-task may be completed. You must do this regardless if your HTTP request is successful or not.
* // IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background.
* BackgroundGeolocation.finish(); // FOR IOS ONLY
* })
* .catch((error) => {
* console.log('BackgroundGeolocation error');
* });
* BackgroundGeolocation.configure((location) => {
console.log('[js] BackgroundGeolocation callback: ' + location.latitude + ',' + location.longitude);
// IMPORTANT: You must execute the finish method here to inform the native plugin that you're finished,
// and the background-task may be completed. You must do this regardless if your HTTP request is successful or not.
// IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background.
BackgroundGeolocation.finish(); // FOR IOS ONLY
* }, (error) => {
* console.log('BackgroundGeolocation error');
* }, {
* //options
* });
*
* // Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app.
* BackgroundGeolocation.start();
@ -219,9 +220,9 @@ export class BackgroundGeolocation {
* Options a json object of type Config
*/
@Cordova({
callbackOrder: 'reverse'
sync: true
})
static configure(options: Config): Promise<Location> { return; }
static configure(callback: Function, errorCallback: Function, options: Config): void { return; }
/**

View File

@ -1,4 +1,4 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Background Mode
@ -6,8 +6,8 @@ import {Plugin, Cordova} from './plugin';
* Cordova plugin to prevent the app from going to sleep while in background.
* Requires Cordova plugin: cordova-plugin-background-mode. For more info about plugin, vist: https://github.com/katzer/cordova-plugin-background-mode#android-customization
*@usage
* ```js
* import {BackgroundMode} from 'ionic-native';
* ```typescript
* import { BackgroundMode } from 'ionic-native';
*
* BackgroundMode.enable();
* ```
@ -39,28 +39,28 @@ export class BackgroundMode {
@Cordova({
sync: true
})
static enable(): void {}
static enable(): void { }
/**
* Disable the background mode.
* Once the background mode has been disabled, the app will be paused when in background.
*/
/**
* Disable the background mode.
* Once the background mode has been disabled, the app will be paused when in background.
*/
@Cordova()
static disable(): void {}
static disable(): void { }
/**
* Checks if background mode is enabled or not.
* @returns {boolean} returns a true of false if the background mode is enabled.
*/
@Cordova()
static isEnabled(): Promise<boolean> {return; }
static isEnabled(): Promise<boolean> { return; }
/**
* Can be used to get the information if the background mode is active.
* @returns {boolean} returns tru or flase if the background mode is active.
*/
@Cordova()
static isActive(): Promise<boolean> {return; }
static isActive(): Promise<boolean> { return; }
/**
* Override the default title, ticker and text.
@ -70,7 +70,7 @@ export class BackgroundMode {
@Cordova({
platforms: ['Android']
})
static setDefaults(options?: Configure): void {}
static setDefaults(options?: Configure): void { }
/**
* Modify the displayed information.
@ -80,17 +80,18 @@ export class BackgroundMode {
@Cordova({
platforms: ['Android']
})
static update(options?: Configure): void {}
static update(options?: Configure): void { }
/**
* Sets a callback for a specific event
* Can be used to get notified or run function when the background mode has been activated, deactivated or failed.
* @param eventName The name of the event. Available events: activate, deactivate, failure
* @param {string} eventName The name of the event. Available events: activate, deactivate, failure
*/
@Cordova({
sync: true
})
static on(eventName: string, callback: any): void {}
static on(eventName: string, callback: any): void { }
}
/**

View File

@ -1,4 +1,4 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Badge
@ -8,8 +8,8 @@ import {Plugin, Cordova} from './plugin';
* Requires Cordova plugin: cordova-plugin-badge. For more info, please see the [Badge plugin docs](https://github.com/katzer/cordova-plugin-badge).
*
* @usage
* ```js
* import {Badge} from 'ionic-native';
* ```typescript
* import { Badge } from 'ionic-native';
*
*
* Badge.set(10);
@ -74,4 +74,5 @@ export class Badge {
*/
@Cordova()
static registerPermission(): Promise<any> { return; }
}

View File

@ -1,4 +1,4 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Barcode Scanner
@ -8,8 +8,8 @@ import {Plugin, Cordova} from './plugin';
* Requires Cordova plugin: `phonegap-plugin-barcodescanner`. For more info, please see the [BarcodeScanner plugin docs](https://github.com/phonegap/phonegap-plugin-barcodescanner).
*
* @usage
* ```js
* import {BarcodeScanner} from 'ionic-native';
* ```typescript
* import { BarcodeScanner } from 'ionic-native';
*
*
* BarcodeScanner.scan().then((barcodeData) => {
@ -38,6 +38,7 @@ export class BarcodeScanner {
};
/**
* Open the barcode scanner.
* @param options {Object} Optional options to pass to the scanner
* @return Returns a Promise that resolves with scanner data, or rejects with an error.
*/
@Cordova({
@ -48,10 +49,10 @@ export class BarcodeScanner {
/**
* Encodes data into a barcode.
* NOTE: not well supported on Android
* @param type
* @param data
* @param type {string} Type of encoding
* @param data {any} Data to encode
*/
@Cordova()
static encode(type: string, data: any): Promise<any> {return; }
static encode(type: string, data: any): Promise<any> { return; }
}

View File

@ -1,15 +1,15 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Base64 To Gallery
* @description This plugin allows you to save base64 data as a png image into the device
* @usage
* ```ts
* import {Base64ToGallery} from 'ionic-native';
* ```typescript
* import { Base64ToGallery } from 'ionic-native';
*
*
* Base64ToGallery.base64ToGallery(base64Data, 'img_').then(
* res => console.log("Saved image to gallery ", res),
* err => console.log("Error saving image to gallery ", err)
* res => console.log('Saved image to gallery ', res),
* err => console.log('Error saving image to gallery ', err)
* );
* ```
*/
@ -24,11 +24,11 @@ export class Base64ToGallery {
/**
* Converts a base64 string to an image file in the device gallery
* @param {string} data The actual base64 string that you want to save
* @param {sstring} prefix Prefix the file with a string. Default is 'img_'. Optional.
* @param {any} options (optional) An object with properties: prefix: string, mediaScanner: boolean. Prefix will be prepended to the filename. If true, mediaScanner runs Media Scanner on Android and saves to Camera Roll on iOS; if false, saves to Library folder on iOS.
* @returns {Promise} returns a promise that resolves when the image is saved.
*/
@Cordova()
static base64ToGallery(data: string , prefix?: string ): Promise<any> {
static base64ToGallery(data: string, options?: {prefix?: string; mediaScanner?: boolean}): Promise<any> {
return;
}

View File

@ -1,5 +1,5 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @name Battery Status
@ -7,14 +7,13 @@ import {Observable} from 'rxjs/Observable';
* Requires Cordova plugin: cordova-plugin-batterystatus. For more info, please see the [BatteryStatus plugin docs](https://github.com/apache/cordova-plugin-battery-status).
*
* @usage
* ```js
* import {BatteryStatus} from 'ionic-native';
*
* ```typescript
* import { BatteryStatus } from 'ionic-native';
*
*
* // watch change in battery status
* let subscription = BatteryStatus.onChange().subscribe(
* status => {
* (status: StatusObject) => {
* console.log(status.level, status.isPlugged);
* }
* );
@ -39,7 +38,7 @@ export class BatteryStatus {
eventObservable: true,
event: 'batterystatus'
})
static onChange (): Observable<StatusObject> {return; }
static onChange(): Observable<StatusObject> { return; }
/**
* Watch when the battery level goes low
@ -49,7 +48,7 @@ export class BatteryStatus {
eventObservable: true,
event: 'batterylow'
})
static onLow (): Observable<StatusObject> {return; }
static onLow(): Observable<StatusObject> { return; }
/**
* Watch when the battery level goes to critial
@ -59,7 +58,7 @@ export class BatteryStatus {
eventObservable: true,
event: 'batterycritical'
})
static onCritical (): Observable<StatusObject> {return; }
static onCritical(): Observable<StatusObject> { return; }
}

View File

@ -1,5 +1,5 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @name BLE
@ -24,7 +24,7 @@ import {Observable} from 'rxjs/Observable';
*
* Peripheral Data is passed to the success callback when scanning and connecting. Limited data is passed when scanning.
*
* ```ts
* ```typescript
* {
* "name": "Battery Demo",
* "id": "20:FF:D0:FF:D1:C0",
@ -34,7 +34,7 @@ import {Observable} from 'rxjs/Observable';
* ```
* After connecting, the peripheral object also includes service, characteristic and descriptor information.
*
* ```ts
* ```typescript
* {
* "name": "Battery Demo",
* "id": "20:FF:D0:FF:D1:C0",
@ -93,7 +93,7 @@ import {Observable} from 'rxjs/Observable';
*
* ### Android
*
* ```ts
* ```typescript
* {
* "name": "demo",
* "id": "00:1A:7D:DA:71:13",
@ -108,7 +108,7 @@ import {Observable} from 'rxjs/Observable';
*
* Note that iOS uses the string value of the constants for the [Advertisement Data Retrieval Keys](https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CBCentralManagerDelegate_Protocol/index.html#//apple_ref/doc/constant_group/Advertisement_Data_Retrieval_Keys). This will likely change in the future.
*
* ```ts
* ```typescript
* {
* "name": "demo",
* "id": "D8479A4F-7517-BCD3-91B5-3302B2F81802",
@ -137,7 +137,7 @@ import {Observable} from 'rxjs/Observable';
*
* This means that you need convert your data to ArrayBuffers before sending and from ArrayBuffers when receiving.
*
* ```ts
* ```typescript
* // ASCII only
* function stringToBytes(string) {
* var array = new Uint8Array(string.length);
@ -272,7 +272,7 @@ export class BLE {
deviceId: string,
serviceUUID: string,
characteristicUUID: string
): Promise<any> { return; };
): Promise<any> { return; };
/**
* Write the value of a characteristic.
@ -308,7 +308,7 @@ export class BLE {
serviceUUID: string,
characteristicUUID: string,
value: ArrayBuffer
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Write the value of a characteristic without waiting for confirmation from the peripheral.
@ -325,7 +325,7 @@ export class BLE {
serviceUUID: string,
characteristicUUID: string,
value: ArrayBuffer
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Register to be notified when the value of a characteristic changes.
@ -351,7 +351,7 @@ export class BLE {
deviceId: string,
serviceUUID: string,
characteristicUUID: string
): Observable<any> { return; }
): Observable<any> { return; }
/**
* Stop being notified when the value of a characteristic changes.
@ -366,7 +366,7 @@ export class BLE {
deviceId: string,
serviceUUID: string,
characteristicUUID: string
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Report the connection status.

View File

@ -1,16 +1,19 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @name Bluetooth Serial
* @description This plugin enables serial communication over Bluetooth. It was written for communicating between Android or iOS and an Arduino.
* @usage
* ```ts
* ```typescript
* import { BluetoothSerial } from 'ionic-native';
*
*
* // Write a string
* Bluetooth.write("hello world").then(success, failure);
* BluetoothSerial.write("hello world").then(success, failure);
*
* // Array of int or bytes
* Bluetooth.write([186, 220, 222]).then(success, failure);
* BluetoothSerial.write([186, 220, 222]).then(success, failure);
*
* // Typed Array
* var data = new Uint8Array(4);
@ -18,10 +21,10 @@ import {Observable} from 'rxjs/Observable';
* data[1] = 0x42;
* data[2] = 0x43;
* data[3] = 0x44;
* Bluetooth.write(data).then(success, failure);
* BluetoothSerial.write(data).then(success, failure);
*
* // Array Buffer
* Bluetooth.write(data.buffer).then(success, failure);
* BluetoothSerial.write(data.buffer).then(success, failure);
* ```
*/
@Plugin({
@ -42,7 +45,7 @@ export class BluetoothSerial {
observable: true,
clearFunction: 'disconnect'
})
static connect (macAddress_or_uuid: string): Observable<any> {return; }
static connect(macAddress_or_uuid: string): Observable<any> { return; }
/**
* Connect insecurely to a Bluetooth device
@ -54,7 +57,7 @@ export class BluetoothSerial {
observable: true,
clearFunction: 'disconnect'
})
static connectInsecure (macAddress: string): Observable<any> {return; }
static connectInsecure(macAddress: string): Observable<any> { return; }
/**
* Writes data to the serial port
@ -64,7 +67,7 @@ export class BluetoothSerial {
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static write (data: any): Promise<any> {return; }
static write(data: any): Promise<any> { return; }
/**
* Gets the number of bytes of data available
@ -72,7 +75,7 @@ export class BluetoothSerial {
*/
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
}) static available (): Promise<any> {return; }
}) static available(): Promise<any> { return; }
/**
* Reads data from the buffer
@ -81,7 +84,7 @@ export class BluetoothSerial {
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static read (): Promise<any> {return; }
static read(): Promise<any> { return; }
/**
* Reads data from the buffer until it reaches a delimiter
@ -91,7 +94,7 @@ export class BluetoothSerial {
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static readUntil (delimiter: string): Promise<any> {return; }
static readUntil(delimiter: string): Promise<any> { return; }
/**
* Subscribe to be notified when data is received
@ -103,7 +106,7 @@ export class BluetoothSerial {
observable: true,
clearFunction: 'unsubscribe'
})
static subscribe (delimiter: string): Observable<any> {return; }
static subscribe(delimiter: string): Observable<any> { return; }
/**
* Subscribe to be notified when data is received
@ -114,7 +117,7 @@ export class BluetoothSerial {
observable: true,
clearFunction: 'unsubscribeRawData'
})
static subscribeRawData (): Observable<any> {return; }
static subscribeRawData(): Observable<any> { return; }
/**
* Clears data in buffer
@ -123,7 +126,7 @@ export class BluetoothSerial {
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static clear (): Promise<any> {return; }
static clear(): Promise<any> { return; }
/**
* Lists bonded devices
@ -132,7 +135,7 @@ export class BluetoothSerial {
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static list (): Promise<any> {return; }
static list(): Promise<any> { return; }
/**
* Reports if bluetooth is enabled
@ -141,7 +144,7 @@ export class BluetoothSerial {
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static isEnabled (): Promise<any> {return; }
static isEnabled(): Promise<any> { return; }
/**
* Reports the connection status
@ -150,7 +153,7 @@ export class BluetoothSerial {
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static isConnected (): Promise<any> {return; }
static isConnected(): Promise<any> { return; }
/**
* Reads the RSSI from the connected peripheral
@ -159,7 +162,7 @@ export class BluetoothSerial {
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static readRSSI (): Promise<any> {return; }
static readRSSI(): Promise<any> { return; }
/**
* Show the Bluetooth settings on the device
@ -168,7 +171,7 @@ export class BluetoothSerial {
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static showBluetoothSettings (): Promise<any> {return; }
static showBluetoothSettings(): Promise<any> { return; }
/**
* Enable Bluetooth on the device
@ -177,7 +180,7 @@ export class BluetoothSerial {
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static enable (): Promise<any> {return; }
static enable(): Promise<any> { return; }
/**
* Discover unpaired devices
@ -186,7 +189,7 @@ export class BluetoothSerial {
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static discoverUnpaired (): Promise<any> {return; }
static discoverUnpaired(): Promise<any> { return; }
/**
* Subscribe to be notified on Bluetooth device discovery. Discovery process must be initiated with the `discoverUnpaired` function.
@ -197,7 +200,7 @@ export class BluetoothSerial {
observable: true,
clearFunction: 'clearDeviceDiscoveredListener'
})
static setDeviceDiscoveredListener (): Observable<any> {return; }
static setDeviceDiscoveredListener(): Observable<any> { return; }
/**
* Sets the human readable device name that is broadcasted to other devices
@ -207,7 +210,7 @@ export class BluetoothSerial {
platforms: ['Android'],
sync: true
})
static setName (newName: string): void {}
static setName(newName: string): void { }
/**
* Makes the device discoverable by other devices
@ -217,5 +220,6 @@ export class BluetoothSerial {
platforms: ['Android'],
sync: true
})
static setDiscoverable (discoverableDuration: number): void {}
static setDiscoverable(discoverableDuration: number): void { }
}

View File

@ -1,4 +1,4 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Brightness
@ -8,8 +8,9 @@ import {Plugin, Cordova} from './plugin';
* Requires Cordova plugin: `cordova-plugin-brightness`. For more info, please see the [Brightness plugin docs](https://github.com/mgcrea/cordova-plugin-brightness).
*
* @usage
* ```ts
* import {Brightness} from 'ionic-native';
* ```typescript
* import { Brightness } from 'ionic-native';
*
*
* let brightnessValue: number = 0.8;
* Brightness.setBrightness(brightnessValue);
@ -17,34 +18,35 @@ import {Plugin, Cordova} from './plugin';
*
*/
@Plugin({
plugin: 'cordova-plugin-brightness',
pluginRef: 'plugins.brightness',
repo: 'https://github.com/mgcrea/cordova-plugin-brightness',
platforms: ['Android', 'iOS']
plugin: 'cordova-plugin-brightness',
pluginRef: 'cordova.plugins.brightness',
repo: 'https://github.com/mgcrea/cordova-plugin-brightness',
platforms: ['Android', 'iOS']
})
export class Brightness {
/**
* Sets the brightness of the display.
*
* @param {value} Floating number between 0 and 1 in which case 1 means 100% brightness and 0 means 0% brightness.
* @returns {Promise} Returns a Promise that resolves if setting brightness was successful.
*/
@Cordova()
static setBrightness(value: number): Promise<any> { return; }
/**
* Sets the brightness of the display.
*
* @param {value} Floating number between 0 and 1 in which case 1 means 100% brightness and 0 means 0% brightness.
* @returns {Promise} Returns a Promise that resolves if setting brightness was successful.
*/
@Cordova()
static setBrightness(value: number): Promise<any> { return; }
/**
* Reads the current brightness of the device display.
*
* @returns {Promise} Returns a Promise that resolves with the
* brightness value of the device display (floating number between 0 and 1).
*/
@Cordova()
static getBrightness(): Promise<any> { return; }
/**
* Reads the current brightness of the device display.
*
* @returns {Promise} Returns a Promise that resolves with the
* brightness value of the device display (floating number between 0 and 1).
*/
@Cordova()
static getBrightness(): Promise<any> { return; }
/**
* Keeps the screen on. Prevents the device from setting the screen to sleep.
*/
@Cordova()
static setKeepScreenOn(value: boolean): void { }
/**
* Keeps the screen on. Prevents the device from setting the screen to sleep.
*/
@Cordova()
static setKeepScreenOn(value: boolean): void { }
}

View File

@ -1,5 +1,9 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @private
*/
export interface CalendarOptions {
firstReminderMinutes?: number;
secondReminderMinutes?: number;
@ -11,11 +15,6 @@ export interface CalendarOptions {
url?: string;
}
export interface Calendar {
id: number;
name: string;
}
/**
* @name Calendar
* @description
@ -23,8 +22,19 @@ export interface Calendar {
*
* Requires Cordova plugin: `cordova-plugin-calendar`. For more info, please see the [Calendar plugin docs](https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin).
*
*
* @usage
*
* ```
* import {Calendar} from 'ionic-native';
*
*
*
* Calendar.createCalendar('MyCalendar').then(
* (msg) => { console.log(msg); },
* (err) => { console.log(err); }
* );
* ```
*
*/
@Plugin({
plugin: 'cordova-plugin-calendar',
@ -48,78 +58,54 @@ export class Calendar {
@Cordova()
static hasReadWritePermission(): Promise<boolean> { return; }
/**
* Check if we have read permission
* @returns {Promise<boolean>}
*/
@Cordova()
static hasReadPermission(): Promise<boolean> {return; }
/**
* Check if we have read permission
* @returns {Promise<boolean>}
*/
@Cordova()
static hasReadPermission(): Promise<boolean> { return; }
/**
* Check if we have write permission
* @returns {Promise<boolean>}
*/
@Cordova()
static hasWritePermission(): Promise<boolean> {return; }
/**
* Check if we have write permission
* @returns {Promise<boolean>}
*/
@Cordova()
static hasWritePermission(): Promise<boolean> { return; }
/**
* Request write permission
* @returns {Promise<any>}
*/
@Cordova()
static requestWritePermission(): Promise<any> {return; }
/**
* Request write permission
* @returns {Promise<any>}
*/
@Cordova()
static requestWritePermission(): Promise<any> { return; }
/**
* Request read permission
* @returns {Promise<any>}
*/
@Cordova()
static requestReadPermission(): Promise<any> {return; }
/**
* Request read permission
* @returns {Promise<any>}
*/
@Cordova()
static requestReadPermission(): Promise<any> { return; }
/**
* Requests read/write permissions
* @returns {Promise<any>}
*/
@Cordova()
static requestReadWritePermission(): Promise<any> {return; }
static requestReadWritePermission(): Promise<any> { return; }
/**
* Create a calendar. (iOS only)
*
* @usage
* ```
* import {Calendar} from 'ionic-native';
*
*
*
* Calendar.createCalendar('MyCalendar').then(
* (msg) => { console.log(msg); },
* (err) => { console.log(err); }
* );
* ```
*
* @param {string | Object} nameOrOptions either a string name or a options object.
* options:
* calendarName: string the name of the calendar
* calendarColor: string the hex color of the calendar
* @return Returns a Promise
* @param {string | Object} nameOrOptions either a string name or a options object. If string, provide the calendar name. IF an object, provide a calendar name as a string and a calendar color in hex format as a string
* @return {Promise} Returns a Promise
*/
@Cordova()
static createCalendar(
nameOrOptions: string | { calendarName: string, calendarColor: string }
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Delete a calendar. (iOS only)
*
* @usage
* ```
* Calendar.deleteCalendar('MyCalendar').then(
* (msg) => { console.log(msg); },
* (err) => { console.log(err); }
* );
* ```
*
* @param {string} name Name of the calendar to delete.
* @return Returns a Promise
*/
@ -157,7 +143,6 @@ export class Calendar {
/**
* Silently create an event.
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
@ -172,7 +157,7 @@ export class Calendar {
notes?: string,
startDate?: Date,
endDate?: Date
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Silently create an event with additional options.
@ -193,7 +178,7 @@ export class Calendar {
startDate?: Date,
endDate?: Date,
options?: CalendarOptions
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Interactively create an event.
@ -212,7 +197,7 @@ export class Calendar {
notes?: string,
startDate?: Date,
endDate?: Date
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Interactively create an event with additional options.
@ -233,7 +218,7 @@ export class Calendar {
startDate?: Date,
endDate?: Date,
options?: CalendarOptions
): Promise<any> { return; }
): Promise<any> { return; }
// deprecated
// @Cordova()
@ -263,11 +248,10 @@ export class Calendar {
notes?: string,
startDate?: Date,
endDate?: Date
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Find an event with additional options.
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
@ -284,7 +268,7 @@ export class Calendar {
startDate?: Date,
endDate?: Date,
options?: CalendarOptions
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Find a list of events within the specified date range. (Android only)
@ -337,7 +321,7 @@ export class Calendar {
newNotes?: string,
newStartDate?: Date,
newEndDate?: Date
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Modify an event with additional options. (iOS only)
@ -355,31 +339,31 @@ export class Calendar {
* @param {CalendarOptions} [options] Additional options, see `getCalendarOptions`
* @return Returns a Promise
*/
@Cordova()
static modifyEventWithOptions(
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date,
newTitle?: string,
newLocation?: string,
newNotes?: string,
newStartDate?: Date,
newEndDate?: Date,
options?: CalendarOptions
) { return; }
@Cordova()
static modifyEventWithOptions(
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date,
newTitle?: string,
newLocation?: string,
newNotes?: string,
newStartDate?: Date,
newEndDate?: Date,
options?: CalendarOptions
) { return; }
/**
* Delete an event.
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @return Returns a Promise
*/
/**
* Delete an event.
*
* @param {string} [title] The event title
* @param {string} [location] The event location
* @param {string} [notes] The event notes
* @param {Date} [startDate] The event start date
* @param {Date} [endDate] The event end date
* @return Returns a Promise
*/
@Cordova()
static deleteEvent(
title?: string,
@ -387,7 +371,7 @@ export class Calendar {
notes?: string,
startDate?: Date,
endDate?: Date
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Delete an event from the specified Calendar. (iOS only)
@ -400,20 +384,22 @@ export class Calendar {
* @param {string} calendarName
* @return Returns a Promise
*/
@Cordova()
static deleteEventFromNamedCalendar(
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date,
calendarName?: string
): Promise<any> { return; }
@Cordova()
static deleteEventFromNamedCalendar(
title?: string,
location?: string,
notes?: string,
startDate?: Date,
endDate?: Date,
calendarName?: string
): Promise<any> { return; }
/**
* Open the calendar at the specified date.
* @return {Date} date
* @param {Date} date The date you want to open the calendar on
* @return {Promise<any>} Promise returns a promise
*/
@Cordova()
static openCalendar(date: Date): Promise<any> { return; }
}

View File

@ -0,0 +1,124 @@
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
export interface CameraPreviewRect {
x: number;
y: number;
width: number;
height: number;
}
export interface CameraPreviewSize {
maxWidth: number;
maxHeight: number;
}
/**
* @name CameraPreview
* @description
* Showing camera preview in HTML
*
* For more info, please see the [Cordova Camera Preview Plugin Docs](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview).
*
*/
@Plugin({
plugin: 'cordova-plugin-camera-preview',
pluginRef: 'cordova.plugins.camerapreview',
repo: 'https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview',
platforms: ['Android', 'iOS']
})
export class CameraPreview {
/**
* Starts the camera preview instance.
* @param {CameraPreviewRect} position and size of the preview window - {x: number, y: number, width: number, height: number}
* @param {string} which camera to use - 'front' | 'back'
* @param {boolean} enable tap to take picture
* @param {boolean} enable preview box drag across the screen
* @param {boolean} send preview box to the back of the webview
* @param {number} alpha of the preview box
*/
@Cordova({
sync: true
})
static startCamera(rect: CameraPreviewRect, defaultCamera: string, tapEnabled: boolean, dragEnabled: boolean, toBack: boolean, alpha: number): void {
};
/**
* Stops the camera preview instance.
*/
@Cordova({
sync: true
})
static stopCamera(): void { };
/**
* Take the picture, the parameter size is optional
* @param {CameraPreviewSize} optional - size of the picture to take
*/
@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

@ -1,67 +1,67 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
export interface CameraOptions {
/** Picture quality in range 0-100. Default is 50 */
quality?: number;
/**
* Choose the format of the return value.
* Defined in navigator.camera.DestinationType. Default is FILE_URI.
* DATA_URL : 0, Return image as base64-encoded string
* FILE_URI : 1, Return image file URI
* NATIVE_URI : 2 Return image native URI
* (e.g., assets-library:// on iOS or content:// on Android)
*/
destinationType?: number;
/**
* Set the source of the picture.
* Defined in navigator.camera.PictureSourceType. Default is CAMERA.
* PHOTOLIBRARY : 0,
* CAMERA : 1,
* SAVEDPHOTOALBUM : 2
*/
sourceType?: number;
/** Allow simple editing of image before selection. */
allowEdit?: boolean;
/**
* Choose the returned image file's encoding.
* Defined in navigator.camera.EncodingType. Default is JPEG
* JPEG : 0 Return JPEG encoded image
* PNG : 1 Return PNG encoded image
*/
encodingType?: number;
/**
* Width in pixels to scale image. Must be used with targetHeight.
* Aspect ratio remains constant.
*/
targetWidth?: number;
/**
* Height in pixels to scale image. Must be used with targetWidth.
* Aspect ratio remains constant.
*/
targetHeight?: number;
/**
* Set the type of media to select from. Only works when PictureSourceType
* is PHOTOLIBRARY or SAVEDPHOTOALBUM. Defined in nagivator.camera.MediaType
* PICTURE: 0 allow selection of still pictures only. DEFAULT.
* Will return format specified via DestinationType
* VIDEO: 1 allow selection of video only, WILL ALWAYS RETURN FILE_URI
* ALLMEDIA : 2 allow selection from all media types
*/
mediaType?: number;
/** Rotate the image to correct for the orientation of the device during capture. */
correctOrientation?: boolean;
/** Save the image to the photo album on the device after capture. */
saveToPhotoAlbum?: boolean;
/**
* Choose the camera to use (front- or back-facing).
* Defined in navigator.camera.Direction. Default is BACK.
* FRONT: 0
* BACK: 1
*/
cameraDirection?: number;
/** iOS-only options that specify popover location in iPad. Defined in CameraPopoverOptions. */
popoverOptions?: CameraPopoverOptions;
/** Picture quality in range 0-100. Default is 50 */
quality?: number;
/**
* Choose the format of the return value.
* Defined in navigator.camera.DestinationType. Default is FILE_URI.
* DATA_URL : 0, Return image as base64-encoded string
* FILE_URI : 1, Return image file URI
* NATIVE_URI : 2 Return image native URI
* (e.g., assets-library:// on iOS or content:// on Android)
*/
destinationType?: number;
/**
* Set the source of the picture.
* Defined in navigator.camera.PictureSourceType. Default is CAMERA.
* PHOTOLIBRARY : 0,
* CAMERA : 1,
* SAVEDPHOTOALBUM : 2
*/
sourceType?: number;
/** Allow simple editing of image before selection. */
allowEdit?: boolean;
/**
* Choose the returned image file's encoding.
* Defined in navigator.camera.EncodingType. Default is JPEG
* JPEG : 0 Return JPEG encoded image
* PNG : 1 Return PNG encoded image
*/
encodingType?: number;
/**
* Width in pixels to scale image. Must be used with targetHeight.
* Aspect ratio remains constant.
*/
targetWidth?: number;
/**
* Height in pixels to scale image. Must be used with targetWidth.
* Aspect ratio remains constant.
*/
targetHeight?: number;
/**
* Set the type of media to select from. Only works when PictureSourceType
* is PHOTOLIBRARY or SAVEDPHOTOALBUM. Defined in nagivator.camera.MediaType
* PICTURE: 0 allow selection of still pictures only. DEFAULT.
* Will return format specified via DestinationType
* VIDEO: 1 allow selection of video only, WILL ALWAYS RETURN FILE_URI
* ALLMEDIA : 2 allow selection from all media types
*/
mediaType?: number;
/** Rotate the image to correct for the orientation of the device during capture. */
correctOrientation?: boolean;
/** Save the image to the photo album on the device after capture. */
saveToPhotoAlbum?: boolean;
/**
* Choose the camera to use (front- or back-facing).
* Defined in navigator.camera.Direction. Default is BACK.
* FRONT: 0
* BACK: 1
*/
cameraDirection?: number;
/** iOS-only options that specify popover location in iPad. Defined in CameraPopoverOptions. */
popoverOptions?: CameraPopoverOptions;
}
/**
@ -69,20 +69,20 @@ export interface CameraOptions {
* of the popover when selecting images from an iPad's library or album.
*/
export interface CameraPopoverOptions {
x: number;
y: number;
width: number;
height: number;
/**
* Direction the arrow on the popover should point. Defined in Camera.PopoverArrowDirection
* Matches iOS UIPopoverArrowDirection constants.
* ARROW_UP : 1,
* ARROW_DOWN : 2,
* ARROW_LEFT : 4,
* ARROW_RIGHT : 8,
* ARROW_ANY : 15
*/
arrowDir: number;
x: number;
y: number;
width: number;
height: number;
/**
* Direction the arrow on the popover should point. Defined in Camera.PopoverArrowDirection
* Matches iOS UIPopoverArrowDirection constants.
* ARROW_UP : 1,
* ARROW_DOWN : 2,
* ARROW_LEFT : 4,
* ARROW_RIGHT : 8,
* ARROW_ANY : 15
*/
arrowDir: number;
}
/**
@ -93,14 +93,16 @@ export interface CameraPopoverOptions {
* Requires {@link module:driftyco/ionic-native} and the Cordova plugin: `cordova-plugin-camera`. For more info, please see the [Cordova Camera Plugin Docs](https://github.com/apache/cordova-plugin-camera).
*
* @usage
* ```js
* import {Camera} from 'ionic-native';
* ```typescript
* import { Camera } from 'ionic-native';
*
*
* Camera.getPicture(options).then((imageData) => {
* // imageData is either a base64 encoded string or a file URI
* // If it's base64:
* let base64Image = "data:image/jpeg;base64," + imageData;
* let base64Image = 'data:image/jpeg;base64,' + imageData;
* }, (err) => {
* // Handle error
* });
* ```
*/
@ -111,31 +113,11 @@ export interface CameraPopoverOptions {
platforms: ['Android', 'BlackBerry', 'Browser', 'Firefox', 'FireOS', 'iOS', 'Windows', 'Windows Phone 8', 'Ubuntu']
})
export class Camera {
/**
* Take a picture or video, or load one from the library.
* @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'
})
static getPicture(options: CameraOptions): Promise<any> { return; }
/**
* Remove intermediate image files that are kept in temporary storage after calling camera.getPicture.
* Applies only when the value of Camera.sourceType equals Camera.PictureSourceType.CAMERA and the Camera.destinationType equals Camera.DestinationType.FILE_URI.
* @return Returns a Promise
*/
@Cordova({
platforms: ['iOS']
})
static cleanup() { };
/**
* @private
* @enum {number}
*/
static DestinationType = {
public static DestinationType = {
/** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible */
DATA_URL: 0,
/** Return file uri (content://media/external/images/media/2 for Android) */
@ -148,7 +130,7 @@ export class Camera {
* @private
* @enum {number}
*/
static EncodingType = {
public static EncodingType = {
/** Return JPEG encoded image */
JPEG: 0,
/** Return PNG encoded image */
@ -158,26 +140,26 @@ export class Camera {
* @private
* @enum {number}
*/
static MediaType = {
public static MediaType = {
/** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */
PICTURE: 0,
/** Allow selection of video only, ONLY RETURNS URL */
VIDEO: 1,
/** Allow selection from all media types */
ALLMEDIA : 2
ALLMEDIA: 2
};
/**
* @private
* @enum {number}
*/
static PictureSourceType = {
public static PictureSourceType = {
/** Choose image from picture library (same as SAVEDPHOTOALBUM for Android) */
PHOTOLIBRARY : 0,
PHOTOLIBRARY: 0,
/** Take picture from camera */
CAMERA : 1,
CAMERA: 1,
/** Choose image from picture library (same as PHOTOLIBRARY for Android) */
SAVEDPHOTOALBUM : 2
SAVEDPHOTOALBUM: 2
};
/**
@ -185,25 +167,43 @@ export class Camera {
* Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover.
* @enum {number}
*/
static PopoverArrowDirection = {
ARROW_UP : 1,
ARROW_DOWN : 2,
ARROW_LEFT : 4,
ARROW_RIGHT : 8,
ARROW_ANY : 15
public static PopoverArrowDirection = {
ARROW_UP: 1,
ARROW_DOWN: 2,
ARROW_LEFT: 4,
ARROW_RIGHT: 8,
ARROW_ANY: 15
};
/**
* @private
* @enum {number}
*/
static Direction = {
public static Direction = {
/** Use the back-facing camera */
BACK: 0,
/** Use the front-facing camera */
FRONT: 1
};
/**
* Take a picture or video, or load one from the library.
* @param {CameraOptions?} options Options that you want to pass to the camera. Encoding type, quality, etc. Optional
* @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'
})
static getPicture(options?: CameraOptions): Promise<any> { return; }
/**
* Remove intermediate image files that are kept in temporary storage after calling camera.getPicture.
* Applies only when the value of Camera.sourceType equals Camera.PictureSourceType.CAMERA and the Camera.destinationType equals Camera.DestinationType.FILE_URI.
* @return Returns a Promise
*/
@Cordova({
platforms: ['iOS']
})
static cleanup() { };
}

View File

@ -1,13 +1,13 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name CardIO
* @description
* @usage
* ```
* import {CardIO} from 'ionic-native';
* import { CardIO } from 'ionic-native';
*
* ...
*
* CardIO.canScan()
* .then(
@ -25,49 +25,50 @@ import {Plugin, Cordova} from './plugin';
* ```
*/
@Plugin({
plugin: 'https://github.com/card-io/card.io-Cordova-Plugin',
pluginRef: 'CardIO',
repo: 'https://github.com/card-io/card.io-Cordova-Plugin',
platforms: ['iOS', 'Android']
plugin: 'https://github.com/card-io/card.io-Cordova-Plugin',
pluginRef: 'CardIO',
repo: 'https://github.com/card-io/card.io-Cordova-Plugin',
platforms: ['iOS', 'Android']
})
export class CardIO {
/**
* Check whether card scanning is currently available. (May vary by
* device, OS version, network connectivity, etc.)
*
*/
@Cordova()
static canScan(): Promise<boolean> {return; }
/**
* Check whether card scanning is currently available. (May vary by
* device, OS version, network connectivity, etc.)
*
*/
@Cordova()
static canScan(): Promise<boolean> { return; }
/**
* Scan a credit card with card.io.
* @param {CardIOOptions} options Options for configuring the plugin
*/
@Cordova()
static scan(options?: CardIOOptions): Promise<any> {return; }
/**
* Scan a credit card with card.io.
* @param {CardIOOptions} options Options for configuring the plugin
*/
@Cordova()
static scan(options?: CardIOOptions): Promise<any> { return; }
/**
* Retrieve the version of the card.io library. Useful when contacting support.
*/
@Cordova()
static version(): Promise<string> { return; }
/**
* Retrieve the version of the card.io library. Useful when contacting support.
*/
@Cordova()
static version(): Promise<string> {return; }
}
export interface CardIOOptions {
requireExpiry?: boolean;
requireCCV?: boolean;
requirePostalCode?: boolean;
supressManual?: boolean;
restrictPostalCodeToNumericOnly?: boolean;
keepApplicationTheme?: boolean;
requireCardholderName?: boolean;
scanInstructions?: string;
noCamera?: boolean;
scanExpiry?: boolean;
languageOrLocale?: string;
guideColor?: string;
supressConfirmation?: boolean;
hideCardIOLogo?: boolean;
useCardIOLogo?: boolean;
supressScan?: boolean;
requireExpiry?: boolean;
requireCCV?: boolean;
requirePostalCode?: boolean;
supressManual?: boolean;
restrictPostalCodeToNumericOnly?: boolean;
keepApplicationTheme?: boolean;
requireCardholderName?: boolean;
scanInstructions?: string;
noCamera?: boolean;
scanExpiry?: boolean;
languageOrLocale?: string;
guideColor?: string;
supressConfirmation?: boolean;
hideCardIOLogo?: boolean;
useCardIOLogo?: boolean;
supressScan?: boolean;
}

View File

@ -1,4 +1,5 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Clipboard
@ -9,19 +10,18 @@ import {Plugin, Cordova} from './plugin';
* For more info, please see the [Clipboard plugin docs](https://github.com/VersoSolutions/CordovaClipboard.git).
*
* @usage
* ```js
* import {Clipboard} from 'ionic-native';
* ```typescript
* import { Clipboard } from 'ionic-native';
*
*
*
* Clipboard.copy("Hello world");
* Clipboard.copy('Hello world');
*
* Clipboard.paste().then(
* (resolve : string) => {
* (resolve: string) => {
* alert(resolve);
* },
* (reject : string) => {
* alert("Error: " + reject);
* (reject: string) => {
* alert('Error: ' + reject);
* }
* );
* );

View File

@ -1,235 +1,253 @@
import {Plugin, Cordova, InstanceProperty, CordovaInstance} from './plugin';
declare var window: any,
navigator: any;
export interface IContactProperties {
/** A globally unique identifier. */
id?: string;
/** The name of this Contact, suitable for display to end users. */
displayName?: string;
/** An object containing all components of a persons name. */
name?: ContactName;
/** A casual name by which to address the contact. */
nickname?: string;
/** An array of all the contact's phone numbers. */
phoneNumbers?: IContactField[];
/** An array of all the contact's email addresses. */
emails?: IContactField[];
/** An array of all the contact's addresses. */
addresses?: ContactAddress[];
/** An array of all the contact's IM addresses. */
ims?: IContactField[];
/** An array of all the contact's organizations. */
organizations?: ContactOrganization[];
/** The birthday of the contact. */
birthday?: Date;
/** A note about the contact. */
note?: string;
/** An array of the contact's photos. */
photos?: IContactField[];
/** An array of all the user-defined categories associated with the contact. */
categories?: IContactField[];
/** An array of web pages associated with the contact. */
urls?: IContactField[];
}
import { Cordova, CordovaInstance, InstanceProperty, Plugin } from './plugin';
declare var window: any,
navigator: any;
export interface IContactProperties {
/** A globally unique identifier. */
id?: string;
/** The name of this Contact, suitable for display to end users. */
displayName?: string;
/** An object containing all components of a persons name. */
name?: IContactName;
/** A casual name by which to address the contact. */
nickname?: string;
/** An array of all the contact's phone numbers. */
phoneNumbers?: IContactField[];
/** An array of all the contact's email addresses. */
emails?: IContactField[];
/** An array of all the contact's addresses. */
addresses?: IContactAddress[];
/** An array of all the contact's IM addresses. */
ims?: IContactField[];
/** An array of all the contact's organizations. */
organizations?: IContactOrganization[];
/** The birthday of the contact. */
birthday?: Date;
/** A note about the contact. */
note?: string;
/** An array of the contact's photos. */
photos?: IContactField[];
/** An array of all the user-defined categories associated with the contact. */
categories?: IContactField[];
/** An array of web pages associated with the contact. */
urls?: IContactField[];
}
/**
* @private
*/
export class Contact {
private _objectInstance: any;
@InstanceProperty get id(): string {return; }
@InstanceProperty get displayName(): string {return; }
@InstanceProperty get nickname(): ContactName {return; }
@InstanceProperty get phoneNumbers(): string {return; }
@InstanceProperty get emails(): IContactField[] {return; }
@InstanceProperty get addresses(): ContactAddress[] {return; }
@InstanceProperty get ims(): IContactField[] {return; }
@InstanceProperty get organizations(): ContactOrganization[] {return; }
@InstanceProperty get birthday(): Date {return; }
@InstanceProperty get note(): string {return; }
@InstanceProperty get photos(): IContactField[] {return; }
@InstanceProperty get categories(): IContactField[] {return; }
@InstanceProperty get urls(): IContactField[] {return; }
constructor () {
this._objectInstance = navigator.contacts.create();
export class Contact implements IContactProperties {
private _objectInstance: any;
@InstanceProperty get id(): string { return; }
@InstanceProperty get displayName(): string { return; }
@InstanceProperty get name(): IContactName {return; }
@InstanceProperty get nickname(): string { return; }
@InstanceProperty get phoneNumbers(): IContactField[] { return; }
@InstanceProperty get emails(): IContactField[] { return; }
@InstanceProperty get addresses(): IContactAddress[] { return; }
@InstanceProperty get ims(): IContactField[] { return; }
@InstanceProperty get organizations(): IContactOrganization[] { return; }
@InstanceProperty get birthday(): Date { return; }
@InstanceProperty get note(): string { return; }
@InstanceProperty get photos(): IContactField[] { return; }
@InstanceProperty get categories(): IContactField[] { return; }
@InstanceProperty get urls(): IContactField[] { return; }
constructor() {
this._objectInstance = navigator.contacts.create();
}
clone(): Contact {
let newContact = new Contact();
for (let prop in this) {
if (prop === 'id') return;
newContact[prop] = this[prop];
}
clone(): Contact {
let newContact = new Contact();
for (let prop in this) {
if (prop === 'id') return;
newContact[prop] = this[prop];
}
return newContact;
}
@CordovaInstance()
remove(): Promise<any> {return; }
@CordovaInstance()
save(): Promise<any> {return; }
return newContact;
}
@CordovaInstance()
remove(): Promise<any> { return; }
@CordovaInstance()
save(): Promise<any> { return; }
}
interface IContactError {
/** Error code */
code: number;
/** Error message */
message: string;
/** Error code */
code: number;
/** Error message */
message: string;
}
declare var ContactError: {
new(code: number): IContactError;
UNKNOWN_ERROR: number;
INVALID_ARGUMENT_ERROR: number;
TIMEOUT_ERROR: number;
PENDING_OPERATION_ERROR: number;
IO_ERROR: number;
NOT_SUPPORTED_ERROR: number;
PERMISSION_DENIED_ERROR: number
new (code: number): IContactError;
UNKNOWN_ERROR: number;
INVALID_ARGUMENT_ERROR: number;
TIMEOUT_ERROR: number;
PENDING_OPERATION_ERROR: number;
IO_ERROR: number;
NOT_SUPPORTED_ERROR: number;
PERMISSION_DENIED_ERROR: number
};
export interface IContactName {
/** The complete name of the contact. */
formatted?: string;
/** The contact's family name. */
familyName?: string;
/** The contact's given name. */
givenName?: string;
/** The contact's middle name. */
middleName?: string;
/** The contact's prefix (example Mr. or Dr.) */
honorificPrefix?: string;
/** The contact's suffix (example Esq.). */
honorificSuffix?: string;
/** The complete name of the contact. */
formatted?: string;
/** The contact's family name. */
familyName?: string;
/** The contact's given name. */
givenName?: string;
/** The contact's middle name. */
middleName?: string;
/** The contact's prefix (example Mr. or Dr.) */
honorificPrefix?: string;
/** The contact's suffix (example Esq.). */
honorificSuffix?: string;
}
/**
* @private
*/
export class ContactName implements IContactName {
private _objectInstance: any;
constructor(formatted?: string, familyName?: string, givenName?: string, middleName?: string, honorificPrefix?: string, honorificSuffix?: string) {
this._objectInstance = new window.ContactName(formatted, familyName, givenName, middleName, honorificPrefix, honorificSuffix);
}
@InstanceProperty get formatted(): string {return; }
@InstanceProperty get familyName(): string {return; }
@InstanceProperty get givenName(): string {return; }
@InstanceProperty get middleName(): string {return; }
@InstanceProperty get honorificPrefix(): string {return; }
@InstanceProperty get honorificSuffix(): string {return; }
private _objectInstance: any;
constructor(formatted?: string, familyName?: string, givenName?: string, middleName?: string, honorificPrefix?: string, honorificSuffix?: string) {
this._objectInstance = new window.ContactName(formatted, familyName, givenName, middleName, honorificPrefix, honorificSuffix);
}
@InstanceProperty get formatted(): string { return; }
@InstanceProperty get familyName(): string { return; }
@InstanceProperty get givenName(): string { return; }
@InstanceProperty get middleName(): string { return; }
@InstanceProperty get honorificPrefix(): string { return; }
@InstanceProperty get honorificSuffix(): string { return; }
}
export interface IContactField {
/** A string that indicates what type of field this is, home for example. */
type: string;
/** The value of the field, such as a phone number or email address. */
value: string;
/** Set to true if this ContactField contains the user's preferred value. */
pref: boolean;
/** A string that indicates what type of field this is, home for example. */
type: string;
/** The value of the field, such as a phone number or email address. */
value: string;
/** Set to true if this ContactField contains the user's preferred value. */
pref: boolean;
}
/**
* @private
*/
export class ContactField implements IContactField {
private _objectInstance: any;
constructor(type?: string, value?: string, pref?: boolean) {
this._objectInstance = new window.ContactField(type, value, pref);
}
@InstanceProperty get type(): string {return; }
@InstanceProperty get value(): string {return; }
@InstanceProperty get pref(): boolean {return; }
private _objectInstance: any;
constructor(type?: string, value?: string, pref?: boolean) {
this._objectInstance = new window.ContactField(type, value, pref);
}
@InstanceProperty get type(): string { return; }
@InstanceProperty get value(): string { return; }
@InstanceProperty get pref(): boolean { return; }
}
export interface IContactAddress {
/** Set to true if this ContactAddress contains the user's preferred value. */
pref?: boolean;
/** A string indicating what type of field this is, home for example. */
type?: string;
/** The full address formatted for display. */
formatted?: string;
/** The full street address. */
streetAddress?: string;
/** The city or locality. */
locality?: string;
/** The state or region. */
region?: string;
/** The zip code or postal code. */
postalCode?: string;
/** The country name. */
country?: string;
/** Set to true if this ContactAddress contains the user's preferred value. */
pref?: boolean;
/** A string indicating what type of field this is, home for example. */
type?: string;
/** The full address formatted for display. */
formatted?: string;
/** The full street address. */
streetAddress?: string;
/** The city or locality. */
locality?: string;
/** The state or region. */
region?: string;
/** The zip code or postal code. */
postalCode?: string;
/** The country name. */
country?: string;
}
/**
* @private
*/
export class ContactAddress implements IContactAddress {
private _objectInstance: any;
constructor (pref?: boolean,
type?: string,
formatted?: string,
streetAddress?: string,
locality?: string,
region?: string,
postalCode?: string,
country?: string) {
this._objectInstance = new window.ContactAddress(pref, type, formatted, streetAddress, locality, region, postalCode, country);
}
@InstanceProperty get pref(): boolean {return; }
@InstanceProperty get type(): string {return; }
@InstanceProperty get formatted(): string {return; }
@InstanceProperty get streetAddress(): string {return; }
@InstanceProperty get locality(): string {return; }
@InstanceProperty get region(): string {return; }
@InstanceProperty get postalCode(): string {return; }
@InstanceProperty get country(): string {return; }
private _objectInstance: any;
constructor(pref?: boolean,
type?: string,
formatted?: string,
streetAddress?: string,
locality?: string,
region?: string,
postalCode?: string,
country?: string) {
this._objectInstance = new window.ContactAddress(pref, type, formatted, streetAddress, locality, region, postalCode, country);
}
@InstanceProperty get pref(): boolean { return; }
@InstanceProperty get type(): string { return; }
@InstanceProperty get formatted(): string { return; }
@InstanceProperty get streetAddress(): string { return; }
@InstanceProperty get locality(): string { return; }
@InstanceProperty get region(): string { return; }
@InstanceProperty get postalCode(): string { return; }
@InstanceProperty get country(): string { return; }
}
export interface IContactOrganization {
/** Set to true if this ContactOrganization contains the user's preferred value. */
pref?: boolean;
/** A string that indicates what type of field this is, home for example. */
type?: string;
/** The name of the organization. */
name?: string;
/** The department the contract works for. */
department?: string;
/** The contact's title at the organization. */
title?: string;
/** Set to true if this ContactOrganization contains the user's preferred value. */
pref?: boolean;
/** A string that indicates what type of field this is, home for example. */
type?: string;
/** The name of the organization. */
name?: string;
/** The department the contract works for. */
department?: string;
/** The contact's title at the organization. */
title?: string;
}
/**
* @private
*/
export class ContactOrganization implements IContactOrganization {
private _objectInstance: any;
constructor () {
this._objectInstance = new window.ContactOrganization();
}
@InstanceProperty get pref(): boolean {return; }
@InstanceProperty get type(): string {return; }
@InstanceProperty get name(): string {return; }
@InstanceProperty get department(): string {return; }
@InstanceProperty get title(): string {return; }
private _objectInstance: any;
constructor() {
this._objectInstance = new window.ContactOrganization();
}
@InstanceProperty get pref(): boolean { return; }
@InstanceProperty get type(): string { return; }
@InstanceProperty get name(): string { return; }
@InstanceProperty get department(): string { return; }
@InstanceProperty get title(): string { return; }
}
/** Search options to filter navigator.contacts. */
export interface IContactFindOptions {
/** The search string used to find navigator.contacts. */
filter?: string;
/** Determines if the find operation returns multiple navigator.contacts. */
multiple?: boolean;
/* Contact fields to be returned back. If specified, the resulting Contact object only features values for these fields. */
desiredFields?: string[];
/** The search string used to find navigator.contacts. */
filter?: string;
/** Determines if the find operation returns multiple navigator.contacts. */
multiple?: boolean;
/* Contact fields to be returned back. If specified, the resulting Contact object only features values for these fields. */
desiredFields?: string[];
}
/**
* @private
*/
export class ContactFindOptions implements IContactFindOptions {
private _objectInstance: any;
constructor () {
this._objectInstance = new window.ContactFindOptions();
}
@InstanceProperty get filter(): string {return; }
@InstanceProperty get multiple(): boolean {return; }
@InstanceProperty get desiredFields(): any {return; }
@InstanceProperty get hasPhoneNumber(): boolean {return; }
private _objectInstance: any;
constructor() {
this._objectInstance = new window.ContactFindOptions();
}
@InstanceProperty get filter(): string { return; }
@InstanceProperty get multiple(): boolean { return; }
@InstanceProperty get desiredFields(): any { return; }
@InstanceProperty get hasPhoneNumber(): boolean { return; }
}
/**
@ -239,16 +257,15 @@ export class ContactFindOptions implements IContactFindOptions {
*
* @usage
*
* ```js
* import {Contact} from 'ionic-native';
*
* ```typescript
* import { Contact } from 'ionic-native';
*
*
* let contact = new Contact();
* contact.displayName = "Mr. Ionitron";
* contact.displayName = 'Mr. Ionitron';
* contact.save().then(
* () => console.log("Contact saved!", contact),
* (error: any) => console.error("Error saving contact.", error)
* () => console.log('Contact saved!', contact),
* (error: any) => console.error('Error saving contact.', error)
* );
* ```
*
@ -260,9 +277,10 @@ export class ContactFindOptions implements IContactFindOptions {
repo: 'https://github.com/apache/cordova-plugin-contacts'
})
export class Contacts {
static create(): Contact {
return new Contact();
}
static create(): Contact {
return new Contact();
}
/**
* Search for contacts in the Contacts list.
* @param fields {string[]} Contact fields to be used as a search qualifier.
@ -282,10 +300,12 @@ export class Contacts {
errorIndex: 2
})
static find(fields: string[], options?: any): Promise<any> { return; }
/**
* Select a single Contact.
* @return Returns a Promise that resolves with the selected Contact
*/
@Cordova()
static pickContact(): Promise<any> {return; }
static pickContact(): Promise<any> { return; }
}

34
src/plugins/crop.ts Normal file
View File

@ -0,0 +1,34 @@
import {Cordova, Plugin} from './plugin';
/**
* @name Crop
* @description Crops images
* @usage
* ```
* import {Crop} from 'ionic-native';
*
* ...
*
* Crop.crop('path/to/image.jpg', {quality: 75})
* .then(
* newImage => console.log("new image path is: " + newImage),
* error => console.error("Error cropping image", error)
* );
* ```
*/
@Plugin({
plugin: 'cordova-plugin-crop',
pluginRef: 'plugins',
repo: 'https://github.com/jeduan/cordova-plugin-crop'
})
export class Crop {
/**
* Crops an image
* @param pathToImage
* @param options
* @return {Promise<string>} Returns a promise that resolves with the new image path, or rejects if failed to crop.
*/
@Cordova({
callbackOrder: 'reverse'
})
static crop(pathToImage: string, options?: {quality: number}): Promise<string> {return; }
}

View File

@ -1,4 +1,5 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
export interface DatePickerOptions {
/**
@ -12,7 +13,7 @@ export interface DatePickerOptions {
* Platforms: iOS, Android, Windows
* Selected date
*/
date: Date;
date: Date | string | number;
/**
* Platforms: iOS, Android, Windows
@ -20,7 +21,7 @@ export interface DatePickerOptions {
* Type: Date | empty String
* Default: empty String
*/
minDate?: Date;
minDate?: Date | string | number;
/**
* Platforms?: iOS, Android, Windows
@ -28,7 +29,7 @@ export interface DatePickerOptions {
* Type?: Date | empty String
* Default?: empty String
*/
maxDate?: Date;
maxDate?: Date | string | number;
/**
* Platforms?: Android
@ -73,16 +74,16 @@ export interface DatePickerOptions {
* Requires Cordova plugin: `cordova-plugin-datepicker`. For more info, please see the [DatePicker plugin docs](https://github.com/VitaliiBlagodir/cordova-plugin-datepicker).
*
* @usage
* ```js
* import {DatePicker} from 'ionic-native';
* ```typescript
* import { DatePicker } from 'ionic-native';
*
*
* DatePicker.show({
* date: new Date(),
* mode: 'date'
* }).then(
* date => console.log("Got date: ", date),
* err => console.log("Error occurred while getting date:", err)
* date => console.log('Got date: ', date),
* err => console.log('Error occurred while getting date: ', err)
* );
* ```
*

View File

@ -1,12 +1,13 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @name DB Meter
* @description This plugin defines a global DBMeter object, which permits to get the decibel values from the microphone.
* @usage
* ```ts
* import {DBMeter} from 'ionic-native';
*
* ```typescript
* import { DBMeter } from 'ionic-native';
*
*
* // Start listening
@ -16,7 +17,7 @@ import {Observable} from 'rxjs/Observable';
*
* // Check if we are listening
* DBMeter.isListening().then(
* (isListening : boolean) => console.log(isListening)
* (isListening: boolean) => console.log(isListening)
* );
*
* // Stop listening
@ -24,8 +25,8 @@ import {Observable} from 'rxjs/Observable';
*
* // Delete DBMeter instance from memory
* DBMeter.delete().then(
* () => console.log("Deleted DB Meter instance"),
* error => console.log("Error occurred while deleting DB Meter instance")
* () => console.log('Deleted DB Meter instance'),
* error => console.log('Error occurred while deleting DB Meter instance')
* );
* ```
*/
@ -45,27 +46,27 @@ export class DBMeter {
observable: true,
clearFunction: 'stop'
})
static start (): Observable<any> {return; }
static start(): Observable<any> { return; }
/**
* Stops listening
* @private
*/
@Cordova()
static stop (): Promise<any> {return; }
static stop(): Promise<any> { return; }
/**
* Check if the DB Meter is listening
* @return {Promise<boolean>} Returns a promise that resolves with a boolean that tells us whether the DB meter is listening
*/
@Cordova()
static isListening(): Promise<boolean> {return; }
static isListening(): Promise<boolean> { return; }
/**
* Delete the DB Meter instance
* @return {Promise<any>} Returns a promise that will resolve if the instance has been deleted, and rejects if errors occur.
*/
@Cordova()
static delete(): Promise<any> {return; }
static delete(): Promise<any> { return; }
}

View File

@ -1,5 +1,6 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
export interface DeeplinkMatch {
/**
@ -17,7 +18,7 @@ export interface DeeplinkMatch {
* any internal native data available as "extras" at the time
* the route was matched (for example, Facebook sometimes adds extra data)
*/
$link: any;
$link: any;
}
/**
@ -26,8 +27,8 @@ export interface DeeplinkMatch {
* and Universal App Links.
*
* @usage
* ```ts
* import {IonicDeeplinks} from 'ionic-native';
* ```typescript
* import { IonicDeeplinks } from 'ionic-native';
*
* ```
*/
@ -52,7 +53,7 @@ export class Deeplinks {
@Cordova({
observable: true
})
static route(paths): Observable<DeeplinkMatch> {return; }
static route(paths): Observable<DeeplinkMatch> { return; }
/**
*
@ -75,5 +76,6 @@ export class Deeplinks {
@Cordova({
observable: true
})
static routeWithNavController(navController, paths): Observable<DeeplinkMatch> {return; }
static routeWithNavController(navController, paths): Observable<DeeplinkMatch> { return; }
}

View File

@ -1,4 +1,5 @@
import {Plugin, CordovaProperty} from './plugin';
import { CordovaProperty, Plugin } from './plugin';
declare var window: {
device: Device
@ -32,9 +33,8 @@ export interface Device {
* Access information about the underlying device and platform.
*
* @usage
* ```js
* import {Device} from 'ionic-native';
*
* ```typescript
* import { Device } from 'ionic-native';
*
*
* console.log('Device UUID is: ' + Device.device.uuid);
@ -54,4 +54,5 @@ export class Device {
*/
@CordovaProperty
static get device() { return window.device; }
}

View File

@ -1,33 +1,36 @@
import {Cordova, Plugin} from './plugin';
@Plugin({
plugin: 'https://github.com/loicknuchel/cordova-device-accounts.git',
pluginRef: 'plugins.DeviceAccounts',
repo: 'https://github.com/loicknuchel/cordova-device-accounts',
platforms: ['Android']
})
export class DeviceAccounts {
/**
* Gets all accounts registered on the Android Device
*/
@Cordova()
static get(): Promise<any> {return; }
/**
* Get all accounts registered on Android device for requested type
*/
@Cordova()
static getByType(type: string): Promise<any> {return; }
/**
* Get all emails registered on Android device (accounts with 'com.google' type)
*/
@Cordova()
static getEmails(): Promise<any> {return; }
/**
* Get the first email registered on Android device
*/
@Cordova()
static getEmail(): Promise<any> {return; }
}
import { Cordova, Plugin } from './plugin';
@Plugin({
plugin: 'https://github.com/loicknuchel/cordova-device-accounts.git',
pluginRef: 'plugins.DeviceAccounts',
repo: 'https://github.com/loicknuchel/cordova-device-accounts',
platforms: ['Android']
})
export class DeviceAccounts {
/**
* Gets all accounts registered on the Android Device
*/
@Cordova()
static get(): Promise<any> { return; }
/**
* Get all accounts registered on Android device for requested type
*/
@Cordova()
static getByType(type: string): Promise<any> { return; }
/**
* Get all emails registered on Android device (accounts with 'com.google' type)
*/
@Cordova()
static getEmails(): Promise<any> { return; }
/**
* Get the first email registered on Android device
*/
@Cordova()
static getEmail(): Promise<any> { return; }
}

View File

@ -1,5 +1,6 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
export interface AccelerationData {
@ -40,19 +41,18 @@ export interface AccelerometerOptions {
* Requires Cordova plugin: `cordova-plugin-device-motion`. For more info, please see the [Device Motion docs](https://github.com/apache/cordova-plugin-device-motion).
*
* @usage
* ```ts
* import {DeviceMotion} from 'ionic-native';
*
* ```typescript
* import { DeviceMotion } from 'ionic-native';
*
*
* // Get the device current acceleration
* DeviceMotion.getCurrentAcceleration().then(
* acceleration => console.log(acceleration),
* error => console.log(error)
* (acceleration: AccelerationData) => console.log(acceleration),
* (error: any) => console.log(error)
* );
*
* // Watch device acceleration
* var subscription = DeviceMotion.watchAcceleration().subscribe(acceleration => {
* var subscription = DeviceMotion.watchAcceleration().subscribe((acceleration: AccelerationData) => {
* console.log(acceleration);
* });
*
@ -73,9 +73,7 @@ export class DeviceMotion {
* @returns {Promise<any>} Returns object with x, y, z, and timestamp properties
*/
@Cordova()
static getCurrentAcceleration(): Promise<AccelerationData> {
return;
}
static getCurrentAcceleration(): Promise<AccelerationData> { return; }
/**
* Watch the device acceleration. Clear the watch by unsubscribing from the observable.
@ -87,7 +85,6 @@ export class DeviceMotion {
observable: true,
clearFunction: 'clearWatch'
})
static watchAcceleration(options?: AccelerometerOptions): Observable<AccelerationData> {
return;
}
static watchAcceleration(options?: AccelerometerOptions): Observable<AccelerationData> { return; }
}

View File

@ -1,5 +1,6 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
export interface CompassHeading {
@ -45,20 +46,20 @@ export interface CompassOptions {
* Requires Cordova plugin: `cordova-plugin-device-orientation`. For more info, please see the [Device Orientation docs](https://github.com/apache/cordova-plugin-device-orientation).
*
* @usage
* ```ts
* import {DeviceOrientation} from 'ionic-native';
*
* ```typescript
* // CompassHeading is an interface for compass
* import { DeviceOrientation, CompassHeading } from 'ionic-native';
*
*
* // Get the device current compass heading
* DeviceOrientation.getCurrentHeading().then(
* data => console.log(data),
* error => console.log(error)
* (data: CompassHeading) => console.log(data),
* (error: any) => console.log(error)
* );
*
* // Watch the device compass heading change
* var subscription = DeviceOrientation.watchHeading().subscribe(
* data => console.log(data)
* (data: CompassHeading) => console.log(data)
* );
*
* // Stop watching heading change

View File

@ -1,37 +1,197 @@
import {Plugin, Cordova} from './plugin';
import {Cordova, Plugin, CordovaProperty} from './plugin';
/**
* @name Diagnostic
* @description
* Checks whether device hardware features are enabled or available to the app, e.g. camera, GPS, wifi
*
* @usage
* ```typescript
* import { Diagnostic } from 'ionic-native';
*
* let successCallback = (isAvailable) => { console.log('Is available? ' + isAvailable); };
* let errorCallback = (e) => console.error(e);
*
* Diagnostic.isCameraAvailable().then(successCallback).catch(errorCallback);
*
* Diagnostic.isBluetoothAvailable().then(successCallback, errorCallback);
*
*
* Diagnostic.getBluetoothState()
* .then((state) => {
* if(state == Diagnostic.bluetoothStates.POWERED_ON){
* // do something
* } else {
* // do something else
* }
* }).catch(e => console.error(e));
*
* ```
*/
@Plugin({
plugin: 'cordova.plugins.diagnostic',
pluginRef: 'cordova.plugins.diagnostic',
repo: 'https://github.com/dpa99c/cordova-diagnostic-plugin'
})
export class Diagnostic {
static permission = {
'READ_CALENDAR': 'READ_CALENDAR',
'WRITE_CALENDAR': 'WRITE_CALENDAR',
'CAMERA': 'CAMERA',
'READ_CONTACTS': 'READ_CONTACTS',
'WRITE_CONTACTS': 'WRITE_CONTACTS',
'GET_ACCOUNTS': 'GET_ACCOUNTS',
'ACCESS_FINE_LOCATION': 'ACCESS_FINE_LOCATION',
'ACCESS_COARSE_LOCATION': 'ACCESS_COARSE_LOCATION',
'RECORD_AUDIO': 'RECORD_AUDIO',
'READ_PHONE_STATE': 'READ_PHONE_STATE',
'CALL_PHONE': 'CALL_PHONE',
'ADD_VOICEMAIL': 'ADD_VOICEMAIL',
'USE_SIP': 'USE_SIP',
'PROCESS_OUTGOING_CALLS': 'PROCESS_OUTGOING_CALLS',
'READ_CALL_LOG': 'READ_CALL_LOG',
'WRITE_CALL_LOG': 'WRITE_CALL_LOG',
'SEND_SMS': 'SEND_SMS',
'RECEIVE_SMS': 'RECEIVE_SMS',
'READ_SMS': 'READ_SMS',
'RECEIVE_WAP_PUSH': 'RECEIVE_WAP_PUSH',
'RECEIVE_MMS': 'RECEIVE_MMS',
'WRITE_EXTERNAL_STORAGE': 'WRITE_EXTERNAL_STORAGE',
'READ_EXTERNAL_STORAGE': 'READ_EXTERNAL_STORAGE',
'BODY_SENSORS': 'BODY_SENSORS'
};
static permissionStatus = {
'NOT_REQUESTED': 'not_determined',
'DENIED': 'denied',
'RESTRICTED': 'restricted',
'GRANTED': 'authorized',
'GRANTED_WHEN_IN_USE': 'authorized_when_in_use'
};
static locationAuthorizationMode = {
'ALWAYS': 'always',
'WHEN_IN_USE': 'when_in_use'
};
static permissionGroups = {
'GRANTED': 'GRANTED',
'DENIED': 'DENIED',
'NOT_REQUESTED': 'NOT_REQUESTED',
'DENIED_ALWAYS': 'DENIED_ALWAYS'
};
static locationMode = {
'HIGH_ACCURACY': 'high_accuracy',
'DEVICE_ONLY': 'device_only',
'BATTERY_SAVING': 'battery_saving',
'LOCATION_OFF': 'location_off'
};
static bluetoothState = {
'UNKNOWN': 'unknown',
'RESETTING': 'resetting', // iOS
'UNSUPPORTED': 'unsupported', // iOS
'UNAUTHORIZED': 'unauthorized', // iOS
'POWERED_OFF': 'powered_off',
'POWERED_ON': 'powered_on',
'POWERING_OFF': 'powering_off',
'POWERING_ON': 'powering_on'
};
/**
* Checks if app is able to access device location.
*/
@Cordova()
static isLocationEnabled(): Promise<any> {return; }
static isLocationAvailable(): Promise<any> { return; }
/**
* Checks if Wifi is connected/enabled. On iOS this returns true if the device is connected to a network by WiFi. On Android and Windows 10 Mobile this returns true if the WiFi setting is set to enabled.
* On Android this requires permission. `<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />`
*/
@Cordova()
static isWifiEnabled(): Promise<any> {return; }
static isWifiAvailable(): Promise<any> { return; }
/**
* Checks if the device has a camera. On Android this returns true if the device has a camera. On iOS this returns true if both the device has a camera AND the application is authorized to use it. On Windows 10 Mobile this returns true if both the device has a rear-facing camera AND the
* application is authorized to use it.
*/
@Cordova()
static isCameraEnabled(): Promise<any> {return; }
static isCameraAvailable(): Promise<any> { return; }
/**
* Checks if the device has Bluetooth capabilities and if so that Bluetooth is switched on (same on Android, iOS and Windows 10 Mobile)
* On Android this requires permission <uses-permission android:name="android.permission.BLUETOOTH" />
*/
@Cordova()
static isBluetoothEnabled(): Promise<any> {return; }
static isBluetoothAvailable(): Promise<any> { return; }
/**
* Displays the device location settings to allow user to enable location services/change location mode.
*/
@Cordova({sync: true, platforms: ['Android', 'Windows 10']})
static switchToLocationSettings(): void { }
/**
* Displays mobile settings to allow user to enable mobile data.
*/
@Cordova({sync: true, platforms: ['Android', 'Windows 10']})
static switchToMobileDataSettings(): void { }
/**
* Displays Bluetooth settings to allow user to enable Bluetooth.
*/
@Cordova({sync: true, platforms: ['Android', 'Windows 10']})
static switchToBluetoothSettings(): void { }
/**
* Displays WiFi settings to allow user to enable WiFi.
*/
@Cordova({sync: true, platforms: ['Android', 'Windows 10']})
static switchToWifiSettings(): void { }
/**
* Returns true if the WiFi setting is set to enabled, and is the same as `isWifiAvailable()`
*/
@Cordova({platforms: ['Android', 'Windows 10']})
static isWifiEnabled(): Promise<boolean> { return; }
/**
* Enables/disables WiFi on the device.
* Requires `ACCESS_WIFI_STATE` and `CHANGE_WIFI_STATE` permissions on Android
* @param state {boolean}
*/
@Cordova({callbackOrder: 'reverse', platforms: ['Android', 'Windows 10']})
static setWifiState(state: boolean): Promise<any> { return; }
/**
* Enables/disables Bluetooth on the device.
* Requires `BLUETOOTH` and `BLUETOOTH_ADMIN` permissions on Android
* @param state {boolean}
*/
@Cordova({callbackOrder: 'reverse', platforms: ['Android', 'Windows 10']})
static setBluetoothState(state: boolean): Promise<any> { return; }
/**
* Returns true if the device setting for location is on. On Android this returns true if Location Mode is switched on. On iOS this returns true if Location Services is switched on.
*/
@Cordova({platforms: ['Android', 'iOS']})
static isLocationEnabled(): Promise<boolean> {return; }
/**
* Checks if the application is authorized to use location.
* Note for Android: this is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will always return GRANTED status as permissions are already granted at installation time.
*/
@Cordova()
static isLocationAuthorized(): Promise<any> { return; }
/**
* Returns the location authorization status for the application.
*/
@Cordova({platforms: ['Android', 'iOS']})
static getLocationAuthorizationStatus(): Promise<any> {return; }
/**
* Returns the location authorization status for the application.
@ -39,36 +199,159 @@ export class Diagnostic {
*
* mode - (iOS-only / optional) location authorization mode: "always" or "when_in_use". If not specified, defaults to "when_in_use".
*/
@Cordova()
static requestLocationAuthorization(mode?: string): Promise<any> {return; }
/**
* Checks if the application is authorized to use location.
* Note for Android: this is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will always return GRANTED status as permissions are already granted at installation time.
*/
@Cordova()
static isLocationAuthorized(): Promise<any> {return; }
@Cordova({platforms: ['Android', 'iOS']})
static requestLocationAuthorization(mode?: string): Promise<any> { return; }
/**
* Checks if camera hardware is present on device.
*/
@Cordova()
static isCameraPresent(): Promise<any> {return; }
@Cordova({platforms: ['Android', 'iOS']})
static isCameraPresent(): Promise<any> { return; }
/**
* Checks if the application is authorized to use the camera.
* Note for Android: this is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will always return TRUE as permissions are already granted at installation time.
*/
@Cordova()
static isCameraAuthorized(): Promise<any> {return; }
@Cordova({platforms: ['Android', 'iOS']})
static isCameraAuthorized(): Promise<any> { return; }
/**
* Returns the camera authorization status for the application.
*/
@Cordova({platforms: ['Android', 'iOS']})
static getCameraAuthorizationStatus(): Promise<any> { return; }
/**
* Requests camera authorization for the application.
*/
@Cordova({platforms: ['Android', 'iOS']})
static requestCameraAuthorization(): Promise<any> { return; }
/**
* Checks if the application is authorized to use the microphone.
*/
@Cordova({platforms: ['Android', 'iOS']})
static isMicrophoneAuthorized(): Promise<boolean> { return; }
/**
* Returns the microphone authorization status for the application.
*/
@Cordova({platforms: ['Android', 'iOS']})
static getMicrophoneAuthorizationStatus(): Promise<any> { return; }
/**
* Requests microphone authorization for the application.
*/
@Cordova({platforms: ['Android', 'iOS']})
static requestMicrophoneAuthorization(): Promise<any> { return; }
/**
* Checks if the application is authorized to use contacts (address book).
*/
@Cordova({platforms: ['Android', 'iOS']})
static isContactsAuthorized(): Promise<boolean> { return; }
/**
* Returns the contacts authorization status for the application.
*/
@Cordova({platforms: ['Android', 'iOS']})
static getContactsAuthroizationStatus(): Promise<any> { return; }
/**
* Requests contacts authorization for the application.
*/
@Cordova({platforms: ['Android', 'iOS']})
static requestContactsAuthorization(): Promise<any> { return; }
/**
* Checks if the application is authorized to use the calendar.
*
* Notes for Android:
* - This is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will always return TRUE as permissions are already granted at installation time.
*
* Notes for iOS:
* - This relates to Calendar Events (not Calendar Reminders)
*/
@Cordova({platforms: ['Android', 'iOS']})
static isCalendarAuthorized(): Promise<boolean> { return; }
/**
* Returns the calendar authorization status for the application.
*
* Notes for Android:
* - This is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will always return `GRANTED` status as permissions are already granted at installation time.
*
* Notes for iOS:
* - This relates to Calendar Events (not Calendar Reminders)
*
*/
@Cordova({platforms: ['Android', 'iOS']})
static getCalendarAuthorizationStatus(): Promise<any> { return; }
/**
* Requests calendar authorization for the application.
*
* Notes for iOS:
* - Should only be called if authorization status is NOT_DETERMINED. Calling it when in any other state will have no effect and just return the current authorization status.
* - This relates to Calendar Events (not Calendar Reminders)
*
* Notes for Android:
* - This is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will have no effect as the permissions are already granted at installation time.
* - This requests permission for `READ_CALENDAR` run-time permission
* - Required permissions must be added to `AndroidManifest.xml` as appropriate - see Android permissions: `READ_CALENDAR`, `WRITE_CALENDAR`
*
*/
@Cordova({platforms: ['Android', 'iOS']})
static requestCalendarAuthorization(): Promise<any> { return; }
/**
* Opens settings page for this app.
* On Android, this opens the "App Info" page in the Settings app.
* On iOS, this opens the app settings page in the Settings app. This works only on iOS 8+ - iOS 7 and below will invoke the errorCallback.
*/
@Cordova({platforms: ['Android', 'iOS']})
static switchToSettings(): Promise<any> {return; }
/**
* Returns the state of Bluetooth on the device.
*/
@Cordova({platforms: ['Android', 'iOS']})
static getBluetoothState(): Promise<any> {return; }
/**
* Registers a function to be called when a change in Bluetooth state occurs.
* @param handler
*/
@Cordova({platforms: ['Android', 'iOS'], sync: true})
static registerBluetoothStateChangeHandler(handler: Function): void { }
/**
* Registers a function to be called when a change in Location state occurs.
* @param handler
*/
@Cordova({platforms: ['Android', 'iOS'], sync: true})
static registerLocationStateChangeHandler(handler: Function): void { }
/**
* Checks if high-accuracy locations are available to the app from GPS hardware. Returns true if Location mode is enabled and is set to "Device only" or "High accuracy" AND if the app is authorised to use location.
*/
@Cordova({platforms: ['Android']})
static isGpsLocationAvailable(): Promise<boolean> {return; }
/**
* Checks if location mode is set to return high-accuracy locations from GPS hardware.
* Returns true if Location mode is enabled and is set to either:
* - Device only = GPS hardware only (high accuracy)
* - High accuracy = GPS hardware, network triangulation and Wifi network IDs (high and low accuracy)
*/
@Cordova()
static isGpsLocationEnabled(): Promise<any> {return; }
@Cordova({platforms: ['Android']})
static isGpsLocationEnabled(): Promise<any> { return; }
/**
* Checks if low-accuracy locations are available to the app from network triangulation/WiFi access points. Returns true if Location mode is enabled and is set to "Battery saving" or "High accuracy" AND if the app is authorised to use location.
*/
@Cordova({platforms: ['Android']})
static isNetworkLocationAvailable(): Promise<any> {return; }
/**
* Checks if location mode is set to return low-accuracy locations from network triangulation/WiFi access points.
@ -76,22 +359,137 @@ export class Diagnostic {
* - Battery saving = network triangulation and Wifi network IDs (low accuracy)
* - High accuracy = GPS hardware, network triangulation and Wifi network IDs (high and low accuracy)
*/
@Cordova()
static isNetworkLocationEnabled(): Promise<any> {return; }
@Cordova({platforms: ['Android']})
static isNetworkLocationEnabled(): Promise<any> { return; }
/**
* Returns the current location mode setting for the device.
*/
@Cordova({platforms: ['Android']})
static getLocationMode(): Promise<any> {return; }
/**
* Returns the current authorisation status for a given permission.
* Note: this is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will always return GRANTED status as permissions are already granted at installation time.
* @param permission
*/
@Cordova({platforms: ['Android'], callbackOrder: 'reverse'})
static getPermissionAuthorizationStatus(permission: any): Promise<any> {return; }
/**
* Returns the current authorisation status for multiple permissions.
* Note: this is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will always return GRANTED status as permissions are already granted at installation time.
* @param permissions
*/
@Cordova({platforms: ['Android'], callbackOrder: 'reverse'})
static getPermissionsAuthorizationStatus(permissions: any[]): Promise<any> {return; }
/**
* Requests app to be granted authorisation for a runtime permission.
* Note: this is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will have no effect as the permissions are already granted at installation time.
* @param permission
*/
@Cordova({platforms: ['Android'], callbackOrder: 'reverse'})
static requestRuntimePermission(permission: any): Promise<any> {return; }
/**
* Requests app to be granted authorisation for multiple runtime permissions.
* Note: this is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will always return GRANTED status as permissions are already granted at installation time.
* @param permissions
*/
@Cordova({platforms: ['Android'], callbackOrder: 'reverse'})
static requestRuntimePermissions(permissions: any[]): Promise<any> {return; }
/**
* Checks if the device setting for Bluetooth is switched on.
* This requires `BLUETOOTH` permission on Android
*/
@Cordova({platforms: ['Android']})
static isBluetoothEnabled(): Promise<boolean> {return; }
/**
* Checks if the device has Bluetooth capabilities.
*/
@Cordova({platforms: ['Android']})
static hasBluetoothSupport(): Promise<boolean> {return; }
/**
* Checks if the device has Bluetooth Low Energy (LE) capabilities.
*/
@Cordova({platforms: ['Android']})
static hasBluetoothLESupport(): Promise<boolean> {return; }
/**
* Checks if the device supports Bluetooth Low Energy (LE) Peripheral mode.
*/
@Cordova({platforms: ['Android']})
static hasBluetoothLEPeripheralSupport(): Promise<boolean> {return; }
/**
* Checks if the application is authorized to use the Camera Roll in Photos app.
*/
@Cordova({platforms: ['iOS']})
static isCameraRollAuthorized(): Promise<boolean> {return; }
/**
* Returns the authorization status for the application to use the Camera Roll in Photos app.
*/
@Cordova({platforms: ['iOS']})
static getCameraRollAuthorizationStatus(): Promise<boolean> {return; }
/**
* Requests camera roll authorization for the application. Should only be called if authorization status is NOT_REQUESTED. Calling it when in any other state will have no effect.
*/
@Cordova({platforms: ['iOS']})
static requestCameraRollAuthorization(): Promise<any> {return; }
/**
* Checks if remote (push) notifications are enabled.
* On iOS 8+, returns true if app is registered for remote notifications AND "Allow Notifications" switch is ON AND alert style is not set to "None" (i.e. "Banners" or "Alerts").
* On iOS <=7, returns true if app is registered for remote notifications AND alert style is not set to "None" (i.e. "Banners" or "Alerts") - same as isRegisteredForRemoteNotifications().
*/
@Cordova()
static isRemoteNotificationsEnabled(): Promise<any> {return; }
@Cordova({platforms: ['iOS']})
static isRemoteNotificationsEnabled(): Promise<boolean> {return; }
/**
* Indicates if the app is registered for remote (push) notifications on the device.
* On iOS 8+, returns true if the app is registered for remote notifications and received its device token, or false if registration has not occurred, has failed, or has been denied by the user. Note that user preferences for notifications in the Settings app will not affect this.
* On iOS <=7, returns true if app is registered for remote notifications AND alert style is not set to "None" (i.e. "Banners" or "Alerts") - same as isRemoteNotificationsEnabled().
*/
@Cordova()
static isRegisteredForRemoteNotifications(): Promise<any> {return; }
@Cordova({platforms: ['iOS']})
static isRegisteredForRemoteNotifications(): Promise<boolean> {return; }
/**
* Indicates the current setting of notification types for the app in the Settings app.
* Note: on iOS 8+, if "Allow Notifications" switch is OFF, all types will be returned as disabled.
*/
@Cordova({platforms: ['iOS']})
static getRemoteNotificationTypes(): Promise<any> {return; }
/**
* Checks if the application is authorized to use reminders.
*/
@Cordova({platforms: ['iOS']})
static isRemindersAuthorized(): Promise<boolean> {return; }
/**
* Returns the reminders authorization status for the application.
*/
@Cordova({platforms: ['iOS']})
static getRemindersAuthorizationStatus(): Promise<any> {return; }
/**
* Requests reminders authorization for the application.
*/
@Cordova({platforms: ['iOS']})
static requestRemindersAuthorization(): Promise<any> {return; }
/**
* Checks if the application is authorized for background refresh.
*/
@Cordova({platforms: ['iOS']})
static isBackgroundRefreshAuthorized(): Promise<boolean> {return; }
/**
* Returns the background refresh authorization status for the application.
*/
@Cordova({platforms: ['iOS']})
static getBackgroundRefreshStatus(): Promise<any> {return; }
}

View File

@ -1,4 +1,5 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
export interface PromptCallback {
@ -11,7 +12,6 @@ export interface PromptCallback {
* The text entered in the prompt dialog box. (String)
*/
input1: string;
}
@ -23,8 +23,8 @@ export interface PromptCallback {
* Requires Cordova plugin: `cordova-plugin-dialogs`. For more info, please see the [Dialogs plugin docs](https://github.com/apache/cordova-plugin-dialogs).
*
* @usage
* ```js
* import {Dialogs} from 'ionic-native';
* ```typescript
* import { Dialogs } from 'ionic-native';
*
*
*
@ -53,7 +53,7 @@ export class Dialogs {
message,
title: string = 'Alert',
buttonName: string = 'OK'
): Promise<any> {return; }
): Promise<any> { return; }
/**
* Displays a customizable confirmation dialog box.
@ -70,7 +70,7 @@ export class Dialogs {
message,
title: string = 'Confirm',
buttonLabels: Array<string> = ['OK', 'Cancel']
): Promise<number> { return; }
): Promise<number> { return; }
/**
* Displays a native dialog box that is more customizable than the browser's prompt function.
@ -89,7 +89,7 @@ export class Dialogs {
title: string = 'Prompt',
buttonLabels: Array<string> = ['OK', 'Cancel'],
defaultText: string = ''
): Promise<any> { return; }
): Promise<any> { return; }
/**
@ -99,6 +99,6 @@ export class Dialogs {
@Cordova({
sync: true
})
static beep(times: number): void {}
static beep(times: number): void { }
}

View File

@ -1,5 +1,8 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
declare var cordova: any;
/**
* @name Email Composer
* @description
@ -7,13 +10,14 @@ declare var cordova: any;
* Requires Cordova plugin: cordova-plugin-email-composer. For more info, please see the [Email Composer plugin docs](https://github.com/katzer/cordova-plugin-email-composer).
*
* DISCLAIMER: This plugin is experiencing issues with the latest versions of Cordova. Use at your own risk. Functionality is not guaranteed. Please stay tuned for a more stable version.
* A good alternative to this plugin is the social sharing plugin.
*
* @usage
* ```ts
* import {EmailComposer} from 'ionic-native';
* ```typescript
* import { EmailComposer } from 'ionic-native';
*
*
* EmailComposer.isAvailable().then((available) =>{
* EmailComposer.isAvailable().then((available: boolean) =>{
* if(available) {
* //Now we know we can send
* }
@ -53,10 +57,25 @@ export class EmailComposer {
* @param app {string?} An optional app id or uri scheme.
* @returns {Promise<boolean>} Resolves if available, rejects if not available
*/
static isAvailable (app?: string): Promise<any> {
static isAvailable(app?: string): Promise<any> {
return new Promise<boolean>((resolve, reject) => {
if (app) cordova.plugins.email.isAvailable(app, (isAvailable) => { if (isAvailable) resolve(); else reject(); });
else cordova.plugins.email.isAvailable((isAvailable) => { if (isAvailable) resolve(); else reject(); });
if (app) {
cordova.plugins.email.isAvailable(app, (isAvailable) => {
if (isAvailable) {
resolve();
} else {
reject();
}
});
} else {
cordova.plugins.email.isAvailable((isAvailable) => {
if (isAvailable) {
resolve();
} else {
reject();
}
});
}
});
}
@ -67,7 +86,7 @@ export class EmailComposer {
* @param packageName {string} The package name
*/
@Cordova()
static addAlias(alias: string, packageName: string): void {}
static addAlias(alias: string, packageName: string): void { }
/**
* Displays the email composer pre-filled with data.
@ -80,9 +99,10 @@ export class EmailComposer {
successIndex: 1,
errorIndex: 3
})
static open(email: Email, scope?: any): Promise<any> {return; }
static open(email: Email, scope?: any): Promise<any> { return; }
}
export interface Email {
app?: string;
to?: string | Array<string>;
@ -92,4 +112,4 @@ export interface Email {
subject?: string;
body?: string;
isHtml?: boolean;
}
}

View File

@ -0,0 +1,482 @@
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @name EstimoteBeacons
*
* @description
* This plugin enables communication between a phone and Estimote Beacons peripherals.
*
*/
@Plugin({
plugin: 'cordova-plugin-estimote',
pluginRef: 'estimote.beacons',
repo: 'https://github.com/evothings/phonegap-estimotebeacons',
platforms: ['iOS', 'Android']
})
export class EstimoteBeacons {
/** Proximity value */
static ProximityUnknown = 0;
/** Proximity value */
static ProximityImmediate = 1;
/** Proximity value */
static ProximityNear = 2;
/** Proximity value */
static ProximityFar = 3;
/** Beacon colour */
static BeaconColorUnknown = 0;
/** Beacon colour */
static BeaconColorMintCocktail = 1;
/** Beacon colour */
static BeaconColorIcyMarshmallow = 2;
/** Beacon colour */
static BeaconColorBlueberryPie = 3;
/**
* Beacon colour.
*/
static BeaconColorSweetBeetroot = 4;
/** Beacon colour */
static BeaconColorCandyFloss = 5;
/** Beacon colour */
static BeaconColorLemonTart = 6;
/** Beacon colour */
static BeaconColorVanillaJello = 7;
/** Beacon colour */
static BeaconColorLiquoriceSwirl = 8;
/** Beacon colour */
static BeaconColorWhite = 9;
/** Beacon colour */
static BeaconColorTransparent = 10;
/** Region state */
static RegionStateUnknown = 'unknown';
/** Region state */
static RegionStateOutside = 'outside';
/** Region state */
static RegionStateInside = 'inside';
/**
* Ask the user for permission to use location services
* while the app is in the foreground.
* You need to call this function or requestAlwaysAuthorization
* on iOS 8+.
* Does nothing on other platforms.
*
* @usage
* ```
* EstimoteBeacons.requestWhenInUseAuthorization().then(
* () => { console.log('on success'); },
* () => { console.log('on error'); }
* );
* ```
*
* @see {@link https://community.estimote.com/hc/en-us/articles/203393036-Estimote-SDK-and-iOS-8-Location-Services|Estimote SDK and iOS 8 Location Services}
* @return Returns a Promise.
*/
@Cordova()
static requestWhenInUseAuthorization(): Promise<any> { return; }
/**
* Ask the user for permission to use location services
* whenever the app is running.
* You need to call this function or requestWhenInUseAuthorization
* on iOS 8+.
* Does nothing on other platforms.
*
* @usage
* ```
* EstimoteBeacons.requestAlwaysAuthorization().then(
* () => { console.log('on success'); },
* () => { console.log('on error'); }
* );
* ```
*
* @see {@link https://community.estimote.com/hc/en-us/articles/203393036-Estimote-SDK-and-iOS-8-Location-Services|Estimote SDK and iOS 8 Location Services}
* @return Returns a Promise.
*/
@Cordova()
static requestAlwaysAuthorization(): Promise<any> { return; }
/**
* Get the current location authorization status.
* Implemented on iOS 8+.
* Does nothing on other platforms.
*
* @usage
* ```
* EstimoteBeacons.authorizationStatus().then(
* (result) => { console.log('Location authorization status: ' + result); },
* (errorMessage) => { console.log('Error: ' + errorMessage); }
* );
* ```
*
* @see {@link https://community.estimote.com/hc/en-us/articles/203393036-Estimote-SDK-and-iOS-8-Location-Services|Estimote SDK and iOS 8 Location Services}
* @return Returns a Promise.
*/
@Cordova()
static authorizationStatus(): Promise<any> { return; }
/**
* Start advertising as a beacon.
*
* @usage
* ```
* EstimoteBeacons.startAdvertisingAsBeacon('B9407F30-F5F8-466E-AFF9-25556B57FE6D', 1, 1, 'MyRegion')
* .then(() => { console.log('Beacon started'); });
* setTimeout(() => {
* EstimoteBeacons.stopAdvertisingAsBeacon().then((result) => { console.log('Beacon stopped'); });
* }, 5000);
* ```
* @param uuid {string} UUID string the beacon should advertise (mandatory).
* @param major {number} Major value to advertise (mandatory).
* @param minor {number} Minor value to advertise (mandatory).
* @param regionId {string} Identifier of the region used to advertise (mandatory).
* @return Returns a Promise.
*/
@Cordova({
clearFunction: 'stopAdvertisingAsBeacon'
})
static startAdvertisingAsBeacon(uuid: string, major: number, minor: number, regionId: string): Promise<any> { return; }
/**
* Stop advertising as a beacon.
*
* @usage
* ```
* EstimoteBeacons.startAdvertisingAsBeacon('B9407F30-F5F8-466E-AFF9-25556B57FE6D', 1, 1, 'MyRegion')
* .then(() => { console.log('Beacon started'); });
* setTimeout(() => {
* EstimoteBeacons.stopAdvertisingAsBeacon().then((result) => { console.log('Beacon stopped'); });
* }, 5000);
* ```
* @return Returns a Promise.
*/
@Cordova()
static stopAdvertisingAsBeacon(): Promise<any> { return; }
/**
* Enable analytics.
*
* @see {@link http://estimote.github.io/iOS-SDK/Classes/ESTConfig.html|Further details}
*
* @usage
* ```
* EstimoteBeacons.enableAnalytics(true).then(() => { console.log('Analytics enabled'); });
* ```
* @param enable {number} Boolean value to turn analytics on or off (mandatory).
* @return Returns a Promise.
*/
@Cordova()
static enableAnalytics(enable: boolean): Promise<any> { return; }
/**
* Test if analytics is enabled.
*
* @see {@link http://estimote.github.io/iOS-SDK/Classes/ESTConfig.html|Further details}
*
* @usage
* ```
* EstimoteBeacons.isAnalyticsEnabled().then((enabled) => { console.log('Analytics enabled: ' + enabled); });
* ```
* @return Returns a Promise.
*/
@Cordova()
static isAnalyticsEnabled(): Promise<any> { return; }
/**
* Test if App ID and App Token is set.
*
* @see {@link http://estimote.github.io/iOS-SDK/Classes/ESTConfig.html|Further details}
*
* @usage
* ```
* EstimoteBeacons.isAuthorized().then((isAuthorized) => { console.log('App ID and App Token is set: ' + isAuthorized); });
* ```
* @return Returns a Promise.
*/
@Cordova()
static isAuthorized(): Promise<any> { return; }
/**
* Set App ID and App Token.
*
* @see {@link http://estimote.github.io/iOS-SDK/Classes/ESTConfig.html|Further details}
*
* @usage
* ```
* EstimoteBeacons.setupAppIDAndAppToken('MyAppID', 'MyAppToken').then(() => { console.log('AppID and AppToken configured!'); });
* ```
* @param appID {string} The App ID (mandatory).
* @param appToken {string} The App Token (mandatory).
* @return Returns a Promise.
*/
@Cordova()
static setupAppIDAndAppToken(appID: string, appToken: string): Promise<any> { return; }
/**
* Start scanning for all nearby beacons using CoreBluetooth (no region object is used).
* Available on iOS.
*
* @usage
* ```
* EstimoteBeacons.startEstimoteBeaconDiscovery().subscribe(beacons => {
* console.log(JSON.stringify(beacons));
* });
* setTimeout(() => {
* EstimoteBeacons.stopEstimoteBeaconDiscovery().then(() => { console.log('scan stopped'); });
* }, 5000);
* ```
* @return Returns an Observable that notifies of each beacon discovered.
*/
@Cordova({
observable: true,
clearFunction: 'stopEstimoteBeaconDiscovery'
})
static startEstimoteBeaconDiscovery(): Observable<any> { return; }
/**
* Stop CoreBluetooth scan. Available on iOS.
*
* @usage
* ```
* EstimoteBeacons.startEstimoteBeaconDiscovery().subscribe(beacons => {
* console.log(JSON.stringify(beacons));
* });
* setTimeout(() => {
* EstimoteBeacons.stopEstimoteBeaconDiscovery().then(() => { console.log('scan stopped'); });
* }, 5000);
* ```
* @return returns a Promise.
*/
@Cordova()
static stopEstimoteBeaconDiscovery(): Promise<any> { return; }
/**
* Start ranging beacons. Available on iOS and Android.
*
* @usage
* ```
* let region: BeaconRegion = {} // Empty region matches all beacons.
* EstimoteBeacons.startRangingBeaconsInRegion(region).subscribe(info => {
* console.log(JSON.stringify(info));
* });
* setTimeout(() => {
* EstimoteBeacons.stopRangingBeaconsInRegion(region).then(() => { console.log('scan stopped'); });
* }, 5000);
* ```
* @param region {BeaconRegion} Dictionary with region properties (mandatory).
* @return Returns an Observable that notifies of each beacon discovered.
*/
@Cordova({
observable: true,
clearFunction: 'stopRangingBeaconsInRegion',
clearWithArgs: true
})
static startRangingBeaconsInRegion(region: BeaconRegion): Observable<any> { return; }
/**
* Stop ranging beacons. Available on iOS and Android.
*
* @usage
* ```
* let region: BeaconRegion = {} // Empty region matches all beacons.
* EstimoteBeacons.startRangingBeaconsInRegion(region).subscribe(info => {
* console.log(JSON.stringify(info));
* });
* setTimeout(() => {
* EstimoteBeacons.stopRangingBeaconsInRegion(region).then(() => { console.log('scan stopped'); });
* }, 5000);
* ```
* @param region {BeaconRegion} Dictionary with region properties (mandatory).
* @return returns a Promise.
*/
@Cordova()
static stopRangingBeaconsInRegion(region: BeaconRegion): Promise<any> { return; }
/**
* Start ranging secure beacons. Available on iOS.
* This function has the same parameters/behaviour as
* {@link EstimoteBeacons.startRangingBeaconsInRegion}.
* To use secure beacons set the App ID and App Token using
* {@link EstimoteBeacons.setupAppIDAndAppToken}.
*/
@Cordova({
observable: true,
clearFunction: 'stopRangingSecureBeaconsInRegion',
clearWithArgs: true
})
static startRangingSecureBeaconsInRegion(region: BeaconRegion): Observable<any> { return; }
/**
* Stop ranging secure beacons. Available on iOS.
* This function has the same parameters/behaviour as
* {@link EstimoteBeacons.stopRangingBeaconsInRegion}.
*/
@Cordova()
static stopRangingSecureBeaconsInRegion(region: BeaconRegion): Promise<any> { return; }
/**
* Start monitoring beacons. Available on iOS and Android.
*
* @usage
* ```
* let region: BeaconRegion = {} // Empty region matches all beacons.
* EstimoteBeacons.startMonitoringForRegion(region).subscribe(state => {
* console.log('Region state: ' + JSON.stringify(state));
* });
* ```
* @param region {BeaconRegion} Dictionary with region properties (mandatory).
* @param [notifyEntryStateOnDisplay=false] {boolean} Set to true to detect if you
* are inside a region when the user turns display on, see
* {@link https://developer.apple.com/library/prerelease/ios/documentation/CoreLocation/Reference/CLBeaconRegion_class/index.html#//apple_ref/occ/instp/CLBeaconRegion/notifyEntryStateOnDisplay|iOS documentation}
* for further details (optional, defaults to false, iOS only).
* @return Returns an Observable that notifies of each region state discovered.
*/
@Cordova({
observable: true,
clearFunction: 'stopMonitoringForRegion',
clearWithArgs: true,
successIndex: 1,
errorIndex: 2
})
static startMonitoringForRegion(region: BeaconRegion, notifyEntryStateOnDisplay: boolean): Observable<any> { return; }
/**
* Stop monitoring beacons. Available on iOS and Android.
*
* @usage
* ```
* let region: BeaconRegion = {} // Empty region matches all beacons.
* EstimoteBeacons.stopMonitoringForRegion(region).then(() => { console.log('monitoring is stopped'); });
* ```
* @param region {BeaconRegion} Dictionary with region properties (mandatory).
* @return returns a Promise.
*/
@Cordova()
static stopMonitoringForRegion(region: BeaconRegion): Promise<any> { return; }
/**
* Start monitoring secure beacons. Available on iOS.
* This function has the same parameters/behaviour as
* EstimoteBeacons.startMonitoringForRegion.
* To use secure beacons set the App ID and App Token using
* {@link EstimoteBeacons.setupAppIDAndAppToken}.
* @see {@link EstimoteBeacons.startMonitoringForRegion}
*/
@Cordova({
observable: true,
clearFunction: 'stopSecureMonitoringForRegion',
clearWithArgs: true,
successIndex: 1,
errorIndex: 2
})
static startSecureMonitoringForRegion(region: BeaconRegion, notifyEntryStateOnDisplay: boolean): Observable<any> { return; }
/**
* Stop monitoring secure beacons. Available on iOS.
* This function has the same parameters/behaviour as
* {@link EstimoteBeacons.stopMonitoringForRegion}.
*/
@Cordova()
static stopSecureMonitoringForRegion(region: BeaconRegion): Promise<any> { return; }
/**
* Connect to Estimote Beacon. Available on Android.
*
* @usage
* ```
* EstimoteBeacons.connectToBeacon(FF:0F:F0:00:F0:00);
* ```
* ```
* EstimoteBeacons.connectToBeacon({
* proximityUUID: '000000FF-F00F-0FF0-F000-000FF0F00000',
* major: 1,
* minor: 1
* });
* ```
* @param beacon {Beacon} Beacon to connect to.
* @return returns a Promise.
*/
@Cordova()
static connectToBeacon(beacon: any): Promise<any> { return; }
/**
* Disconnect from connected Estimote Beacon. Available on Android.
*
* @usage
* ```
* EstimoteBeacons.disconnectConnectedBeacon();
* ```
* @return returns a Promise.
*/
@Cordova()
static disconnectConnectedBeacon(): Promise<any> { return; }
/**
* Write proximity UUID to connected Estimote Beacon. Available on Android.
*
* @usage
* ```
* // Example that writes constant ESTIMOTE_PROXIMITY_UUID
* EstimoteBeacons.writeConnectedProximityUUID(ESTIMOTE_PROXIMITY_UUID);
*
* @param uuid {string} String to write as new UUID
* @return returns a Promise.
*/
@Cordova()
static writeConnectedProximityUUID(uuid: any): Promise<any> { return; }
/**
* Write major to connected Estimote Beacon. Available on Android.
*
* @usage
* ```
* // Example that writes 1
* EstimoteBeacons.writeConnectedMajor(1);
*
* @param major {number} number to write as new major
* @return returns a Promise.
*/
@Cordova()
static writeConnectedMajor(major: number): Promise<any> { return; }
/**
* Write minor to connected Estimote Beacon. Available on Android.
*
* @usage
* ```
* // Example that writes 1
* EstimoteBeacons.writeConnectedMinor(1);
*
* @param minor {number} number to write as new minor
* @return returns a Promise.
*/
@Cordova()
static writeConnectedMinor(minor: number): Promise<any> { return; }
}
export interface BeaconRegion {
state?: string;
major: number;
minor: number;
identifier?: string;
uuid: string;
}

View File

@ -1,4 +1,4 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Facebook
@ -69,8 +69,8 @@ import {Plugin, Cordova} from './plugin';
* For tracking events, see `logEvent` and `logPurchase`.
*
* @usage
* ```js
* import {Facebook} from 'ionic-native';
* ```typescript
* import { Facebook } from 'ionic-native';
*
*
*
@ -85,20 +85,20 @@ import {Plugin, Cordova} from './plugin';
})
export class Facebook {
/**
* Browser wrapper
* @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> {
return;
}
/**
* Browser wrapper
* @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> {
return;
}
/**
* Login to Facebook to authenticate this app.
*
* ```ts
* ```typescript
* {
* status: "connected",
* authResponse: {
@ -113,10 +113,10 @@ export class Facebook {
* ```
*
* @param {string[]} permissions List of [permissions](https://developers.facebook.com/docs/facebook-login/permissions) this app has upon logging in.
* @return Returns a Promise that resolves with a status object if login succeeds, and rejects if login fails.
* @return {Promise<FacebookLoginResponse>} Returns a Promise that resolves with a status object if login succeeds, and rejects if login fails.
*/
@Cordova()
static login(permissions: string[]): Promise<any> { return; }
static login(permissions: string[]): Promise<FacebookLoginResponse> { return; }
/**
* Logout of Facebook.
@ -213,7 +213,7 @@ export class Facebook {
name: string,
params?: Object,
valueToSum?: number
): Promise<any> { return; }
): Promise<any> { return; }
/**
* Log a purchase. For more information see the Events section above.
@ -245,4 +245,17 @@ export class Facebook {
url: string,
picture: string
}): Promise<any> { return; }
}
export interface FacebookLoginResponse {
status: string;
authResponse: {
session_key: boolean;
accessToken: string;
expiresIn: number;
sig: string;
secret: string;
userID: string;
};
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
import {Plugin, CordovaInstance} from './plugin';
import { CordovaInstance, Plugin } from './plugin';
declare var FileTransfer;
@ -106,19 +107,49 @@ export interface FileTransferError {
/**
* @name Transfer
* @description This plugin allows you to upload and download files.
* Example:
* Create instance:
*
* @description
* This plugin allows you to upload and download files.
*
* @usage
* ```typescript
* import { Transfer } from 'ionic-native';
*
*
* // Create instance:
* const fileTransfer = new Transfer();
*
* Upload a file:
* // Upload a file:
* fileTransfer.upload(..).then(..).catch(..);
*
* Download a file:
* // Download a file:
* fileTransfer.download(..).then(..).catch(..);
*
* Abort active transfer:
* // Abort active transfer:
* fileTransfer.abort();
*
* E.g
*
* upload(){
* const fileTransfer = new Transfer();
* var options: any;
*
* options = {
* fileKey: 'file',
* fileName: 'name.jpg',
* headers: {}
* .....
* }
* fileTransfer.upload("<file path>", "<api endpoint>", options)
* .then((data) => {
* // success
* }, (err) => {
* // error
* })
* }
*
* ```
*
*/
@Plugin({
plugin: 'cordova-plugin-file-transfer',
@ -127,11 +158,23 @@ export interface FileTransferError {
})
export class Transfer {
public static FILE_NOT_FOUND_ERR: number = 1;
public static INVALID_URL_ERR: number = 2;
public static CONNECTION_ERR: number = 3;
public static ABORT_ERR: number = 4;
public static NOT_MODIFIED_ERR: number = 4;
/**
* Error code rejected from upload with FileTransferError
* Defined in FileTransferError.
* FILE_NOT_FOUND_ERR: 1 Return when file was not found
* INVALID_URL_ERR: 2, Return when url was invalid
* CONNECTION_ERR: 3, Return on connection error
* ABORT_ERR: 4, Return on aborting
* NOT_MODIFIED_ERR: 5 Return on "304 Not Modified" HTTP response
* @enum {number}
*/
public static FileTransferErrorCode = {
FILE_NOT_FOUND_ERR: 1,
INVALID_URL_ERR: 2,
CONNECTION_ERR: 3,
ABORT_ERR: 4,
NOT_MODIFIED_ERR: 5
};
private _objectInstance: any;
@ -145,7 +188,7 @@ export class Transfer {
* @param {string} fileUrl Filesystem URL representing the file on the device or a data URI. For backwards compatibility, this can also be the full path of the file on the device.
* @param {string} url URL of the server to receive the file, as encoded by encodeURI().
* @param {FileUploadOptions} options Optional parameters.
* @param {boolean} trustAllHosts: Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful since Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS.
* @param {boolean} trustAllHosts Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful since Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS.
* @return Returns a Promise that resolves to a FileUploadResult and rejects with FileTransferError.
*/
@CordovaInstance({
@ -189,6 +232,6 @@ export class Transfer {
@CordovaInstance({
sync: true
})
abort(): void {}
abort(): void { }
}

View File

@ -1,4 +1,5 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Flashlight
@ -7,8 +8,8 @@ import {Plugin, Cordova} from './plugin';
* Requires Cordova plugin: `cordova-plugin-flashlight`. For more info, please see the [Flashlight plugin docs](https://github.com/EddyVerbruggen/Flashlight-PhoneGap-Plugin).
*
* @usage
* ```js
* import {Flashlight} from 'ionic-native';
* ```typescript
* import { Flashlight } from 'ionic-native';
*
*
*
@ -21,7 +22,6 @@ import {Plugin, Cordova} from './plugin';
})
export class Flashlight {
/**
* Checks if the flashlight is available
* @returns {Promise<boolean>} Returns a promise that resolves with a boolean stating if the flashlight is available.
@ -53,7 +53,7 @@ export class Flashlight {
/**
* Checks if the flashlight is turned on.
* Returns a boolean
* @returns {boolean}
*/
@Cordova({
sync: true

164
src/plugins/geofence.ts Normal file
View File

@ -0,0 +1,164 @@
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @name Geofence
* @description Monitors circular geofences around latitude/longitude coordinates, and sends a notification to the user when the boundary of a geofence is crossed. Notifications can be sent when the user enters and/or exits a geofence.
* Geofences persist after device reboot. Geofences will be monitored even when the app is not running.
* @usage
* ```
* import { Geofence } from 'ionic-native';
* import { Platform } from 'ionic-angular'
* ...
*
* constructor(private platform: Platform) {
* this.platform.ready().then(() => {
// initialize the plugin
* Geofence.initialize().then(
* // resolved promise does not return a value
* () => console.log('Geofence Plugin Ready'),
* (err) => console.log(err)
* )
* })
* }
*
* private addGeofence() {
* //options describing geofence
* let fence = {
* id: "69ca1b88-6fbe-4e80-a4d4-ff4d3748acdb", //any unique ID
* latitude: 37.285951, //center of geofence radius
* longitude: -121.936650,
* radius: 100, //radius to edge of geofence
* transitionType: 3, //see 'Transition Types' below
* notification: { //notification settings
* id: 1, //any unique ID
* title: "You crossed a fence", //notification title
* text: "You just arrived to Gliwice city center.", //notification body
* openAppOnClick: true //open app when notification is tapped
* }
* }
*
* Geofence.addOrUpdate(fence).then(
* () => console.log('Geofence added'),
* (err) => console.log('Geofence failed to add')
* );
* }
*
* ```
* ### Transition Types ###
* Transition type specifies whether the geofence should trigger when the user enters and/or leaves the geofence.
*
* #### Supported values ####
* - 1: Enter
* - 2: Leave
* - 3: Both
*
* ### Defining a Geofence ###
* Geofences are defined by an object that is passed to `addOrUpdate()`. Object properties are:
* - id: Any unique ID for the geofence. This ID is used to remove and update a geofence
* - latitude: Latitude coordinate of the center of the geofence radius
* - longitude: Latitude coordinate of the center of the geofence radius
* - radius: Radius from the center to the edge of the geofence
* - transitionType: Type of geofence transition to monitor for. See 'Transition Types' above
* - notification: Object. Options for defining the notification sent when a geofence is crossed
* - id: Any unique ID
* - title: Notification title
* - text: Notification body
* - openAppOnClick: Boolean. Whether to open the app when the notification is tapped by the user
*
* ### Troubleshooting ###
* #### I get compile errors when I run `ionic build ios` or `ionic run ios`. ####
* This could be caused by the Cordova project directory in `/platforms/ios` not being named correctly.
* Try running `ionic platform rm <platform>` then run `ionic platform add <platform>` to recreate the
* platform directories.
*/
declare var window: any;
@Plugin({
plugin: 'cordova-plugin-geofence',
pluginRef: 'geofence',
repo: 'https://github.com/cowbell/cordova-plugin-geofence/',
platforms: ['Android', 'iOS', 'Windows Phone 8', 'Windows Phone']
})
export class Geofence {
public static TransitionType = {
ENTER: 1,
EXIT: 2,
BOTH: 3
};
public static onTrasitionReceived: Function;
/**
* Initializes the plugin. User will be prompted to allow the app to use location and notifications.
*
* @return {Promise<any>}
*/
@Cordova()
static initialize(): Promise<void> { return };
/**
* Adds a new geofence or array of geofences. For geofence object, see above.
*
* @return {Promise<any>}
*/
@Cordova()
static addOrUpdate(geofences: Object | Array<Object>): Promise<void> { return };
/**
* Removes a geofence or array of geofences. `geofenceID` corresponds to one or more IDs specified when the
* geofence was created.
*
* @return {Promise<any>}
*/
@Cordova()
static remove(geofenceId: string | Array<string>): Promise<void> { return };
/**
* Removes all geofences.
*
* @return {Promise<any>}
*/
@Cordova()
static removeAll(): Promise<void> { return };
/**
* Returns an array of geofences currently being monitored.
*
* @return {Promise<Array<string>>}
*/
@Cordova()
static getWatched(): Promise<string> { return };
/**
* Called when a geofence is crossed in the direction specified by `TransitType`.
* Commenting out. Not yet implemented in plugin.
*
* @return {Promise<any>}
*/
static onTransitionReceived(): Observable<any> {
return new Observable<any>((observer) => {
window && window.geofence && (window.geofence.onTransitionReceived = observer.next.bind(observer));
return () => window.geofence.onTransitionReceived = () => {};
});
}
/**
* Called when the user clicks a geofence notification. iOS and Android only.
* Commenting out. Not yet implemented in plugin.
*
* @return {Promise<Object>}
*/
static onNotificationClicked(): Observable<any> {
return new Observable<any>((observer) => {
window && window.geofence && (window.geofence.onNotificationClicked = observer.next.bind(observer));
return () => window.geofence.onNotificationClicked = () => {};
});
}
}

View File

@ -1,5 +1,6 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
declare var navigator: any;
@ -101,20 +102,19 @@ export interface GeolocationOptions {
*
* @usage
*
* ```ts
* import {Geolocation} from 'ionic-native';
*
* ```typescript
* import { Geolocation } from 'ionic-native';
*
*
* Geolocation.getCurrentPosition().then((resp) => {
* //resp.coords.latitude
* //resp.coords.longitude
* // resp.coords.latitude
* // resp.coords.longitude
* })
*
* let watch = Geolocation.watchPosition();
* watch.subscribe((data) => {
* //data.coords.latitude
* //data.coords.longitude
* // data.coords.latitude
* // data.coords.longitude
* })
* ```
*/
@ -139,7 +139,7 @@ export class Geolocation {
* Watch the current device's position. Clear the watch by unsubscribing from
* Observable changes.
*
* ```ts
* ```typescript
* var subscription = Geolocation.watchPosition().subscribe(position => {
* console.log(position.coords.longitude + ' ' + position.coords.latitude);
* });
@ -154,8 +154,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), observer.error.bind(observer), options);
return () => navigator.geolocation.clearWatch(watchId);
}
);

View File

@ -1,20 +1,19 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Globalization
* @description
* @usage
* ```js
* import {Globalization} from 'ionic-native';
*
* ```typescript
* import { Globalization } from 'ionic-native';
*
*
* ```
*/
@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,14 +22,14 @@ 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
@ -39,10 +38,10 @@ export class Globalization {
* @return {Promise<{value: string}>} Returns a promise when the date has been converted.
*/
@Cordova({
successIndex: 1,
errorIndex: 2
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; }
/**
* 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.
@ -51,11 +50,10 @@ export class Globalization {
* @return {Promise<{value: string}>} Returns a promise when the date has been converted.
*/
@Cordova({
successIndex: 1,
errorIndex: 2
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 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.
@ -63,10 +61,9 @@ export class Globalization {
* @return {Promise<{value: string}>} Returns a promise.
*/
@Cordova({
callbackOrder: 'reverse'
callbackOrder: 'reverse'
})
static getDatePattern(options: {formatLength: string, selector: string}): Promise<{pattern: string}> {return; }
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.
@ -74,9 +71,9 @@ export class Globalization {
* @return {Promise<{value: string}>} Returns a promise.
*/
@Cordova({
callbackOrder: 'reverse'
callbackOrder: 'reverse'
})
static getDateNames(options: {type: string, item: string}): Promise<{value: Array<string>}> {return; }
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.
@ -84,24 +81,24 @@ export class Globalization {
* @returns {Promise<dst>} reutrns a promise with the value
*/
@Cordova()
static isDayLightSavingsTime(date: Date): Promise<{dst: string}> {return; }
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; }
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
successIndex: 1,
errorIndex: 2
})
static numberToString(options: {type: string}): Promise<{value: string}> {return; }
static numberToString(options: { type: string }): Promise<{ value: string }> { return; }
/**
*
@ -110,10 +107,10 @@ export class Globalization {
* @returns {Promise} Returns a promise with the value.
*/
@Cordova({
successIndex: 1,
errorIndex: 2
successIndex: 1,
errorIndex: 2
})
static stringToNumber(stringToConvert: string, options: {type: string}): Promise<{value: number|string}> {return; }
static stringToNumber(stringToConvert: string, options: { type: string }): Promise<{ value: number | string }> { return; }
/**
* Returns a pattern string to format and parse numbers according to the client's user preferences.
@ -121,9 +118,9 @@ export class Globalization {
* @returns {Promise} returns a promise with the value.
*/
@Cordova({
callbackOrder: 'reverse'
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; }
/**
* Returns a pattern string to format and parse currency values according to the client's user preferences and ISO 4217 currency code.
@ -131,6 +128,6 @@ export class Globalization {
* @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

@ -1,10 +1,13 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Google Plus
* @description
* @usage
* ```
* ```typescript
* import { GooglePlus } from 'ionic-native';
*
*
* ```
*/
@ -22,25 +25,25 @@ export class GooglePlus {
* @param options
*/
@Cordova()
static login(options?: any): Promise<any> {return; }
static login(options?: any): Promise<any> { return; }
/**
* You can call trySilentLogin to check if they're already signed in to the app and sign them in silently if they are.
* @param options
*/
@Cordova()
static trySilentLogin(options?: any): Promise<any> {return; }
static trySilentLogin(options?: any): Promise<any> { return; }
/**
* This will clear the OAuth2 token.
*/
@Cordova()
static logout(): Promise<any> {return; }
static logout(): Promise<any> { return; }
/**
* This will clear the OAuth2 token, forget which account was used to login, and disconnect that account from the app. This will require the user to allow the app access again next time they sign in. Be aware that this effect is not always instantaneous. It can take time to completely disconnect.
*/
@Cordova()
static disconnect(): Promise<any> {return; }
static disconnect(): Promise<any> { return; }
}
}

View File

@ -1,4 +1,5 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
declare var window;
@ -12,112 +13,134 @@ declare var window;
* - (Android) Google Play Services SDK installed via [Android SDK Manager](https://developer.android.com/sdk/installing/adding-packages.html)
*/
@Plugin({
plugin: 'cordova-plugin-google-analytics',
pluginRef: 'analytics',
repo: 'https://github.com/danwilson/google-analytics-plugin',
platforms: ['Android', 'iOS']
plugin: 'cordova-plugin-google-analytics',
pluginRef: 'analytics',
repo: 'https://github.com/danwilson/google-analytics-plugin',
platforms: ['Android', 'iOS']
})
export class GoogleAnalytics {
/**
* In your 'deviceready' handler, set up your Analytics tracker.
* https://developers.google.com/analytics/devguides/collection/analyticsjs/
* @param {string} id Your Google Analytics Mobile App property
*/
@Cordova()
static startTrackerWithId(id: string): Promise<any> { return; }
/**
* In your 'deviceready' handler, set up your Analytics tracker.
* https://developers.google.com/analytics/devguides/collection/analyticsjs/
* @param {string} id Your Google Analytics Mobile App property
*/
@Cordova()
static startTrackerWithId(id: string): Promise<any> { return; }
/**
* Track a screen
* https://developers.google.com/analytics/devguides/collection/analyticsjs/screens
*
* @param {string} title Screen title
*/
@Cordova()
static trackView(title: string): Promise<any> { return; }
/**
* Track a screen
* https://developers.google.com/analytics/devguides/collection/analyticsjs/screens
*
* @param {string} title Screen title
* @param {string} campaignUrl Campaign url for measuring referrals
*/
@Cordova()
static trackView(title: string, campaignUrl?: string): Promise<any> { return; }
/**
* Track an event
* https://developers.google.com/analytics/devguides/collection/analyticsjs/events
* @param {string} category
* @param {string} action
* @param {string} label
* @param {number} value
*/
@Cordova()
static trackEvent(category: string, action: string, label?: string, value?: number): Promise<any> { return; }
/**
* Track an event
* https://developers.google.com/analytics/devguides/collection/analyticsjs/events
* @param {string} category
* @param {string} action
* @param {string} label
* @param {number} value
*/
@Cordova()
static trackEvent(category: string, action: string, label?: string, value?: number): Promise<any> { return; }
/**
* Track an exception
* @param {string} description
* @param {boolean} fatal
*/
@Cordova()
static trackException(description: string, fatal: boolean): Promise<any> { return; }
/**
* Track an exception
* @param {string} description
* @param {boolean} fatal
*/
@Cordova()
static trackException(description: string, fatal: boolean): Promise<any> { return; }
/**
* Track User Timing (App Speed)
* @param {string} category
* @param {number} intervalInMilliseconds
* @param {string} variable
* @param {string} label
*/
@Cordova()
static trackTiming(category: string, intervalInMilliseconds: number, variable: string, label: string): Promise<any> { return; }
/**
* Track User Timing (App Speed)
* @param {string} category
* @param {number} intervalInMilliseconds
* @param {string} variable
* @param {string} label
*/
@Cordova()
static trackTiming(category: string, intervalInMilliseconds: number, variable: string, label: string): Promise<any> { return; }
/**
* Add a Transaction (Ecommerce)
* https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#addTrans
* @param {string} id
* @param {string} affiliation
* @param {number} revenue
* @param {number} tax
* @param {number} shipping
* @param {string} currencyCode
*/
@Cordova()
static addTransaction(id: string, affiliation: string, revenue: number, tax: number, shipping: number, currencyCode: string): Promise<any> { return; }
/**
* Add a Transaction (Ecommerce)
* https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#addTrans
* @param {string} id
* @param {string} affiliation
* @param {number} revenue
* @param {number} tax
* @param {number} shipping
* @param {string} currencyCode
*/
@Cordova()
static addTransaction(id: string, affiliation: string, revenue: number, tax: number, shipping: number, currencyCode: string): Promise<any> { return; }
/**
* Add a Transaction Item (Ecommerce)
* https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#addItem
* @param {string} id
* @param {string} name
* @param {string} sku
* @param {string} category
* @param {number} price
* @param {number} quantity
* @param {string} currencyCode
*/
@Cordova()
static addTransactionItem(id: string, name: string, sku: string, category: string, price: number, quantity: number, currencyCode: string): Promise<any> { return; }
/**
* Add a Transaction Item (Ecommerce)
* https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#addItem
* @param {string} id
* @param {string} name
* @param {string} sku
* @param {string} category
* @param {number} price
* @param {number} quantity
* @param {string} currencyCode
*/
@Cordova()
static addTransactionItem(id: string, name: string, sku: string, category: string, price: number, quantity: number, currencyCode: string): Promise<any> { return; }
/**
* Add a Custom Dimension
* https://developers.google.com/analytics/devguides/platform/customdimsmets
* @param {string} key
* @param {string} value
*/
@Cordova()
static addCustomDimension(key: number, value: string): Promise<any> { return; }
/**
* Add a Custom Dimension
* https://developers.google.com/analytics/devguides/platform/customdimsmets
* @param {string} key
* @param {string} value
*/
@Cordova()
static addCustomDimension(key: number, value: string): Promise<any> { return; }
/**
* Set a UserId
* https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id
* @param {string} id
*/
@Cordova()
static setUserId(id: string): Promise<any> { return; }
/**
* Set a UserId
* https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id
* @param {string} id
*/
@Cordova({sync: true})
static setUserId(id: string): void { }
/**
* Enable verbose logging
*/
@Cordova()
static debugMode(): Promise<any> { return; }
/**
* Sets the app version
* @param appVersion
*/
@Cordova({sync: true})
static setAppVersion(appVersion: string): void { }
/**
* Enable/disable automatic reporting of uncaught exceptions
* @param {boolean} shouldEnable
*/
@Cordova()
static enableUncaughtExceptionReporting(shouldEnable: boolean): Promise<any> { return; }
/**
* Set a anonymize Ip address
* @param anonymize
*/
@Cordova({sync: true})
static setAnonymizeIp(anonymize: boolean): void { }
/**
* Enabling Advertising Features in Google Analytics allows you to take advantage of Remarketing, Demographics & Interests reports, and more
* @param allow
*/
@Cordova({sync: true})
static setAllowIDFACollection(allow: boolean): void { }
/**
* Enable verbose logging
*/
@Cordova({sync: true})
static debugMode(): Promise<any> { return; }
/**
* Enable/disable automatic reporting of uncaught exceptions
* @param {boolean} shouldEnable
*/
@Cordova()
static enableUncaughtExceptionReporting(shouldEnable: boolean): Promise<any> { return; }
}

View File

@ -1,10 +1,13 @@
import { Cordova, CordovaInstance, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @private
* Created by Ibrahim on 3/29/2016.
*/
declare var plugin: any;
/**
* @private
* You can listen to these events where appropriate
@ -43,14 +46,16 @@ export const GoogleMapsAnimation = {
* @description This plugin uses the native Google Maps SDK
* @usage
* ```
* import {GoogleMap, GoogleMapsEvent} from 'ionic-native';
* import { GoogleMap, GoogleMapsEvent } from 'ionic-native';
*
* ...
*
* // somewhere in your component
* let map = new GoogleMap('elementID');
* let map = new GoogleMap('elementID', {
* // Map Options: https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapOptions
});
*
* map.on(GoogleMapsEvent.MAP_READY).subscribe(() => console.log("Map is ready!"));
* map.on(GoogleMapsEvent.MAP_READY).subscribe(() => console.log('Map is ready!'));
* ```
*/
@Plugin({
@ -62,8 +67,9 @@ export class GoogleMap {
_objectInstance: any;
/**
* Checks if a map object has been created.
* @return {Promise<boolean>} returns a promise that resolves with a boolean that indicates if the plugin is available.
* Checks if a map object has been created and is available.
*
* @return {Promise<boolean>}
*/
@Cordova()
static isAvailable(): Promise<boolean> {
@ -74,23 +80,31 @@ export class GoogleMap {
this._objectInstance = plugin.google.maps.Map.getMap(document.getElementById(elementId), options);
}
/**
* Listen to a map event.
*
* @return {Observable<any>}
*/
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);
}
);
}
/**
* Listen to a map event only once.
*
* @return {Promise<any>}
*/
one(event: any): Promise<any> {
return new Promise<any>(
resolve => this._objectInstance.one(event, resolve)
);
}
@CordovaInstance({ sync: true })
setDebuggable(isDebuggable: boolean): void {
}
@ -100,7 +114,9 @@ export class GoogleMap {
}
/**
* Get the position of the camera
* Get the position of the camera.
*
* @return {Promise<CameraPosition>}
*/
@CordovaInstance()
getCameraPosition(): Promise<CameraPosition> {
@ -108,15 +124,19 @@ export class GoogleMap {
}
/**
* Get the location of the user
* Get the location of the user.
*
* @return {Promise<MyLocation>}
*/
@CordovaInstance()
getMyLocation(): Promise<MyLocation> {
getMyLocation(options?: MyLocationOptions): Promise<MyLocation> {
return;
}
/**
* Get the visible region
* Get the visible region.
*
* @return {Promise<VisibleRegion>}
*/
@CordovaInstance()
getVisibleRegion(): Promise<VisibleRegion> {
@ -184,8 +204,11 @@ export class GoogleMap {
return new Promise<GoogleMapsMarker>(
(resolve, reject) => {
this._objectInstance.addMarker(options, (marker: any) => {
if (marker) resolve(new GoogleMapsMarker(marker));
else reject();
if (marker) {
resolve(new GoogleMapsMarker(marker));
} else {
reject();
}
});
}
);
@ -195,8 +218,11 @@ export class GoogleMap {
return new Promise<GoogleMapsCircle>(
(resolve, reject) => {
this._objectInstance.addCircle(options, (circle: any) => {
if (circle) resolve(new GoogleMapsCircle(circle));
else reject();
if (circle) {
resolve(new GoogleMapsCircle(circle));
} else {
reject();
}
});
}
);
@ -206,8 +232,11 @@ export class GoogleMap {
return new Promise<GoogleMapsPolygon>(
(resolve, reject) => {
this._objectInstance.addPolygon(options, (polygon: any) => {
if (polygon) resolve(new GoogleMapsPolygon(polygon));
else reject();
if (polygon) {
resolve(new GoogleMapsPolygon(polygon));
} else {
reject();
}
});
}
);
@ -217,8 +246,11 @@ export class GoogleMap {
return new Promise<GoogleMapsPolyline>(
(resolve, reject) => {
this._objectInstance.addPolyline(options, (polyline: any) => {
if (polyline) resolve(new GoogleMapsPolyline(polyline));
else reject();
if (polyline) {
resolve(new GoogleMapsPolyline(polyline));
} else {
reject();
}
});
}
);
@ -228,8 +260,11 @@ export class GoogleMap {
return new Promise<GoogleMapsTileOverlay>(
(resolve, reject) => {
this._objectInstance.addTileOverlay(options, (tileOverlay: any) => {
if (tileOverlay) resolve(new GoogleMapsTileOverlay(tileOverlay));
else reject();
if (tileOverlay) {
resolve(new GoogleMapsTileOverlay(tileOverlay));
} else {
reject();
}
});
}
);
@ -239,8 +274,11 @@ export class GoogleMap {
return new Promise<GoogleMapsGroundOverlay>(
(resolve, reject) => {
this._objectInstance.addGroundOverlay(options, (groundOverlay: any) => {
if (groundOverlay) resolve(new GoogleMapsGroundOverlay(groundOverlay));
else reject();
if (groundOverlay) {
resolve(new GoogleMapsGroundOverlay(groundOverlay));
} else {
reject();
}
});
}
);
@ -250,8 +288,11 @@ export class GoogleMap {
return new Promise<GoogleMapsKmlOverlay>(
(resolve, reject) => {
this._objectInstance.addKmlOverlay(options, (kmlOverlay: any) => {
if (kmlOverlay) resolve(new GoogleMapsKmlOverlay(kmlOverlay));
else reject();
if (kmlOverlay) {
resolve(new GoogleMapsKmlOverlay(kmlOverlay));
} else {
reject();
}
});
}
);
@ -341,6 +382,13 @@ export interface MyLocation {
bearing?: number;
}
/**
* @private
*/
export interface MyLocationOptions {
enableHighAccuracy?: boolean;
}
/**
* @private
*/
@ -389,11 +437,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));
}
);
}
@ -537,9 +582,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));
}
);
}
@ -629,9 +673,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));
}
);
}
@ -721,9 +764,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));
}
);
}
@ -951,8 +993,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 })
@ -1005,3 +1048,52 @@ 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 {
adminArea?: string;
country?: string;
countryCode?: string;
extra?: {
featureName?: string;
lines?: Array<string>;
permises?: string;
phone?: string;
url?: string
};
locale?: string;
locality?: string;
position?: { lat: number; lng: number };
postalCode?: string;
subAdminArea?: string;
subLocality?: string;
subThoroughfare?: string;
thoroughfare?: 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

@ -1,17 +1,16 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Hotspot
* @description
* @usage
* ```js
* import {Hotspot, Network} from 'ionic-native';
* ```typescript
* import { Hotspot, Network } from 'ionic-native';
*
* ...
* Hotspot.scanWifi().then((networks: Array<Network>) => {
* console.log(networks);
* });
* ...
*
* Hotspot.scanWifi().then((networks: Array<Network>) => {
* console.log(networks);
* });
*
* ```
*/
@ -24,10 +23,10 @@ import {Plugin, Cordova} from './plugin';
export class Hotspot {
@Cordova()
static isAvailable(): Promise<boolean> {return; }
static isAvailable(): Promise<boolean> { return; }
@Cordova()
static toggleWifi(): Promise<boolean> {return; }
static toggleWifi(): Promise<boolean> { return; }
/**
* Configures and starts hotspot with SSID and Password
@ -39,7 +38,7 @@ export class Hotspot {
* @return {Promise<void>} - Promise to call once hotspot is started, or reject upon failure
*/
@Cordova()
static createHotspot(ssid: string, mode: string, password: string): Promise<void> {return; }
static createHotspot(ssid: string, mode: string, password: string): Promise<void> { return; }
/**
* Turns on Access Point
@ -47,7 +46,7 @@ export class Hotspot {
* @return {Promise<boolean>} - true if AP is started
*/
@Cordova()
static startHotspot(): Promise<boolean> {return; }
static startHotspot(): Promise<boolean> { return; }
/**
* Configures hotspot with SSID and Password
@ -59,7 +58,7 @@ export class Hotspot {
* @return {Promise<void>} - Promise to call when hotspot is configured, or reject upon failure
*/
@Cordova()
static configureHotspot(ssid: string, mode: string, password: string): Promise<void> {return; }
static configureHotspot(ssid: string, mode: string, password: string): Promise<void> { return; }
/**
* Turns off Access Point
@ -67,7 +66,7 @@ export class Hotspot {
* @return {Promise<boolean>} - Promise to turn off the hotspot, true on success, false on failure
*/
@Cordova()
static stopHotspot(): Promise<boolean> {return; }
static stopHotspot(): Promise<boolean> { return; }
/**
* Checks if hotspot is enabled
@ -75,10 +74,10 @@ export class Hotspot {
* @return {Promise<void>} - Promise that hotspot is enabled, rejected if it is not enabled
*/
@Cordova()
static isHotspotEnabled(): Promise<void> {return; }
static isHotspotEnabled(): Promise<void> { return; }
@Cordova()
static getAllHotspotDevices(): Promise<Array<HotspotDevice>> {return; }
static getAllHotspotDevices(): Promise<Array<HotspotDevice>> { return; }
/**
* Connect to a WiFi network
@ -92,25 +91,25 @@ export class Hotspot {
* Promise that connection to the WiFi network was successfull, rejected if unsuccessful
*/
@Cordova()
static connectToWifi(ssid: string, password: string): Promise<void> {return; }
static connectToWifi(ssid: string, password: string): Promise<void> { return; }
/**
* Connect to a WiFi network
*
* @param {string} ssid
* SSID to connect
* @param {string} password
* Password to use
* @param {string} authentication
* Authentication modes to use (LEAP, SHARED, OPEN)
* @param {string[]} encryption
* Encryption modes to use (CCMP, TKIP, WEP104, WEP40)
*
* @return {Promise<void>}
* Promise that connection to the WiFi network was successfull, rejected if unsuccessful
*/
/**
* Connect to a WiFi network
*
* @param {string} ssid
* SSID to connect
* @param {string} password
* Password to use
* @param {string} authentication
* Authentication modes to use (LEAP, SHARED, OPEN)
* @param {string[]} encryption
* Encryption modes to use (CCMP, TKIP, WEP104, WEP40)
*
* @return {Promise<void>}
* Promise that connection to the WiFi network was successfull, rejected if unsuccessful
*/
@Cordova()
static connectToWifiAuthEncrypt(ssid: string, password: string, authentication: string, encryption: Array<string>): Promise<void> {return; }
static connectToWifiAuthEncrypt(ssid: string, password: string, authentication: string, encryption: Array<string>): Promise<void> { return; }
/**
* Add a WiFi network
@ -126,7 +125,7 @@ export class Hotspot {
* Promise that adding the WiFi network was successfull, rejected if unsuccessful
*/
@Cordova()
static addWifiNetwork(ssid: string, mode: string, password: string): Promise<void> {return; }
static addWifiNetwork(ssid: string, mode: string, password: string): Promise<void> { return; }
/**
* Remove a WiFi network
@ -138,43 +137,43 @@ export class Hotspot {
* Promise that removing the WiFi network was successfull, rejected if unsuccessful
*/
@Cordova()
static removeWifiNetwork(ssid: string): Promise<void> {return; }
static removeWifiNetwork(ssid: string): Promise<void> { return; }
@Cordova()
static isConnectedToInternet(): Promise<boolean> {return; }
static isConnectedToInternet(): Promise<boolean> { return; }
@Cordova()
static isConnectedToInternetViaWifi(): Promise<boolean> {return; }
static isConnectedToInternetViaWifi(): Promise<boolean> { return; }
@Cordova()
static isWifiOn(): Promise<boolean> {return; }
static isWifiOn(): Promise<boolean> { return; }
@Cordova()
static isWifiSupported(): Promise<boolean> {return; }
static isWifiSupported(): Promise<boolean> { return; }
@Cordova()
static isWifiDirectSupported(): Promise<boolean> {return; }
static isWifiDirectSupported(): Promise<boolean> { return; }
@Cordova()
static scanWifi(): Promise<Array<Network>> {return; }
static scanWifi(): Promise<Array<Network>> { return; }
@Cordova()
static scanWifiByLevel(): Promise<Array<Network>> {return; }
static scanWifiByLevel(): Promise<Array<Network>> { return; }
@Cordova()
static startWifiPeriodicallyScan(interval: number, duration: number): Promise<any> {return; }
static startWifiPeriodicallyScan(interval: number, duration: number): Promise<any> { return; }
@Cordova()
static stopWifiPeriodicallyScan(): Promise<any> {return; }
static stopWifiPeriodicallyScan(): Promise<any> { return; }
@Cordova()
static getNetConfig(): Promise<NetworkConfig> {return; }
static getNetConfig(): Promise<NetworkConfig> { return; }
@Cordova()
static getConnectionInfo(): Promise<ConnectionInfo> {return; }
static getConnectionInfo(): Promise<ConnectionInfo> { return; }
@Cordova()
static pingHost(ip: string): Promise<string> {return; }
static pingHost(ip: string): Promise<string> { return; }
/**
* Gets MAC Address associated with IP Address from ARP File
@ -184,7 +183,7 @@ export class Hotspot {
* @return {Promise<string>} - A Promise for the MAC Address
*/
@Cordova()
static getMacAddressOfHost(ip: string): Promise<string> {return; }
static getMacAddressOfHost(ip: string): Promise<string> { return; }
/**
* Checks if IP is live using DNS
@ -194,7 +193,7 @@ export class Hotspot {
* @return {Promise<boolean>} - A Promise for whether the IP Address is reachable
*/
@Cordova()
static isDnsLive(ip: string): Promise<boolean> {return; }
static isDnsLive(ip: string): Promise<boolean> { return; }
/**
* Checks if IP is live using socket And PORT
@ -204,7 +203,7 @@ export class Hotspot {
* @return {Promise<boolean>} - A Promise for whether the IP Address is reachable
*/
@Cordova()
static isPortLive(ip: string): Promise<boolean> {return; }
static isPortLive(ip: string): Promise<boolean> { return; }
/**
* Checks if device is rooted
@ -212,7 +211,7 @@ export class Hotspot {
* @return {Promise<boolean>} - A Promise for whether the device is rooted
*/
@Cordova()
static isRooted(): Promise<boolean> {return; }
static isRooted(): Promise<boolean> { return; }
}

View File

@ -1,61 +1,79 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @name Httpd
* @description
* Embedded httpd for Cordova apps. Light weight HTTP server.
* @usage
* ```typescript
* import {Httpd, HttpdOptions} from 'ionic-native';
*
* let options: HttpdOptions = {
* www_root: 'httpd_root', // relative path to app's www directory
* port: 80,
* localhost_only: false
* };
*
* Httpd.startServer(options).subscribe((data) => {
* console.log('Server is live');
* });
*
* ```
*/
@Plugin({
plugin: 'https://github.com/floatinghotpot/cordova-httpd.git',
pluginRef: 'cordova.plugins.CorHttpd',
repo: 'https://github.com/floatinghotpot/cordova-httpd',
platforms: ['iOS', 'Android']
plugin: 'https://github.com/floatinghotpot/cordova-httpd.git',
pluginRef: 'cordova.plugins.CorHttpd',
repo: 'https://github.com/floatinghotpot/cordova-httpd',
platforms: ['iOS', 'Android']
})
export class Httpd {
/**
* Starts a web server.
* @returns {Observable<string>} Returns an Observable. Subscribe to receive the URL for your web server (if succeeded). Unsubscribe to stop the server.
* @param options {HttpdOptions}
*/
@Cordova({
observable: true,
clearFunction: 'stopServer'
})
static startServer(options: any): Observable<string> {return; }
/**
* Starts a web server.
* @returns {Observable<string>} Returns an Observable. Subscribe to receive the URL for your web server (if succeeded). Unsubscribe to stop the server.
* @param options {HttpdOptions}
*/
@Cordova({
observable: true,
clearFunction: 'stopServer'
})
static startServer(options?: any): Observable<string> { return; }
/**
* Gets the URL of the running server
* @returns {Promise<string>} Returns a promise that resolves with the URL of the web server.
*/
@Cordova()
static getUrl(): Promise<string> {return; }
/**
* Gets the URL of the running server
* @returns {Promise<string>} Returns a promise that resolves with the URL of the web server.
*/
@Cordova()
static getUrl(): Promise<string> { return; }
/**
* Get the local path of the running webserver
* @returns {Promise<string>} Returns a promise that resolves with the local path of the web server.
*/
@Cordova()
static getLocalPath(): Promise<string> { return; }
/**
* Get the local path of the running webserver
* @returns {Promise<string>} Returns a promise that resolves with the local path of the web server.
*/
@Cordova()
static getLocalPath(): Promise<string> {return; }
}
/**
* These options are used for the Httpd.startServer() function.
*/
export interface HttpdOptions {
/**
* The public root directory for your web server. This path is relative to your app's www directory.
* Default is current directory.
*/
www_root?: string;
/**
* The port number to use.
* Default is 8888
*/
port?: number;
/**
* Setting this option to false will allow remote access to your web server (over any IP).
* Default is false.
*/
localhost_only?: boolean;
}
/**
* The public root directory for your web server. This path is relative to your app's www directory.
* Default is current directory.
*/
www_root?: string;
/**
* The port number to use.
* Default is 8888
*/
port?: number;
/**
* Setting this option to false will allow remote access to your web server (over any IP).
* Default is false.
*/
localhost_only?: boolean;
}

View File

@ -1,5 +1,6 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
declare var cordova: any;
@ -21,7 +22,7 @@ export interface Beacon {
/**
* The proximity of the beacon relative to the phone.
*
*
* Possible options are:
* ProximityImmediate
* ProximityNear
@ -47,6 +48,7 @@ export interface Beacon {
accuracy: number;
}
export interface BeaconRegion {
/**
* A unique identifier for this region.
@ -65,7 +67,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;
@ -76,6 +78,7 @@ export interface BeaconRegion {
*/
notifyEntryStateOnDisplay?: boolean;
}
export interface CircularRegion {
/**
* A unique identifier for this region.
@ -97,6 +100,7 @@ export interface CircularRegion {
*/
radius: number;
}
export type Region = BeaconRegion | CircularRegion;
export interface PluginResult {
@ -125,11 +129,17 @@ 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 {
/**
* An observable that publishes information about the location permission authorization status.
*
*
* @return Returns a string.
*/
didChangeAuthorizationStatus(): Observable<string>;
@ -137,10 +147,10 @@ export interface Delegate {
/**
* 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>;
@ -148,32 +158,32 @@ export interface Delegate {
/**
* 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
* 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
* 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>;
@ -181,7 +191,7 @@ export interface Delegate {
/**
* 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>;
@ -189,7 +199,7 @@ export interface Delegate {
/**
* 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>;
@ -197,16 +207,16 @@ export interface Delegate {
/**
* 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
* 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>;
@ -221,25 +231,25 @@ export interface Delegate {
*
* @usage
*
* ```ts
* import {IBeacon} from 'ionic-native';
* ```typescript
* 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
* data => console.log('didRangeBeaconsInRegion: ', data),
* error => console.error();
* );
* delegate.didStartMonitoringForRegion()
* .subscribe(
* data => {console.log('didStartMonitoringForRegion: ', data)},
* error => console.error
* data => console.log('didStartMonitoringForRegion: ', data),
* error => console.error();
* );
* delegate.didEnterRegion()
* .subscribe(
@ -247,9 +257,9 @@ export interface Delegate {
* 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'),
@ -258,18 +268,17 @@ export interface Delegate {
* ```
*/
@Plugin({
plugin: 'cordova-plugin-ibeacon',
pluginRef: 'cordova.plugins.locationManager',
repo: 'https://github.com/petermetz/cordova-plugin-ibeacon',
platforms: ['Android', 'iOS']
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 {
@ -362,18 +371,18 @@ export class IBeacon {
/**
* Creates a new BeaconRegion
*
*
* @param {String} identifier @see {CLRegion}
* @param {String} uuid The proximity ID of the beacon being targeted.
* @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, 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);
}
/**
@ -384,7 +393,7 @@ export class IBeacon {
/**
* @param {Delegate} delegate An instance of a delegate to register with the native layer.
*
*
* @return Returns the Delegate
*/
@Cordova()
@ -394,15 +403,15 @@ export class IBeacon {
* 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.
@ -410,7 +419,7 @@ export class IBeacon {
* @return Returns a promise which is resolved as soon as the
* native layer acknowledged the request and started to send events.
*/
@Cordova({sync: true})
@Cordova({otherPromise: true})
static onDomDelegateReady(): Promise<void> { return; }
/**
@ -418,7 +427,7 @@ export class IBeacon {
* @returns Returns a promise which is resolved with a {Boolean}
* indicating whether bluetooth is active.
*/
@Cordova({sync: true})
@Cordova({otherPromise: true})
static isBluetoothEnabled(): Promise<boolean> { return; }
/**
@ -427,7 +436,7 @@ export class IBeacon {
* @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})
@Cordova({otherPromise: true})
static enableBluetooth(): Promise<void> { return; }
/**
@ -436,15 +445,15 @@ export class IBeacon {
* @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})
@Cordova({otherPromise: 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
* 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
* 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.
*
@ -452,44 +461,44 @@ export class IBeacon {
*
* @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})
@Cordova({otherPromise: 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
* 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})
@Cordova({otherPromise: 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.
* 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})
@Cordova({otherPromise: true})
static requestStateForRegion(region: Region): Promise<void> { return; }
@ -507,7 +516,7 @@ export class IBeacon {
* @return Returns a promise which is resolved as soon as the
* native layer acknowledged the dispatch of the monitoring request.
*/
@Cordova({sync: true})
@Cordova({otherPromise: true})
static startRangingBeaconsInRegion(region: BeaconRegion): Promise<void> { return; }
/**
@ -524,16 +533,16 @@ export class IBeacon {
* @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})
@Cordova({otherPromise: 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
*
* @returns Returns a promise which is resolved with the
* requested authorization status.
*/
@Cordova({sync: true})
@Cordova({otherPromise: true})
static getAuthorizationStatus(): Promise<any> { return; }
/**
@ -545,7 +554,7 @@ export class IBeacon {
* 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})
@Cordova({otherPromise: true})
static requestWhenInUseAuthorization(): Promise<void> { return; }
@ -555,23 +564,23 @@ export class IBeacon {
* @returns Returns a promise which is resolved when the native layer
* shows the request dialog.
*/
@Cordova({sync: true})
@Cordova({otherPromise: 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})
@Cordova({otherPromise: 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})
@Cordova({otherPromise: true})
static getRangedRegions(): Promise<Region[]> { return; }
/**
@ -579,7 +588,7 @@ export class IBeacon {
* @returns Returns a promise which is resolved with a {Boolean}
* indicating whether ranging is available or not.
*/
@Cordova({sync: true})
@Cordova({otherPromise: true})
static isRangingAvailable(): Promise<boolean> { return; }
/**
@ -591,7 +600,7 @@ export class IBeacon {
* @returns Returns a promise which is resolved with a {Boolean}
* indicating whether the region type is supported or not.
*/
@Cordova({sync: true})
@Cordova({otherPromise: true})
static isMonitoringAvailableForClass(region: Region): Promise<boolean> { return; }
/**
@ -611,7 +620,7 @@ export class IBeacon {
* @return Returns a promise which is resolved as soon as the
* native layer acknowledged the dispatch of the advertising request.
*/
@Cordova({sync: true})
@Cordova({otherPromise: true})
static startAdvertising(region: Region, measuredPower: number): Promise<void> { return; }
/**
@ -622,7 +631,7 @@ export class IBeacon {
* @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})
@Cordova({otherPromise: true})
static stopAdvertising(region: Region): Promise<void> { return; }
/**
@ -630,7 +639,7 @@ export class IBeacon {
* @returns Returns a promise which is resolved with a {Boolean}
* indicating whether advertising is available or not.
*/
@Cordova({sync: true})
@Cordova({otherPromise: true})
static isAdvertisingAvailable(): Promise<boolean> { return; }
/**
@ -638,17 +647,17 @@ export class IBeacon {
* @returns Returns a promise which is resolved with a {Boolean}
* indicating whether advertising is active.
*/
@Cordova({sync: true})
@Cordova({otherPromise: 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})
@Cordova({otherPromise: true})
static disableDebugLogs(): Promise<void> { return; }
/**
@ -659,7 +668,7 @@ export class IBeacon {
* @returns Returns a promise which is resolved as soon as the
* native layer has set the flag to enabled.
*/
@Cordova({sync: true})
@Cordova({otherPromise: true})
static enableDebugNotifications(): Promise<void> { return; }
/**
@ -669,7 +678,7 @@ export class IBeacon {
* @returns Returns a promise which is resolved as soon as the
* native layer has set the flag to disabled.
*/
@Cordova({sync: true})
@Cordova({otherPromise: true})
static disableDebugNotifications(): Promise<void> { return; }
/**
@ -679,7 +688,7 @@ export class IBeacon {
* @returns Returns a promise which is resolved as soon as the
* native layer has set the logging level accordingly.
*/
@Cordova({sync: true})
@Cordova({otherPromise: true})
static enableDebugLogs(): Promise<void> { return; }
/**
@ -692,7 +701,7 @@ export class IBeacon {
* 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})
@Cordova({otherPromise: true})
static appendToDeviceLog(message: string): Promise<void> { return; }
}
}

View File

@ -1,20 +1,21 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
export interface ImagePickerOptions {
// max images to be selected, defaults to 15. If this is set to 1, upon
// selection of a single image, the plugin will return it.
maximumImagesCount?: number;
// max images to be selected, defaults to 15. If this is set to 1, upon
// selection of a single image, the plugin will return it.
maximumImagesCount?: number;
// max width and height to allow the images to be. Will keep aspect
// ratio no matter what. So if both are 800, the returned image
// will be at most 800 pixels wide and 800 pixels tall. If the width is
// 800 and height 0 the image will be 800 pixels wide if the source
// is at least that wide.
width?: number;
height?: number;
// max width and height to allow the images to be. Will keep aspect
// ratio no matter what. So if both are 800, the returned image
// will be at most 800 pixels wide and 800 pixels tall. If the width is
// 800 and height 0 the image will be 800 pixels wide if the source
// is at least that wide.
width?: number;
height?: number;
// quality of resized image, defaults to 100
quality?: number;
// quality of resized image, defaults to 100
quality?: number;
}
/**
@ -26,8 +27,8 @@ export interface ImagePickerOptions {
* For more info, please see the https://github.com/wymsee/cordova-imagePicker
*
* @usage
* ```js
* import {ImagePicker} from 'ionic-native';
* ```typescript
* import { ImagePicker } from 'ionic-native';
*
*
*
@ -35,8 +36,7 @@ export interface ImagePickerOptions {
* for (var i = 0; i < results.length; i++) {
* console.log('Image URI: ' + results[i]);
* }
* }, (err) => {
* });
* }, (err) => { });
* ```
*/
@Plugin({
@ -55,4 +55,5 @@ export class ImagePicker {
callbackOrder: 'reverse'
})
static getPictures(options: ImagePickerOptions): Promise<any> { return; }
}

View File

@ -0,0 +1,77 @@
import { Cordova, Plugin } from './plugin';
export interface ImageResizerOptions {
/**
* The URI for the image on the device to get scaled
*/
uri: string;
/**
* The width of the new image
*/
width: number;
/**
* The height of the new image
*/
height: number;
/**
* The name of the folder the image should be put
* (Android only)
*/
folderName?: string;
/**
*
* Quality given as Number for the quality of the new image
* (Android and iOS only)
*/
quality?: number;
/**
* A custom name for the file. Default name is a timestamp
* (Android and Windows only)
*/
fileName?: string;
}
/**
* @name ImageResizer
* @description
* Cordova Plugin For Image Resize
*
* Requires plugin `info.protonet.imageresizer` - use the Ionic CLI and type in the following command:
* `ionic plugin add https://github.com/protonet/cordova-plugin-image-resizer.git`
*
* For more info, please see the https://github.com/protonet/cordova-plugin-image-resizer
*
* @usage
* ```typescript
* import { ImageResizer, ImageResizerOptions } from 'ionic-native';
*
* let options = {
* uri: uri,
* folderName: 'Protonet',
* quality: 90,
* width: 1280,
* height: 1280
* } as ImageResizerOptions;
*
* ImageResizer
* .resize(options)
* .then(
* (filePath: string) => { console.log('FilePath', filePath); },
* () => { console.log('Error occured'); }
* )
* ```
*/
@Plugin({
plugin: 'https://github.com/protonet/cordova-plugin-image-resizer.git',
pluginRef: 'ImageResizer',
repo: 'https://github.com/protonet/cordova-plugin-image-resizer'
})
export class ImageResizer {
@Cordova()
static resize(options: ImageResizerOptions): Promise<any> { return; }
}

View File

@ -1,85 +1,103 @@
import {Plugin, Cordova} from './plugin';
export interface InAppBrowserEvent extends Event {
/** the eventname, either loadstart, loadstop, loaderror, or exit. */
type: string;
/** the URL that was loaded. */
url: string;
/** the error code, only in the case of loaderror. */
code: number;
/** the error message, only in the case of loaderror. */
message: string;
}
export interface InAppBrowserRef {
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: string, callback: (event: InAppBrowserEvent) => void);
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: string, callback: (event: InAppBrowserEvent) => void);
/** Closes the InAppBrowser window. */
close();
/**
* Displays an InAppBrowser window that was opened hidden. Calling this has no effect
* if the InAppBrowser was already visible.
*/
show();
/**
* Injects JavaScript code into the InAppBrowser window.
* @param script Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the JavaScript code is injected.
* If the injected script is of type code, the callback executes with
* a single parameter, which is the return value of the script, wrapped in an Array.
* For multi-line scripts, this is the return value of the last statement,
* or the last expression evaluated.
*/
executeScript(script: {file?: string, code?: string}, callback?: (result?: any) => void);
/**
* Injects CSS into the InAppBrowser window.
* @param css Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the CSS is injected.
*/
insertCSS(css: {file?: string, code?: string}, callback?: () => void);
}
@Plugin({
plugin: 'cordova-plugin-inappbrowser',
pluginRef: 'cordova.InAppBrowser'
})
export class InAppBrowser {
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
@Cordova({
sync: true
})
static open(url: string, target?: string, options?: string): InAppBrowserRef { return; }
}
import { Plugin, CordovaInstance } from './plugin';
import { Observable } from 'rxjs/Observable';
declare var cordova: any;
export interface InAppBrowserEvent extends Event {
/** the eventname, either loadstart, loadstop, loaderror, or exit. */
type: string;
/** the URL that was loaded. */
url: string;
/** the error code, only in the case of loaderror. */
code: number;
/** the error message, only in the case of loaderror. */
message: string;
}
/**
* @name InAppBrowser
* @description Launches in app Browser
* @usage
* ```typescript
* import {InAppBrowser} from 'ionic-native';
*
*
* ...
*
*
* let browser = new InAppBrowser('https://ionic.io', '_system');
* browser.executeScript(...);
* browser.insertCSS(...);
* browser.close();
* ```
*/
@Plugin({
plugin: 'cordova-plugin-inappbrowser',
pluginRef: 'cordova.InAppBrowser',
repo: 'https://github.com/apache/cordova-plugin-inappbrowser'
})
export class InAppBrowser {
static open(url: string, target?: string, options?: string): void {
console.warn('Native: Your current usage of the InAppBrowser plugin is depreciated as of ionic-native@1.3.8. Please check the Ionic Native docs for the latest usage details.');
}
private _objectInstance: any;
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
constructor(url: string, target?: string, options?: string) {
try {
this._objectInstance = cordova.InAppBrowser.open(url, target, options);
} catch (e) {
window.open(url);
console.warn('Native: InAppBrowser is not installed or you are running on a browser. Falling back to window.open, all instance methods will NOT work.');
}
}
/**
* Displays an InAppBrowser window that was opened hidden. Calling this has no effect
* if the InAppBrowser was already visible.
*/
@CordovaInstance({sync: true})
show(): void { }
/**
* Closes the InAppBrowser window.
*/
@CordovaInstance({sync: true})
close(): void { }
/**
* Injects JavaScript code into the InAppBrowser window.
* @param script Details of the script to run, specifying either a file or code key.
*/
@CordovaInstance()
executeScript(script: {file?: string, code?: string}): Promise<any> {return; }
/**
* Injects CSS into the InAppBrowser window.
* @param css Details of the script to run, specifying either a file or code key.
*/
@CordovaInstance()
insertCss(css: {file?: string, code?: string}): Promise<any> {return; }
/**
* A method that allows you to listen to events happening in the browser.
* @param event Event name
* @returns {Observable<any>} Returns back an observable that will listen to the event on subscribe, and will stop listening to the event on unsubscribe.
*/
on(event: string): Observable<InAppBrowserEvent> {
return new Observable<InAppBrowserEvent>((observer) => {
this._objectInstance.addEventListener(event, observer.next.bind(observer));
return () => this._objectInstance.removeEventListener(event, observer.next.bind(observer));
});
}
}

View File

@ -1,4 +1,5 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Insomnia
@ -6,8 +7,9 @@ import {Plugin, Cordova} from './plugin';
* Prevent the screen of the mobile device from falling asleep.
*
* @usage
* ```js
* import {Insomnia} from 'ionic-native';
* ```typescript
* import { Insomnia } from 'ionic-native';
*
*
* Insomnia.keepAwake()
* .then(
@ -44,4 +46,5 @@ export class Insomnia {
*/
@Cordova()
static allowSleepAgain(): Promise<any> { return; }
}

57
src/plugins/instagram.ts Normal file
View File

@ -0,0 +1,57 @@
import {Plugin, Cordova} from './plugin';
/**
* @name Instagram
* @description Share a photo with the instagram app
*
* @usage
* ```
* import {Instagram} from 'ionic-native';
*
* Instagram.share('data:image/png;uhduhf3hfif33', 'Caption')
* .then(() => console.log('Shared!'))
* .catch((error: any) => console.error(error));
*
* ```
*/
@Plugin({
plugin: 'cordova-instagram-plugin',
pluginRef: 'Instagram',
repo: 'https://github.com/vstirbu/InstagramPlugin'
})
export class Instagram {
/**
* Detect if the Instagram application is installed on the device.
*
* @return {Promise<boolean|string>} Returns a promise that returns a boolean value if installed, or the app version on android
*/
@Cordova({
callbackStyle: 'node'
})
static isInstalled(): Promise<boolean|string> { return; }
/**
* Share an image on Instagram
* Note: Instagram app stopped accepting pre-filled captions on both iOS and Android. As a work-around, the caption is copied to the clipboard. You have to inform your users to paste the caption.
*
* @param canvasIdOrDataUrl The canvas element id or the dataURL of the image to share
* @param caption The caption of the image
* @return {Promise<any>} Returns a promise that resolves if the image was shared
*/
@Cordova({
callbackStyle: 'node'
})
static share(canvasIdOrDataUrl: string, caption?: string): Promise<any> { return; }
/**
* Share a library asset or video
* @param assetLocalIdentifier A local fileURI
* @return {Promise<any>} Returns a promise that resolves if the image was shared
*/
@Cordova({
callbackOrder: 'reverse'
})
static shareAsset(assetLocalIdentifier: string): Promise<any> { return; }
}

35
src/plugins/is-debug.ts Normal file
View File

@ -0,0 +1,35 @@
import {Plugin, Cordova} from './plugin';
/**
* @name IsDebug
* @description
* Detect if the app is running in debug mode or not.
* Debug mode is when the app is built and installed locally via xcode / eclipse / the cordova cli etc, compared to release mode when the app was downloaded from the app / play store via an end user.
*
* @usage
* ```
* import {IsDebug} from 'ionic-native';
*
* IsDebug.getIsDebug()
* .then((isDebug: boolean) => console.log('Is debug:', isDebug))
* .catch((error: any) => console.error(error));
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-is-debug',
pluginRef: 'cordova.plugins.IsDebug',
repo: 'https://github.com/mattlewis92/cordova-plugin-is-debug'
})
export class IsDebug {
/**
* Determine if an app was installed via xcode / eclipse / the ionic CLI etc
* @return {Promise<boolean>} Returns a promise that resolves with true if the app was installed via xcode / eclipse / the ionic CLI etc. It will resolve to false if the app was downloaded from the app / play store by the end user.
*/
@Cordova()
static getIsDebug(): Promise<boolean> {
return;
}
}

View File

@ -1,12 +1,13 @@
import {Cordova, Plugin} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @name Keyboard
* @description
* @usage
* ```js
* import {Keyboard} from 'ionic-native';
* ```typescript
* import { Keyboard } from 'ionic-native';
*
*
*
@ -23,9 +24,8 @@ export class Keyboard {
* Hide the keyboard accessory bar with the next, previous and done buttons.
* @param hide {boolean}
*/
static hideKeyboardAccessoryBar(hide: boolean): void {
console.log('hideKeyboardAccessoryBar method has been removed temporarily.');
}
@Cordova({sync: true})
static hideKeyboardAccessoryBar(hide: boolean): void { }
/**
* Force keyboard to be shown.
@ -34,7 +34,7 @@ export class Keyboard {
sync: true,
platforms: ['Android', 'BlackBerry 10', 'Windows']
})
static show(): void {}
static show(): void { }
/**
* Close the keyboard if open.
@ -43,7 +43,7 @@ export class Keyboard {
sync: true,
platforms: ['iOS', 'Android', 'BlackBerry 10', 'Windows']
})
static close(): void {}
static close(): void { }
/**
* Prevents the native UIScrollView from moving when an input is focused.
@ -53,7 +53,7 @@ export class Keyboard {
sync: true,
platforms: ['iOS', 'Windows']
})
static disableScroll(disable: boolean): void {}
static disableScroll(disable: boolean): void { }
/**
* Creates an observable that notifies you when the keyboard is shown. Unsubscribe to observable to cancel event watch.
@ -63,7 +63,7 @@ export class Keyboard {
event: 'native.keyboardshow',
platforms: ['iOS', 'Android', 'BlackBerry 10', 'Windows']
})
static onKeyboardShow(): Observable<any> {return; }
static onKeyboardShow(): Observable<any> { return; }
/**
* Creates an observable that notifies you when the keyboard is hidden. Unsubscribe to observable to cancel event watch.
@ -73,6 +73,6 @@ export class Keyboard {
event: 'native.keyboardhide',
platforms: ['iOS', 'Android', 'BlackBerry 10', 'Windows']
})
static onKeyboardHide(): Observable<any> {return; }
static onKeyboardHide(): Observable<any> { return; }
}

View File

@ -1,49 +1,61 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } 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,15 +64,20 @@ 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
* ```js
* import {LaunchNavigator} from 'ionic-native';
* Please refer to the plugin's repo for detailed usage. This docs page only explains the Native wrapper.
*
* ```typescript
* 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)
* success => console.log('Launched navigator'),
* error => console.log('Error launching navigator', error)
* );
* ```
*/
@ -73,19 +90,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; }
): 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

@ -1,20 +1,21 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Local Notifications
* @description
* This plugin allows you to display local notifications on the device
*
* @usage
* ```ts
* import {LocalNotifications} from 'ionic-native';
*
* ```typescript
* import { LocalNotifications } from 'ionic-native';
*
*
* // Schedule a single notification
* LocalNotifications.schedule({
* id: 1,
* text: "Single Notification",
* sound: isAndroid? 'file://sound.mp3': 'file://beep.caf'
* text: 'Single Notification',
* sound: isAndroid? 'file://sound.mp3': 'file://beep.caf',
* data: { secret: key }
* });
*
@ -22,22 +23,22 @@ import {Plugin, Cordova} from './plugin';
* // Schedule multiple notifications
* LocalNotifications.schedule([{
* id: 1,
* text: "Multi Notification 1",
* text: 'Multi Notification 1',
* sound: isAndroid ? 'file://sound.mp3': 'file://beep.caf',
* data: { secret:key }
* },{
* id: 2,
* title: "Local Notification Example",
* text: "Multi Notification 2",
* icon: "http://example.com/icon.png"
* title: 'Local Notification Example',
* text: 'Multi Notification 2',
* icon: 'http://example.com/icon.png'
* }]);
*
*
* // Schedule delayed notification
* LocalNotifications.schedule({
* text: "Delayed Notification",
* text: 'Delayed Notification',
* at: new Date(new Date().getTime() + 3600),
* led: "FF0000",
* led: 'FF0000',
* sound: null
* });
* ```
@ -57,7 +58,7 @@ export class LocalNotifications {
@Cordova({
sync: true
})
static schedule(options?: Notification|Array<Notification>): void {}
static schedule(options?: Notification | Array<Notification>): void { }
/**
* Updates a previously scheduled notification. Must include the id in the options parameter.
@ -66,14 +67,14 @@ export class LocalNotifications {
@Cordova({
sync: true
})
static update(options?: Notification): void {}
static update(options?: Notification): void { }
/**
* Clears single or multiple notifications
* @param notificationId A single notification id, or an array of notification ids.
*/
@Cordova()
static clear(notificationId: any): Promise<any> {return; }
static clear(notificationId: any): Promise<any> { return; }
/**
* Clears all notifications
@ -82,14 +83,14 @@ export class LocalNotifications {
successIndex: 0,
errorIndex: 2
})
static clearAll(): Promise<any> {return; }
static clearAll(): Promise<any> { return; }
/**
* Cancels single or multiple notifications
* @param notificationId A single notification id, or an array of notification ids.
*/
@Cordova()
static cancel(notificationId: any): Promise<any> {return; }
static cancel(notificationId: any): Promise<any> { return; }
/**
* Cancels all notifications
@ -98,85 +99,85 @@ export class LocalNotifications {
successIndex: 0,
errorIndex: 2
})
static cancelAll(): Promise<any> {return; }
static cancelAll(): Promise<any> { return; }
/**
* Checks presence of a notification
* @param notificationId
*/
@Cordova()
static isPresent (notificationId: number): Promise<boolean> {return; }
static isPresent(notificationId: number): Promise<boolean> { return; }
/**
* Checks is a notification is scheduled
* @param notificationId
*/
@Cordova()
static isScheduled (notificationId: number): Promise<boolean> {return; }
static isScheduled(notificationId: number): Promise<boolean> { return; }
/**
* Checks if a notification is triggered
* @param notificationId
*/
@Cordova()
static isTriggered (notificationId: number): Promise<boolean> {return; }
static isTriggered(notificationId: number): Promise<boolean> { return; }
/**
* Get all the notification ids
*/
@Cordova()
static getAllIds (): Promise<Array<number>> {return; }
static getAllIds(): Promise<Array<number>> { return; }
/**
* Get the ids of triggered notifications
*/
@Cordova()
static getTriggeredIds (): Promise<Array<number>> {return; }
static getTriggeredIds(): Promise<Array<number>> { return; }
/**
* Get the ids of scheduled notifications
*/
@Cordova()
static getScheduledIds (): Promise<Array<number>> {return; }
static getScheduledIds(): Promise<Array<number>> { return; }
/**
* Get a notification object
* @param notificationId The id of the notification to get
*/
@Cordova()
static get (notificationId: any): Promise <Notification> {return; }
static get(notificationId: any): Promise<Notification> { return; }
/**
* Get a scheduled notification object
* @param notificationId The id of the notification to get
*/
@Cordova()
static getScheduled (notificationId: any): Promise <Notification> {return; }
static getScheduled(notificationId: any): Promise<Notification> { return; }
/**
* Get a triggered notification object
* @param notificationId The id of the notification to get
*/
@Cordova()
static getTriggered (notificationId: any): Promise <Notification> {return; }
static getTriggered(notificationId: any): Promise<Notification> { return; }
/**
* Get all notification objects
*/
@Cordova()
static getAll(): Promise<Array<Notification>> {return; }
static getAll(): Promise<Array<Notification>> { return; }
/**
* Get all scheduled notification objects
*/
@Cordova()
static getAllScheduled(): Promise<Array<Notification>> {return; }
static getAllScheduled(): Promise<Array<Notification>> { return; }
/**
* Get all triggered notification objects
*/
@Cordova()
static getAllTriggered(): Promise<Array<Notification>> {return; }
static getAllTriggered(): Promise<Array<Notification>> { return; }
/**
@ -187,7 +188,7 @@ export class LocalNotifications {
@Cordova({
sync: true
})
static on(eventName: string, callback: any): void {}
static on(eventName: string, callback: any): void { }
}

View File

@ -0,0 +1,221 @@
import { Cordova, CordovaProperty, Plugin } 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

@ -1,26 +1,34 @@
import {CordovaInstance, Plugin} from './plugin';
import {Observable} from 'rxjs/Observable';
import { CordovaInstance, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
declare var Media: any;
export interface MediaError {
code: number;
message: string;
}
/**
* @name MediaPlugin
* @description
* @usage
* ```ts
* import {MediaPlugin} from 'ionic-native';
* ```typescript
* import { MediaPlugin } from 'ionic-native';
*
*
*
* // Create a MediaPlugin instance. Expects path to file or url as argument
* var file = new MediaPlugin("path/to/file.mp3");
* var file = new MediaPlugin('path/to/file.mp3');
*
* // Catch the Success & Error Output
* // Platform Quirks
* // iOS calls success on completion of playback only
* // Android calls success on completion of playback AND on release()
* file.init.then(() => {
* console.log("Playback Finished");
* console.log('Playback Finished');
* }, (err) => {
* console.log("somthing went wrong! error code: "+err.code+" message: "+err.message);
* console.log('somthing went wrong! error code: ' + err.code + ' message: ' + err.message);
* });
*
* // play the file
@ -52,7 +60,7 @@ declare var Media: any;
* file.release();
*
* // Recording to a file
* var newFile = new MediaPlugin("path/to/file.mp3");
* var newFile = new MediaPlugin('path/to/file.mp3');
* newFile.startRecord();
*
* newFile.stopRecord();
@ -75,6 +83,12 @@ export class MediaPlugin {
static MEDIA_PAUSED: number = 3;
static MEDIA_STOPPED: number = 4;
// error codes
static MEDIA_ERR_ABORTED: number = 1;
static MEDIA_ERR_NETWORK: number = 2;
static MEDIA_ERR_DECODE: number = 3;
static MEDIA_ERR_NONE_SUPPORTED: number = 4;
// Properties
private _objectInstance: any;
status: Observable<any>;
@ -85,11 +99,11 @@ export class MediaPlugin {
* Open a media file
* @param src {string} A URI containing the audio content.
*/
constructor (src: string) {
constructor(src: string) {
let res, rej, next;
this.init = new Promise<any>((resolve, reject) => {res = resolve; rej = reject; });
this.init = new Promise<any>((resolve, reject) => { res = resolve; rej = reject; });
this.status = new Observable((observer) => {
next = data => observer.next(data);
next = data => observer.next(data);
});
this._objectInstance = new Media(src, res, rej, next);
}
@ -98,13 +112,13 @@ export class MediaPlugin {
* Returns the current amplitude of the current recording.
*/
@CordovaInstance()
getCurrentAmplitude (): Promise<any> {return; }
getCurrentAmplitude(): Promise<any> { return; }
/**
* Returns the current position within an audio file. Also updates the Media object's position parameter.
*/
@CordovaInstance()
getCurrentPosition (): Promise<any> {return; }
getCurrentPosition(): Promise<any> { return; }
/**
* Returns the duration of an audio file in seconds. If the duration is unknown, it returns a value of -1.
@ -112,7 +126,7 @@ export class MediaPlugin {
@CordovaInstance({
sync: true
})
getDuration (): number {return; }
getDuration(): number { return; }
/**
* Starts or resumes playing an audio file.
@ -120,10 +134,10 @@ export class MediaPlugin {
@CordovaInstance({
sync: true
})
play (iosOptions?: {
play(iosOptions?: {
numberOfLoops?: number,
playAudioWhenScreenIsLocked?: boolean
}): void {}
}): void { }
/**
* Pauses playing an audio file.
@ -131,7 +145,7 @@ export class MediaPlugin {
@CordovaInstance({
sync: true
})
pause (): void {}
pause(): void { }
/**
* Releases the underlying operating system's audio resources. This is particularly important for Android, since there are a finite amount of OpenCore instances for media playback. Applications should call the release function for any Media resource that is no longer needed.
@ -139,7 +153,7 @@ export class MediaPlugin {
@CordovaInstance({
sync: true
})
release (): void {}
release(): void { }
/**
* Sets the current position within an audio file.
@ -148,7 +162,7 @@ export class MediaPlugin {
@CordovaInstance({
sync: true
})
seekTo (milliseconds: number): void {}
seekTo(milliseconds: number): void { }
/**
* Set the volume for an audio file.
@ -157,7 +171,7 @@ export class MediaPlugin {
@CordovaInstance({
sync: true
})
setVolume (volume: number): void {}
setVolume(volume: number): void { }
/**
* Starts recording an audio file.
@ -165,7 +179,7 @@ export class MediaPlugin {
@CordovaInstance({
sync: true
})
startRecord (): void {}
startRecord(): void { }
/**
@ -174,7 +188,7 @@ export class MediaPlugin {
@CordovaInstance({
sync: true
})
stopRecord (): void {}
stopRecord(): void { }
/**
@ -183,17 +197,6 @@ export class MediaPlugin {
@CordovaInstance({
sync: true
})
stop (): void {}
stop(): void { }
}
export class MediaError {
static get MEDIA_ERR_ABORTED () {return 1; }
static get MEDIA_ERR_NETWORK () {return 2; }
static get MEDIA_ERR_DECODE () {return 3; }
static get MEDIA_ERR_NONE_SUPPORTED () {return 4; }
code: number;
message: string;
}

View File

@ -0,0 +1,91 @@
import { Plugin, Cordova } from './plugin';
/**
* @name NativeAudio
* @description Native Audio Playback
* @usage
* ```typescript
* import {NativeAudio} from 'ionic-native';
*
* NativeAudio.preloadSimple('uniqueId1', 'path/to/file.mp3').then(onSuccess, onError);
* NativeAudio.preloadComplex('uniqueId2', 'path/to/file2.mp3', 1, 1, 0).then(onSuccess, onError);
*
* NativeAudio.play('uniqueId1').then(onSuccess, onError);
* NativeAudio.loop('uniqueId2').then(onSuccess, onError);
*
* NativeAudio.setVolumeForComplexAsset('uniqueId2', 0.6).then(onSuccess,onError);
*
* NativeAudio.stop('uniqueId1').then(onSuccess,onError);
*
* NativeAudio.unload('uniqueId1').then(onSuccess,onError);
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-nativeaudio',
pluginRef: 'plugins.NativeAudio',
repo: 'https://github.com/floatinghotpot/cordova-plugin-nativeaudio'
})
export class NativeAudio {
/**
* Loads an audio file into memory. Optimized for short clips / single shots (up to five seconds). Cannot be stopped / looped.
* @param id {string} unique ID for the audio file
* @param assetPath {string} the relative path or absolute URL (inluding http://) to the audio asset.
* @returns {Promise<any>}
*/
@Cordova()
static preloadSimple(id: string, assetPath: string): Promise<any> {return; }
/**
* Loads an audio file into memory. Optimized for background music / ambient sound. Uses highlevel native APIs with a larger footprint. (iOS: AVAudioPlayer). Can be stopped / looped and used with multiple voices. Can be faded in and out using the delay parameter.
* @param id {string} unique ID for the audio file
* @param assetPath {string} the relative path or absolute URL (inluding http://) to the audio asset.
* @param volume {number} the volume of the preloaded sound (0.1 to 1.0)
* @param voices {number} the number of multichannel voices available
* @param delay {number}
* @returns {Promise<any>}
*/
@Cordova()
static preloadComplex(id: string, assetPath: string, volume: number, voices: number, delay: number): Promise<any> {return; }
/**
* Plays an audio asset
* @param id {string} unique ID for the audio file
* @param completeCallback {Function} callback to be invoked when audio is done playing
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
static play(id: string, completeCallback: Function): Promise<any> {return; }
/**
* Stops playing an audio
* @param id {string} unique ID for the audio file
*/
@Cordova()
static stop(id: string): Promise<any> {return; }
/**
* Loops an audio asset infinitely, this only works for complex assets
* @param id {string} unique ID for the audio file
* @return {Promise<any>}
*/
@Cordova()
static loop(id: string): Promise<any> {return; }
/**
* Unloads an audio file from memory
* @param id {string} unique ID for the audio file
*/
@Cordova()
static unload(id: string): Promise<any> {return; }
/**
* Changes the volume for preloaded complex assets.
* @param id {string} unique ID for the audio file
* @param volume {number} the volume of the audio asset (0.1 to 1.0)
*/
@Cordova()
static setVolumeForComplexAsset(id: string, volume: number): Promise<any> {return; }
}

View File

@ -0,0 +1,59 @@
import { Cordova, Plugin } from './plugin';
/**
* @name NativeStorage
* @description Native storage of variables in Android and iOS
*
* @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 {string}
* @param value
*/
@Cordova()
static setItem(reference: string, value: any): Promise<any> {return; }
/**
* Gets a stored item
* @param reference {string}
*/
@Cordova()
static getItem(reference: string): Promise<any> {return; }
/**
* Removes a single stored item
* @param reference {string}
*/
@Cordova()
static remove(reference: string): Promise<any> {return; }
/**
* Removes all stored values.
*/
@Cordova()
static clear(): Promise<any> {return; }
}

View File

@ -1,5 +1,6 @@
import {Plugin, Cordova, CordovaProperty} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, CordovaProperty, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
declare var navigator: any;
@ -9,12 +10,12 @@ declare var navigator: any;
* Requires Cordova plugin: cordova-plugin-network-information. For more info, please see the [Network plugin docs](https://github.com/apache/cordova-plugin-network-information).
*
* @usage
* ```js
* import {Network} from 'ionic-native';
* ```typescript
* import { Network } from 'ionic-native';
*
* // watch network for a disconnect
* let disconnectSubscription = Network.onDisconnect().subscribe(() => {
* console.log('network was disconnected :-( ')
* console.log('network was disconnected :-(');
* });
*
* // stop disconnect watch
@ -23,9 +24,9 @@ declare var navigator: any;
*
* // watch network for a connection
* let connectSubscription = Network.onConnect().subscribe(() => {
* console.log('network connected!');*
* console.log('network connected!');
* // We just got a connection but we need to wait briefly
*// before we determine the connection type. Might need to wait
* // before we determine the connection type. Might need to wait
* // prior to doing any api requests as well.
* setTimeout(() => {
* if (Network.connection === 'wifi') {
@ -53,7 +54,7 @@ export class Network {
* Return the network connection type
*/
@CordovaProperty
static get connection(): String { return navigator.connection.type; }
static get connection(): string { return navigator.connection.type; }
/**
* Get notified when the device goes offline

View File

@ -1,4 +1,6 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @name OneSignal
@ -9,245 +11,244 @@ import {Plugin, Cordova} from './plugin';
* Requires Cordova plugin: `onesignal-cordova-plugin`. For more info, please see the [OneSignal Cordova Docs](https://documentation.onesignal.com/docs/phonegap-sdk-installation).
*
* @usage
* ```ts
* import {OneSignal} from 'ionic-native';
* ```typescript
* import { OneSignal } from 'ionic-native';
*
* OneSignal.init('b2f7f966-d8cc-11e4-bed1-df8f05be55ba',
* {googleProjectNumber: '703322744261'})
* .subscribe(jsonData => {
* console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
* });
*
* let notificationOpenedCallback(jsonData: any) {
* console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
* };
* OneSignal.init("b2f7f966-d8cc-11e4-bed1-df8f05be55ba",
* {googleProjectNumber: "703322744261"},
* notificationOpenedCallback);
*
* OneSignal.enableInAppAlertNotification(true);
* ```
*
*/
@Plugin({
plugin: 'onesignal-cordova-plugin',
pluginRef: 'plugins.OneSignal',
repo: 'https://github.com/OneSignal/OneSignal-Cordova-SDK',
platforms: ['Android', 'iOS', 'Windows Phone 8']
plugin: 'onesignal-cordova-plugin',
pluginRef: 'plugins.OneSignal',
repo: 'https://github.com/OneSignal/OneSignal-Cordova-SDK'
})
export class OneSignal {
/**
* Only required method you need to call to setup OneSignal to receive push notifications. Call this from the `deviceready` event.
*
* @param {appId} Your AppId from your OneSignal app
* @param {options} The Google Project Number (which you can get from the Google Developer Potal) and the autoRegister option.
* @returns {Promise} Returns a Promise that resolves when remote notification was recieved.
*/
@Cordova()
static init(appId: string,
options: {
googleProjectNumber: string,
autoRegister: boolean
}): Promise<any> { return; }
/**
* Call this when you would like to prompt an iOS user to accept push notifications with the default system prompt.
* Only use if you passed false to autoRegister when calling init.
*/
@Cordova({ sync: true })
static registerForPushNotifications(): void { }
/**
* Tag a user based on an app event of your choosing so later you can create segments on [onesignal.com](https://onesignal.com/) to target these users.
* Recommend using sendTags over sendTag if you need to set more than one tag on a user at a time.
*
* @param {key} Key of your choosing to create or update.
* @param {value} Value to set on the key. NOTE: Passing in a blank String deletes the key, you can also call deleteTag.
*/
@Cordova({ sync: true })
static sendTag(key: string, value: string): void { }
/**
* Tag a user based on an app event of your choosing so later you can create segments on [onesignal.com](https://onesignal.com/) to target these users.
* Recommend using sendTags over sendTag if you need to set more than one tag on a user at a time.
*
* @param {json} Pass a json object with key/value pairs like: {key: "value", key2: "value2"}
*/
@Cordova({ sync: true })
static sendTags(json: any): void { }
/**
* Retrieve a list of tags that have been set on the user from the OneSignal server.
*
* @returns {Promise} Returns a Promise that resolves when tags are recieved.
*/
@Cordova()
static getTags(): Promise<any> { return; }
/**
* Deletes a tag that was previously set on a user with `sendTag` or `sendTags`. Use `deleteTags` if you need to delete more than one.
*
* @param {key} Key to remove.
*/
@Cordova({ sync: true })
static deleteTag(key: string): void { }
/**
* Deletes tags that were previously set on a user with `sendTag` or `sendTags`.
*
* @param {keys} Keys to remove.
*/
@Cordova({ sync: true })
static deleteTags(keys: string[]): void { }
/**
* Lets you retrieve the OneSignal user id and device token.
* Your handler is called after the device is successfully registered with OneSignal.
*
* @returns {Promise} Returns a Promise that reolves if the device was successfully registered.
* It returns a JSON with `userId`and `pushToken`.
*/
@Cordova()
static getIds(): Promise<any> { return; }
/**
* Warning:
* Only applies to Android and Amazon. You can call this from your UI from a button press for example to give your user's options for your notifications.
*
* By default OneSignal always vibrates the device when a notification is displayed unless the device is in a total silent mode.
* Passing false means that the device will only vibrate lightly when the device is in it's vibrate only mode.
*
* @param {enable} false to disable vibrate, true to re-enable it.
*/
@Cordova({ sync: true })
static enableVibrate(enable: boolean): void { }
/**
* Warning:
* Only applies to Android and Amazon. You can call this from your UI from a button press for example to give your user's options for your notifications.
*
* By default OneSignal plays the system's default notification sound when the device's notification system volume is turned on.
* Passing false means that the device will only vibrate unless the device is set to a total silent mode.
*
* @param {enable} false to disable sound, true to re-enable it.
*/
@Cordova({ sync: true })
static enableSound(enable: boolean): void { }
/**
* Warning:
* Only applies to Android and Amazon devices.
*
* By default this is false and notifications will not be shown when the user is in your app, instead the notificationOpenedCallback is fired.
* If set to true notifications will always show in the notification area and notificationOpenedCallback will not fire until the user taps on the notification.
*
* @param {enable} enable
*/
@Cordova({ sync: true })
static enableNotificationsWhenActive(enable: boolean): void { }
/**
* By default this is false and notifications will not be shown when the user is in your app, instead the notificationOpenedCallback is fired.
* If set to true notifications will be shown as native alert boxes if a notification is received when the user is in your app.
* The notificationOpenedCallback is then fired after the alert box is closed.
*
* @param {enable} enable
*/
@Cordova({ sync: true })
static enableInAppAlertNotification(enable: boolean): void { }
/**
* You can call this method with false to opt users out of receiving all notifications through OneSignal.
* You can pass true later to opt users back into notifications.
*
* @param {enable} enable
*/
@Cordova({ sync: true })
static setSubscription(enable: boolean): void { }
/**
/**
* Only required method you need to call to setup OneSignal to receive push notifications. Call this from the `deviceready` event.
*
* @param {notificationObj} Parameters see POST [documentation](https://documentation.onesignal.com/v2.0/docs/notifications-create-notification)
* @returns {Promise} Returns a Promise that resolves if the notification was send successfully.
* @param {appId} Your AppId from your OneSignal app
* @param {options} The Google Project Number (which you can get from the Google Developer Potal) and the autoRegister option.
* @returns {Observable} when a notification is received. Handle your notification action here.
*/
@Cordova()
static postNotification(notificationObj: {
app_id: string,
contents: any,
headings?: any,
isIos?: boolean,
isAndroid?: boolean,
isWP?: boolean,
isWP_WNS?: boolean,
isAdm?: boolean,
isChrome?: boolean,
isChromeWeb?: boolean,
isSafari?: boolean,
isAnyWeb?: boolean,
included_segments?: string[],
excluded_segments?: string[],
include_player_ids?: string[],
include_ios_tokens?: string[],
include_android_reg_ids?: string[],
include_wp_uris?: string[],
include_wp_wns_uris?: string[],
include_amazon_reg_ids?: string[],
include_chrome_reg_ids?: string[],
include_chrome_web_reg_ids?: string[],
app_ids?: string[];
tags?: any[],
ios_badgeType?: string,
ios_badgeCount?: number,
ios_sound?: string,
android_sound?: string,
adm_sound?: string,
wp_sound?: string,
wp_wns_sound?: string,
data?: any,
buttons?: any,
small_icon?: string,
large_icon?: string,
big_picture?: string,
adm_small_icon?: string,
adm_large_icon?: string,
adm_big_picture?: string,
chrome_icon?: string,
chrome_big_picture?: string,
chrome_web_icon?: string,
firefox_icon?: string,
url?: string,
send_after?: string,
delayed_option?: string,
delivery_time_of_day?: string,
android_led_color?: string,
android_accent_color?: string,
android_visibility?: number,
content_available?: boolean,
amazon_background_data?: boolean,
template_id?: string,
android_group?: string,
android_group_message?: any,
adm_group?: string,
adm_group_message?: any,
ttl?: number,
priority?: number,
ios_category?: string
}): Promise<any> { return; }
@Cordova({ observable: true })
static init(appId: string,
options: {
googleProjectNumber: string,
autoRegister: boolean
}): Observable<any> { return; }
/**
* Prompts the user for location permission to allow geotagging based on the "Location radius" filter on the OneSignal dashboard.
*/
@Cordova({ sync: true })
static promptLocation(): void { }
/**
* Enable logging to help debug if you run into an issue setting up OneSignal.
* The logging levels are as follows: 0 = None, 1= Fatal, 2 = Errors, 3 = Warnings, 4 = Info, 5 = Debug, 6 = Verbose
/**
* Call this when you would like to prompt an iOS user to accept push notifications with the default system prompt.
* Only use if you passed false to autoRegister when calling init.
*/
@Cordova({ sync: true })
static registerForPushNotifications(): void { }
/**
* Tag a user based on an app event of your choosing so later you can create segments on [onesignal.com](https://onesignal.com/) to target these users.
* Recommend using sendTags over sendTag if you need to set more than one tag on a user at a time.
*
* @param {key} Key of your choosing to create or update.
* @param {value} Value to set on the key. NOTE: Passing in a blank String deletes the key, you can also call deleteTag.
*/
@Cordova({ sync: true })
static sendTag(key: string, value: string): void { }
/**
* Tag a user based on an app event of your choosing so later you can create segments on [onesignal.com](https://onesignal.com/) to target these users.
* Recommend using sendTags over sendTag if you need to set more than one tag on a user at a time.
*
* @param {json} Pass a json object with key/value pairs like: {key: "value", key2: "value2"}
*/
@Cordova({ sync: true })
static sendTags(json: any): void { }
/**
* Retrieve a list of tags that have been set on the user from the OneSignal server.
*
* @returns {Promise} Returns a Promise that resolves when tags are recieved.
*/
@Cordova()
static getTags(): Promise<any> { return; }
/**
* Deletes a tag that was previously set on a user with `sendTag` or `sendTags`. Use `deleteTags` if you need to delete more than one.
*
* @param {key} Key to remove.
*/
@Cordova({ sync: true })
static deleteTag(key: string): void { }
/**
* Deletes tags that were previously set on a user with `sendTag` or `sendTags`.
*
* @param {keys} Keys to remove.
*/
@Cordova({ sync: true })
static deleteTags(keys: string[]): void { }
/**
* Lets you retrieve the OneSignal user id and device token.
* Your handler is called after the device is successfully registered with OneSignal.
*
* @returns {Promise} Returns a Promise that reolves if the device was successfully registered.
* It returns a JSON with `userId`and `pushToken`.
*/
@Cordova()
static getIds(): Promise<any> { return; }
/**
* Warning:
* Only applies to Android and Amazon. You can call this from your UI from a button press for example to give your user's options for your notifications.
*
* By default OneSignal always vibrates the device when a notification is displayed unless the device is in a total silent mode.
* Passing false means that the device will only vibrate lightly when the device is in it's vibrate only mode.
*
* @param {enable} false to disable vibrate, true to re-enable it.
*/
@Cordova({ sync: true })
static enableVibrate(enable: boolean): void { }
/**
* Warning:
* Only applies to Android and Amazon. You can call this from your UI from a button press for example to give your user's options for your notifications.
*
* By default OneSignal plays the system's default notification sound when the device's notification system volume is turned on.
* Passing false means that the device will only vibrate unless the device is set to a total silent mode.
*
* @param {enable} false to disable sound, true to re-enable it.
*/
@Cordova({ sync: true })
static enableSound(enable: boolean): void { }
/**
* Warning:
* Only applies to Android and Amazon devices.
*
* By default this is false and notifications will not be shown when the user is in your app, instead the notificationOpenedCallback is fired.
* If set to true notifications will always show in the notification area and notificationOpenedCallback will not fire until the user taps on the notification.
*
* @param {enable} enable
*/
@Cordova({ sync: true })
static enableNotificationsWhenActive(enable: boolean): void { }
/**
* By default this is false and notifications will not be shown when the user is in your app, instead the notificationOpenedCallback is fired.
* If set to true notifications will be shown as native alert boxes if a notification is received when the user is in your app.
* The notificationOpenedCallback is then fired after the alert box is closed.
*
* @param {enable} enable
*/
@Cordova({ sync: true })
static enableInAppAlertNotification(enable: boolean): void { }
/**
* You can call this method with false to opt users out of receiving all notifications through OneSignal.
* You can pass true later to opt users back into notifications.
*
* @param {enable} enable
*/
@Cordova({ sync: true })
static setSubscription(enable: boolean): void { }
/**
*
* @param {notificationObj} Parameters see POST [documentation](https://documentation.onesignal.com/v2.0/docs/notifications-create-notification)
* @returns {Promise} Returns a Promise that resolves if the notification was send successfully.
*/
@Cordova()
static postNotification(notificationObj: {
app_id: string,
contents: any,
headings?: any,
isIos?: boolean,
isAndroid?: boolean,
isWP?: boolean,
isWP_WNS?: boolean,
isAdm?: boolean,
isChrome?: boolean,
isChromeWeb?: boolean,
isSafari?: boolean,
isAnyWeb?: boolean,
included_segments?: string[],
excluded_segments?: string[],
include_player_ids?: string[],
include_ios_tokens?: string[],
include_android_reg_ids?: string[],
include_wp_uris?: string[],
include_wp_wns_uris?: string[],
include_amazon_reg_ids?: string[],
include_chrome_reg_ids?: string[],
include_chrome_web_reg_ids?: string[],
app_ids?: string[];
tags?: any[],
ios_badgeType?: string,
ios_badgeCount?: number,
ios_sound?: string,
android_sound?: string,
adm_sound?: string,
wp_sound?: string,
wp_wns_sound?: string,
data?: any,
buttons?: any,
small_icon?: string,
large_icon?: string,
big_picture?: string,
adm_small_icon?: string,
adm_large_icon?: string,
adm_big_picture?: string,
chrome_icon?: string,
chrome_big_picture?: string,
chrome_web_icon?: string,
firefox_icon?: string,
url?: string,
send_after?: string,
delayed_option?: string,
delivery_time_of_day?: string,
android_led_color?: string,
android_accent_color?: string,
android_visibility?: number,
content_available?: boolean,
amazon_background_data?: boolean,
template_id?: string,
android_group?: string,
android_group_message?: any,
adm_group?: string,
adm_group_message?: any,
ttl?: number,
priority?: number,
ios_category?: string
}): Promise<any> { return; }
/**
* Prompts the user for location permission to allow geotagging based on the "Location radius" filter on the OneSignal dashboard.
*/
@Cordova({ sync: true })
static promptLocation(): void { }
/**
* Enable logging to help debug if you run into an issue setting up OneSignal.
* The logging levels are as follows: 0 = None, 1= Fatal, 2 = Errors, 3 = Warnings, 4 = Info, 5 = Debug, 6 = Verbose
* The higher the value the more information is shown.
*
* @param {loglevel} contains two properties: logLevel (for console logging) and visualLevel (for dialog messages)
*/
@Cordova({ sync: true })
static setLogLevel(logLevel: {
logLevel: number,
visualLevel: number
}): void { }
* The higher the value the more information is shown.
*
* @param {loglevel} contains two properties: logLevel (for console logging) and visualLevel (for dialog messages)
*/
@Cordova({ sync: true })
static setLogLevel(logLevel: {
logLevel: number,
visualLevel: number
}): void { }
}

View File

@ -0,0 +1,28 @@
import { Plugin, Cordova } from './plugin';
/**
* @name Photo Viewer
* @description This plugin can display your image in full screen with the ability to pan, zoom, and share the image.
* @usage
* ```typescript
* import { PhotoViewer } from 'ionic-native';
*
* PhotoViewer.show('https://mysite.com/path/to/image.jpg');
*
* PhotoViewer.show('https://mysite.com/path/to/image.jpg', 'My image title', {share: false});
* ```
*/
@Plugin({
plugin: 'com-sarriaroman-photoviewer',
pluginRef: 'PhotoViewer',
repo: 'https://github.com/sarriaroman/photoviewer'
})
export class PhotoViewer {
/**
* Shows an image in full screen
* @param url {string} URL or path to image
* @param title {string}
* @param options {any}
*/
@Cordova({sync: true})
static show(url: string, title?: string, options?: {share?: boolean; }): void { }
}

View File

@ -1,18 +1,19 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Pin Dialog
* @description
*
* @usage
* ```typescript
* import {PinDialog} from 'ionic-native';
* 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);
* if (result.buttonIndex == 1) console.log('User clicked OK, value is: ', result.input1);
* else if(result.buttonIndex == 2) console.log('User cancelled');
* }
* );
@ -33,5 +34,6 @@ export class PinDialog {
@Cordova({
successIndex: 1
})
static prompt(message: string, title: string, buttons: string[]): Promise<{buttonIndex: number, input1: string}> {return; }
static prompt(message: string, title: string, buttons: string[]): Promise<{ buttonIndex: number, input1: string }> { return; }
}

View File

@ -1,10 +1,10 @@
import {get} from '../util';
import { get } from '../util';
import { Observable } from 'rxjs/Observable';
declare var window;
declare var Promise;
declare var $q;
import {Observable} from 'rxjs/Observable';
/**
* @private
@ -22,8 +22,11 @@ export const getPlugin = function(pluginRef: string): any {
*/
export const pluginWarn = function(pluginObj: any, method: string) {
let pluginName = pluginObj.name, plugin = pluginObj.plugin;
if (method) console.warn('Native: tried calling ' + pluginName + '.' + method + ', but the ' + pluginName + ' plugin is not installed.');
else console.warn('Native: tried accessing the ' + pluginName + ' plugin but it\'s not installed.');
if (method) {
console.warn('Native: tried calling ' + pluginName + '.' + method + ', but the ' + pluginName + ' plugin is not installed.');
} else {
console.warn('Native: tried accessing the ' + pluginName + ' plugin but it\'s not installed.');
}
console.warn('Install the ' + pluginName + ' plugin: \'ionic plugin add ' + plugin + '\'');
};
@ -33,19 +36,36 @@ export const pluginWarn = function(pluginObj: any, method: string) {
* @param method
*/
export const cordovaWarn = function(pluginName: string, method: string) {
if (method) console.warn('Native: tried calling ' + pluginName + '.' + method + ', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
else console.warn('Native: tried accessing the ' + pluginName + ' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
if (method) {
console.warn('Native: tried calling ' + pluginName + '.' + method + ', but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
} else {
console.warn('Native: tried accessing the ' + pluginName + ' plugin but Cordova is not available. Make sure to include cordova.js or run in a device/simulator');
}
};
function setIndex (args: any[], opts: any= {}, resolve?: Function, reject?: Function): any {
function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Function): any {
// If the plugin method expects myMethod(success, err, options)
if (opts.callbackOrder === 'reverse') {
// Get those arguments in the order [resolve, reject, ...restOfArgs]
args.unshift(reject);
args.unshift(resolve);
} else if (opts.callbackStyle === 'node') {
args.push((err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
} else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') {
// If we've specified a success/error index
args.splice(opts.successIndex, 0, resolve);
args.splice(opts.errorIndex, 0, reject);
// We don't want that the reject cb gets spliced into the position of an optional argument that has not been defined and thus causing non expected behaviour.
if (opts.errorIndex > args.length) {
args[opts.errorIndex] = reject; // insert the reject fn at the correct specific index
} else {
args.splice(opts.errorIndex, 0, reject); // otherwise just splice it into the array
}
} else {
// Otherwise, let's tack them on to the end of the argument list
// which is 90% of cases
@ -55,10 +75,10 @@ function setIndex (args: any[], opts: any= {}, resolve?: Function, reject?: Func
return args;
}
function callCordovaPlugin(pluginObj: any, methodName: string, args: any[], opts: any= {}, resolve?: Function, reject?: Function) {
function callCordovaPlugin(pluginObj: any, methodName: string, args: any[], opts: any = {}, resolve?: Function, reject?: Function) {
// Try to figure out where the success/error callbacks need to be bound
// to our promise resolve/reject handlers.
args = setIndex (args, opts, resolve, reject);
args = setIndex(args, opts, resolve, reject);
let pluginInstance = getPlugin(pluginObj.pluginRef);
@ -82,21 +102,21 @@ function callCordovaPlugin(pluginObj: any, methodName: string, args: any[], opts
}
function getPromise(cb) {
if (window.Promise) {
return new Promise((resolve, reject) => {
cb(resolve, reject);
});
} else if (window.angular) {
if (window.angular) {
let $q = window.angular.injector(['ng']).get('$q');
return $q((resolve, reject) => {
cb(resolve, reject);
});
} else if (window.Promise) {
return new Promise((resolve, reject) => {
cb(resolve, reject);
});
} else {
console.error('No Promise support or polyfill found. To enable Ionic Native support, please add the es6-promise polyfill before this script, or run with a library like Angular 1/2 or on a recent browser.');
}
}
function wrapPromise(pluginObj: any, methodName: string, args: any[], opts: any= {}) {
function wrapPromise(pluginObj: any, methodName: string, args: any[], opts: any = {}) {
let pluginResult, rej;
const p = getPromise((resolve, reject) => {
pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts, resolve, reject);
@ -106,12 +126,22 @@ function wrapPromise(pluginObj: any, methodName: string, args: any[], opts: any=
// a warning that Cordova is undefined or the plugin is uninstalled, so there is no reason
// to error
if (pluginResult && pluginResult.error) {
p.catch(() => {});
p.catch(() => { });
rej(pluginResult.error);
}
return p;
}
function wrapOtherPromise(pluginObj: any, methodName: string, args: any[], opts: any= {}) {
return getPromise((resolve, reject) => {
let pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts);
if (pluginResult && pluginResult.error) {
reject(pluginResult.error);
}
pluginResult.then(resolve).catch(reject);
});
}
function wrapObservable(pluginObj: any, methodName: string, args: any[], opts: any = {}) {
return new Observable(observer => {
let pluginResult = callCordovaPlugin(pluginObj, methodName, args, opts, observer.next.bind(observer), observer.error.bind(observer));
@ -139,7 +169,7 @@ function callInstance(pluginObj: any, methodName: string, args: any[], opts: any
return pluginObj._objectInstance[methodName].apply(pluginObj._objectInstance, args);
}
function wrapInstance (pluginObj: any, methodName: string, 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
@ -159,6 +189,11 @@ function wrapInstance (pluginObj: any, methodName: string, opts: any = {}) {
}
};
});
} else if (opts.otherPromise) {
return getPromise((resolve, reject) => {
let result = callInstance(pluginObj, methodName, args, opts, resolve, reject);
result.then(resolve, reject);
});
} else {
return getPromise((resolve, reject) => {
callInstance(pluginObj, methodName, args, opts, resolve, reject);
@ -172,11 +207,10 @@ function wrapInstance (pluginObj: any, methodName: string, opts: any = {}) {
* @param event
* @returns {Observable}
*/
function wrapEventObservable (event: string): Observable<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);
});
}
@ -187,21 +221,20 @@ function wrapEventObservable (event: string): Observable<any> {
* @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: any = {}) {
return (...args) => {
if (opts.sync)
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)
} else if (opts.observable) {
return wrapObservable(pluginObj, methodName, args, opts);
else if (opts.eventObservable && opts.event)
} else if (opts.eventObservable && opts.event) {
return wrapEventObservable(opts.event);
else
} else if (opts.otherPromise) {
return wrapOtherPromise(pluginObj, methodName, args, opts);
} else {
return wrapPromise(pluginObj, methodName, args, opts);
}
};
};
@ -211,7 +244,7 @@ export const wrap = function(pluginObj: any, methodName: string, opts: any = {}
* Class decorator specifying Plugin metadata. Required for all plugins.
*
* @usage
* ```ts
* ```typescript
* @Plugin({
* name: 'MyPlugin',
* plugin: 'cordova-plugin-myplugin',
@ -289,7 +322,7 @@ export function CordovaProperty(target: Function, key: string, descriptor: Typed
let pluginInstance = getPlugin(pluginObj.pluginRef);
if (!pluginInstance) {
pluginWarn(this, key);
return { };
return {};
}
return originalMethod.apply(this, args);
};

View File

@ -1,64 +1,85 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
declare var cordova: any;
export interface PrintOptions {
/**
* The name of the print job and the document
*/
name?: string;
/**
* The name of the print job and the document
*/
name?: string;
/**
* The network URL of the printer.
* Only supported on iOS.
*/
printerId?: string;
/**
* The network URL of the printer.
* Only supported on iOS.
*/
printerId?: string;
/**
* Specifies the duplex mode to use for the print job.
* Either double-sided (duplex:true) or single-sided (duplex:false).
* Double-sided by default.
* Only supported on iOS
*/
duplex?: boolean;
/**
* Specifies the duplex mode to use for the print job.
* Either double-sided (duplex:true) or single-sided (duplex:false).
* Double-sided by default.
* Only supported on iOS
*/
duplex?: boolean;
/**
* The orientation of the printed content, portrait or landscape
* Portrait by default.
*/
landscape?: boolean;
/**
* The orientation of the printed content, portrait or landscape
* Portrait by default.
*/
landscape?: boolean;
/**
* If your application only prints black text, setting this property to true can result in better performance in many cases.
* False by default.
*/
grayscale?: boolean;
/**
* If your application only prints black text, setting this property to true can result in better performance in many cases.
* False by default.
*/
grayscale?: boolean;
/**
* The Size and position of the print view
*/
bounds?: number[] | any;
/**
* The Size and position of the print view
*/
bounds?: number[] | any;
}
/**
* @name Printer
* @description Prints documents or HTML rendered content
* @usage
* ```typescript
* import {Printer, PrintOptions} from 'ionic-native';
*
* Printer.isAvailable().then(onSuccess, onError);
*
* let options: PrintOptions = {
* name: 'MyDocument',
* printerId: 'printer007',
* duplex: true,
* landscape: true,
* grayscale: true
* };
*
* Printer.print(content, options).then(onSuccess, onError);
* ```
*/
@Plugin({
plugin: 'de.appplant.cordova.plugin.printer',
pluginRef: 'cordova.plugins.printer',
repo: 'https://github.com/katzer/cordova-plugin-printer.git',
platforms: ['Android', 'iOS']
plugin: 'de.appplant.cordova.plugin.printer',
pluginRef: 'cordova.plugins.printer',
repo: 'https://github.com/katzer/cordova-plugin-printer.git',
platforms: ['Android', 'iOS']
})
export class Printer {
/**
* Checks whether to device is capable of printing.
*/
@Cordova()
static isAvailable(): Promise<boolean> { return; }
/**
* Checks whether to device is capable of printing.
*/
@Cordova()
static isAvailable(): Promise<boolean> { return; }
/**
* Sends content to the printer.
* @param {content} The content to print. Can be a URL or an HTML string. If a HTML DOM Object is provided, its innerHtml property value will be used.
* @param {options} The options to pass to the printer
*/
@Cordova()
static print(content: string | HTMLElement, options?: PrintOptions): Promise<any> { return; }
/**
* Sends content to the printer.
* @param {content} The content to print. Can be a URL or an HTML string. If a HTML DOM Object is provided, its innerHtml property value will be used.
* @param {options} The options to pass to the printer
*/
@Cordova()
static print(content: string | HTMLElement, options?: PrintOptions): Promise<any> { return; }
}

View File

@ -1,4 +1,5 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
export type EventResponse = RegistrationEventResponse | NotificationEventResponse | Error;
@ -64,19 +65,19 @@ export interface PushNotification {
* @param event
* @param callback
*/
on(event: "registration", callback: (response: RegistrationEventResponse) => any): void;
on(event: 'registration', callback: (response: RegistrationEventResponse) => any): void;
/**
* The event notification will be triggered each time a push notification is received by a 3rd party push service on the device.
* @param event
* @param callback
*/
on(event: "notification", callback: (response: NotificationEventResponse) => any): void;
on(event: 'notification', callback: (response: NotificationEventResponse) => any): void;
/**
* The event error will trigger when an internal error occurs and the cache is aborted.
* @param event
* @param callback
*/
on(event: "error", callback: (response: Error) => any): void;
on(event: 'error', callback: (response: Error) => any): void;
/**
*
* @param event Name of the event to listen to. See below(above) for all the event names.
@ -86,9 +87,9 @@ export interface PushNotification {
*/
on(event: string, callback: (response: EventResponse) => any): void;
off(event: "registration", callback: (response: RegistrationEventResponse) => any): void;
off(event: "notification", callback: (response: NotificationEventResponse) => any): void;
off(event: "error", callback: (response: Error) => any): void;
off(event: 'registration', callback: (response: RegistrationEventResponse) => any): void;
off(event: 'notification', callback: (response: NotificationEventResponse) => any): void;
off(event: 'error', callback: (response: Error) => any): void;
/**
* As stated in the example, you will have to store your event handler if you are planning to remove it.
* @param event Name of the event type. The possible event names are the same as for the push.on function.
@ -265,7 +266,7 @@ export interface PushOptions {
}
declare var PushNotification: {
new(): PushNotification
new (): PushNotification
};
/**
@ -278,11 +279,8 @@ declare var PushNotification: {
* For TypeScript users, see the [Push plugin docs about using TypeScript for custom notifications](https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/TYPESCRIPT.md).
*
* @usage
* ```js
* import {Push} from 'ionic-native';
*
*
*
* ```typescript
* import { Push } from 'ionic-native';
* ```
*/
@Plugin({
@ -298,10 +296,10 @@ export class Push {
* ```
* var push = Push.init({
* android: {
* senderID: "12345679"
* senderID: '12345679'
* },
* ios: {
* alert: "true",
* alert: 'true',
* badge: true,
* sound: 'false'
* },

View File

@ -1,17 +1,17 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name SafariViewController
* @description
* @usage
* ```
* import {SafariViewController} from 'ionic-native';
* import { SafariViewController } from 'ionic-native';
*
* ...
*
* SafariViewController.isAvailable()
* .then(
* (available) => {
* (available: boolean) => {
* if(available){
*
* SafariViewController.show({
@ -24,9 +24,9 @@ import {Plugin, Cordova} from './plugin';
* })
* .then(
* (result: any) => {
* if(result.event === 'opened') console.log("Opened");
* else if(result.event === 'loaded') console.log("Loaded");
* else if(result.event === 'closed') console.log("Closed");
* if(result.event === 'opened') console.log('Opened');
* else if(result.event === 'loaded') console.log('Loaded');
* else if(result.event === 'closed') console.log('Closed');
* },
* (error: any) => console.error(error)
* );
@ -39,63 +39,60 @@ import {Plugin, Cordova} from './plugin';
* ```
*/
@Plugin({
plugin: 'cordova-plugin-safariviewcontroller',
pluginRef: 'SafariViewController',
platforms: ['iOS'],
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller'
plugin: 'cordova-plugin-safariviewcontroller',
pluginRef: 'SafariViewController',
platforms: ['iOS', 'Android'],
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller'
})
export class SafariViewController {
/**
* Checks if SafariViewController is available
*/
@Cordova()
static isAvailable(): Promise<boolean> {return; }
/**
* Checks if SafariViewController is available
*/
@Cordova()
static isAvailable(): Promise<boolean> { return; }
/**
* Shows Safari View Controller
* @param options
*/
@Cordova({
callbackOrder: 'reverse'
})
static show(options?: SafariViewControllerOptions): Promise<any> {return; }
/**
* Shows Safari View Controller
* @param options
*/
@Cordova()
static show(options?: SafariViewControllerOptions): Promise<any> { return; }
/**
* Hides Safari View Controller
*/
@Cordova({
sync: true
})
static hide(): void {}
/**
* Hides Safari View Controller
*/
@Cordova()
static hide(): void { }
/**
* Tries to connect to the Chrome's custom tabs service. you must call this method before calling any of the other methods listed below.
*/
@Cordova()
static connectToService(): Promise<any> {return; }
/**
* Tries to connect to the Chrome's custom tabs service. you must call this method before calling any of the other methods listed below.
*/
@Cordova()
static connectToService(): Promise<any> { return; }
/**
* Call this method whenever there's a chance the user will open an external url.
*/
@Cordova()
static warmUp(): Promise<any> {return; }
/**
* Call this method whenever there's a chance the user will open an external url.
*/
@Cordova()
static warmUp(): Promise<any> { return; }
/**
* For even better performance optimization, call this methods if there's more than a 50% chance the user will open a certain URL.
* @param url
*/
@Cordova()
static mayLaunchUrl(url: string): Promise<any> { return; }
/**
* For even better performance optimization, call this methods if there's more than a 50% chance the user will open a certain URL.
* @param url
*/
@Cordova()
static mayLaunchUrl(url: string): Promise<any> {return; }
}
export interface SafariViewControllerOptions {
url?: string;
hidden?: boolean;
toolbarColor?: string;
animated?: boolean;
showDefaultShareMenuItem?: boolean;
enterReaderModeIfAvailable?: boolean;
tintColor?: string;
transition?: string;
url?: string;
hidden?: boolean;
toolbarColor?: string;
animated?: boolean;
showDefaultShareMenuItem?: boolean;
enterReaderModeIfAvailable?: boolean;
tintColor?: string;
transition?: string;
}

View File

@ -0,0 +1,68 @@
import { Cordova, CordovaProperty, Plugin } from './plugin';
declare var window;
/**
* @name Screen Orientation
* @description
* Cordova plugin to set/lock the screen orientation in a common way for iOS, Android, WP8 and Blackberry 10.
* This plugin is based on an early version of Screen Orientation API so the api does not currently match the current spec.
*
* Requires Cordova plugin: `cordova-plugin-screen-orientation`. For more info, please see the [Screen Orientation plugin docs](https://github.com/apache/cordova-plugin-screen-orientation).
*
* @usage
* ```typescript
* import { ScreenOrientation } from 'ionic-native';
*
*
* // set to either landscape
* ScreenOrientation.lockOrientation('landscape');
*
* // allow user rotate
* ScreenOrientation.unlockOrientation();
* ```
*
* @advanced
*
* Accepted orientation values:
*
* | Value | Description |
* |-------------------------------|------------------------------------------------------------------------------|
* | portrait-primary | The orientation is in the primary portrait mode. |
* | portrait-secondary | The orientation is in the secondary portrait mode. |
* | landscape-primary | The orientation is in the primary landscape mode. |
* | landscape-secondary | The orientation is in the secondary landscape mode. |
* | portrait | The orientation is either portrait-primary or portrait-secondary (sensor). |
* | landscape | The orientation is either landscape-primary or landscape-secondary (sensor). |
*
*/
@Plugin({
plugin: 'cordova-plugin-screen-orientation',
pluginRef: 'window.screen',
repo: 'https://github.com/apache/cordova-plugin-screen-orientation',
platforms: ['Android', 'iOS', 'Windows Phone 8']
})
export class ScreenOrientation {
/**
* Lock the orientation to the passed value.
* See below for accepted values
* @param {orientation} The orientation which should be locked. Accepted values see table below.
*/
@Cordova({ sync: true })
static lockOrientation(orientation: string): void { }
/**
* Unlock and allow all orientations.
*/
@Cordova({ sync: true })
static unlockOrientation(): void { }
/*
* Get the current orientation of the device.
*/
@CordovaProperty
static get orientation() {
return window.screen.orientation;
}
}

View File

@ -1,60 +1,76 @@
import {Cordova, Plugin} from './plugin';
declare var navigator: any;
@Plugin({
plugin: 'https://github.com/gitawego/cordova-screenshot.git',
pluginRef: 'navigator.screenshot',
repo: 'https://github.com/gitawego/cordova-screenshot.git'
})
export class Screenshot {
/**
* Takes screenshot and saves the image
*
* @param {string} format. Format can take the value of either 'jpg' or 'png'
* On ios, only 'jpg' format is supported
* @param {number} quality. Determines the quality of the screenshot.
* Default quality is set to 100.
* @param {string} filename. Name of the file as stored on the storage
*/
static save (format?: string, quality?: number, filename?: string): Promise<any> {
return new Promise<any>(
(resolve, reject) => {
navigator.screenshot.save(
(error, result) => {
if (error) {
reject(error);
}else {
resolve(result);
}
},
format,
quality,
filename
);
}
);
}
/**
* Takes screenshot and returns the image as an URI
*
* @param {number} quality. Determines the quality of the screenshot.
* Default quality is set to 100.
*/
static URI (quality?: number): Promise<any> {
return new Promise<any>(
(resolve, reject) => {
navigator.screenshot.URI(
(error, result) => {
if (error) {
reject(error);
}else {
resolve(result);
}
},
quality
);
}
);
}
}
import { Plugin } from './plugin';
declare var navigator: any;
/**
* @name Screenshot
* @description Captures a screen shot
* @usage
* ```typescript
* import {Screenshot} from 'ionic-native';
*
* // Take a screenshot and save to file
* Screenshot.save('jpg', 80, 'myscreenshot.jpg').then(onSuccess, onError);
*
* // Take a screenshot and get temporary file URI
* Screenshot.URI(80).then(onSuccess, onError);
* ```
*/
@Plugin({
plugin: 'https://github.com/gitawego/cordova-screenshot.git',
pluginRef: 'navigator.screenshot',
repo: 'https://github.com/gitawego/cordova-screenshot.git'
})
export class Screenshot {
/**
* Takes screenshot and saves the image
*
* @param {string} format. Format can take the value of either 'jpg' or 'png'
* On ios, only 'jpg' format is supported
* @param {number} quality. Determines the quality of the screenshot.
* Default quality is set to 100.
* @param {string} filename. Name of the file as stored on the storage
*/
static save(format?: string, quality?: number, filename?: string): Promise<any> {
return new Promise<any>(
(resolve, reject) => {
navigator.screenshot.save(
(error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
},
format,
quality,
filename
);
}
);
}
/**
* Takes screenshot and returns the image as an URI
*
* @param {number} quality. Determines the quality of the screenshot.
* Default quality is set to 100.
*/
static URI(quality?: number): Promise<any> {
return new Promise<any>(
(resolve, reject) => {
navigator.screenshot.URI(
(error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
},
quality
);
}
);
}
}

View File

@ -0,0 +1,90 @@
import { CordovaInstance, Plugin } from './plugin';
declare var cordova: any;
/**
* @name Secure Storage
* @description
* This plugin gets, sets and removes key,value pairs from a device's secure storage.
*
* Requires Cordova plugin: `cordova-plugin-secure-storage`. For more info, please see the [Cordova Secure Storage docs](https://github.com/Crypho/cordova-plugin-secure-storage).
*
* @usage
*
* ```typescript
* import { SecureStorage } from 'ionic-native';
*
* let secureStorage: SecureStorage = new SecureStorage();
* secureStorage.create('my_store_name')
* .then(
* () => console.log('Storage is ready!'),
* error => console.log(error)
* );
*
* secureStorage.get('myitem')
* .then(
* data => console.log(data),
* error => console.log(error)
* );
*
* secureStorage.set('myitem', 'myvalue')
* .then(
* data => console.log(data),
* error => console.log(error)
* );
*
* secureStorage.remove('myitem')
* .then(
* data => console.log(data),
* error => console.log(error)
* );
* ```
*/
@Plugin({
plugin: 'cordova-plugin-secure-storage',
pluginRef: 'plugins.securestorage',
repo: 'https://github.com/Crypho/cordova-plugin-secure-storage',
platforms: ['Android', 'iOS', 'Windows Phone', 'Browser']
})
export class SecureStorage {
private _objectInstance: any;
constructor() {}
/**
* Creates a namespaced storage.
* @param store {string}
*/
create(store: string): Promise<any> {
return new Promise((res, rej) => {
this._objectInstance = new cordova.plugins.SecureStorage(res, rej, store);
});
}
/**
* Gets a stored item
* @param reference {string}
*/
@CordovaInstance({
callbackOrder: 'reverse'
})
get(reference: string): Promise<any> { return; }
/**
* Stores a value
* @param reference {string}
* @param value {string}
*/
@CordovaInstance({
callbackOrder: 'reverse'
})
set(reference: string, value: string): Promise<any> { return; }
/**
* Removes a single stored item
* @param reference {string}
*/
@CordovaInstance({
callbackOrder: 'reverse'
})
remove(reference: string): Promise<any> { return; }
}

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

@ -0,0 +1,35 @@
import { Plugin, Cordova } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @name Shake
* @description Handles shake gesture
* @usage
* ```typescript
* import {Shake} from 'ionic-native';
*
* let watch = Shake.startWatch(60).subscribe(() => {
* // do something
* });
*
* watch.unsubscribe();
* ```
*/
@Plugin({
plugin: 'cordova-plugin-shake',
pluginRef: 'shake',
repo: 'https://github.com/leecrossley/cordova-plugin-shake'
})
export class Shake {
/**
* Watch for shake gesture
* @param sensitivity {number} Optional sensitivity parameter. Defaults to 40
*/
@Cordova({
observable: true,
clearFunction: 'stopWatch',
successIndex: 0,
errorIndex: 2
})
static startWatch(sensitivity?: number): Observable<any> {return; }
}

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

@ -0,0 +1,36 @@
import { Cordova, Plugin } 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
* ```typescript
* 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

@ -1,4 +1,5 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* Options for sending an SMS
@ -30,14 +31,12 @@ export interface SmsOptionsAndroid {
* Requires Cordova plugin: cordova-plugin-sms. For more info, please see the [SMS plugin docs](https://github.com/cordova-sms/cordova-sms-plugin).
*
* @usage
* ```ts
* import {SMS} from 'ionic-native';
*
* ```typescript
* import { SMS } from 'ionic-native';
*
*
* // Send a text message using default options
* SMS.send('416123456','Hello world!');
*
* SMS.send('416123456', 'Hello world!');
* ```
*/
@Plugin({
@ -60,6 +59,6 @@ export class SMS {
phoneNumber: string | string[],
message: string,
options?: SmsOptions
): Promise<any> { return; }
): Promise<any> { return; }
}

View File

@ -1,35 +1,45 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Social Sharing
* @description
* Share text, files, images, and links via social networks, sms, and email.
* @usage
* ```js
* import {SocialSharing} from 'ionic-native';
* ```typescript
* import { SocialSharing } from 'ionic-native';
*
* ...
* // TODO add usage info
* // Check if sharing via email is supported
* SocialSharing.canShareViaEmail().then(() => {
* // Sharing via email is possible
* }).catch(() => {
* // Sharing via email is not possible
* });
*
* // Share via email
* SocialSharing.shareViaEmail('Body', 'Subject', 'recipient@example.org').then(() => {
* // Success!
* }).catch(() => {
* // Error!
* });
* ```
*/
@Plugin({
plugin: 'cordova-plugin-x-socialsharing',
pluginRef: 'window.plugins.socialsharing',
pluginRef: 'plugins.socialsharing',
repo: 'https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin',
platforms: ['iOS', 'Android', 'Windows Phone']
})
export class SocialSharing {
/**
* Shares using the share sheet
* @param message {string} The message you would like to share.
* @param subject {string} The subject
* @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 file {string|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()
static share (message?: string, subject?: string, file?: string|Array<string>, url?: string): Promise<any> {return; }
static share(message?: string, subject?: string, file?: string|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+)
@ -38,7 +48,7 @@ export class SocialSharing {
@Cordova({
platforms: ['iOS', 'Android']
})
static shareWithOptions (options: { message?: string, subject?: string, file?: string|Array<string>, url?: string, chooserTitle?: string }): Promise<any> {return; }
static shareWithOptions(options: { message?: string, subject?: string, file?: string|string[], url?: string, chooserTitle?: string }): Promise<any> { return; }
/**
* Checks if you can share via a specific app.
@ -47,7 +57,7 @@ export class SocialSharing {
@Cordova({
platforms: ['iOS', 'Android']
})
static canShareVia (appName: string): Promise<any> {return; }
static canShareVia(appName: string): Promise<any> { return; }
/**
* Shares directly to Twitter
@ -58,7 +68,7 @@ export class SocialSharing {
@Cordova({
platforms: ['iOS', 'Android']
})
static shareViaTwitter (message: string, image?: string, url?: string): Promise<any> {return; }
static shareViaTwitter(message: string, image?: string, url?: string): Promise<any> { return; }
/**
* Shares directly to Facebook
@ -69,7 +79,7 @@ export class SocialSharing {
@Cordova({
platforms: ['iOS', 'Android']
})
static shareViaFacebook (message: string, image?: string, url?: string): Promise<any> {return; }
static shareViaFacebook(message: string, image?: string, url?: string): Promise<any> { return; }
/**
@ -82,7 +92,7 @@ export class SocialSharing {
@Cordova({
platforms: ['iOS', 'Android']
})
static shareViaFacebookWithPasteMessageHint (message: string, image?: string, url?: string, pasteMessageHint?: string): Promise<any> {return; }
static shareViaFacebookWithPasteMessageHint(message: string, image?: string, url?: string, pasteMessageHint?: string): Promise<any> { return; }
/**
* Shares directly to Instagram
@ -92,7 +102,7 @@ export class SocialSharing {
@Cordova({
platforms: ['iOS', 'Android']
})
static shareViaInstagram (message: string, image: string): Promise<any> {return; }
static shareViaInstagram(message: string, image: string): Promise<any> { return; }
/**
* Shares directly to WhatsApp
@ -103,7 +113,7 @@ export class SocialSharing {
@Cordova({
platforms: ['iOS', 'Android']
})
static shareViaWhatsApp (message: string, image?: string, url?: string): Promise<any> {return; }
static shareViaWhatsApp(message: string, image?: string, url?: string): Promise<any> { return; }
/**
* Shares directly to a WhatsApp Contact
@ -115,7 +125,7 @@ export class SocialSharing {
@Cordova({
platforms: ['iOS', 'Android']
})
static shareViaWhatsAppToReceiver (receiver: string, message: string, image?: string, url?: string): Promise<any> {return; }
static shareViaWhatsAppToReceiver(receiver: string, message: string, image?: string, url?: string): Promise<any> { return; }
/**
* Share via SMS
@ -125,21 +135,28 @@ export class SocialSharing {
@Cordova({
platforms: ['iOS', 'Android']
})
static shareViaSMS(messge: string, phoneNumber: string): Promise<any> {return; }
static shareViaSMS(messge: string, phoneNumber: string): Promise<any> { return; }
/**
* Checks if you can share via email
*/
@Cordova({
platforms: ['iOS', 'Android']
})
static canShareViaEmail(): Promise<any> { return; }
/**
* Share via Email
* @param message {string}
* @param subject {string}
* @param to {Array<string>}
* @param cc {Array<string>}
* @param bcc {Array<string>}
* @param files {string|Array<string>} URL or local path to file(s) to attach
* @param to {string[]}
* @param cc {string[]}
* @param bcc {string[]}
* @param files {string|string[]} URL or local path to file(s) to attach
*/
@Cordova({
platforms: ['iOS', 'Android']
})
static shareViaEmail(message: string, subject: string, to: Array<string>, cc: Array<string>, bcc: Array<string>, files: string|Array<string>): Promise<any> {return; }
static shareViaEmail(message: string, subject: string, to: string[], cc: string[] = [], bcc: string[] = [], files: string|string[] = []): Promise<any> { return; }
}

View File

@ -1,12 +1,12 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Spinner Dialog
* @description
* @usage
* ```js
* import {SpinnerDialog} from 'ionic-native';
*
* ```typescript
* import { SpinnerDialog } from 'ionic-native';
*
*
* SpinnerDialog.show();
@ -22,7 +22,6 @@ import {Plugin, Cordova} from './plugin';
})
export class SpinnerDialog {
/**
* Shows the spinner dialog
* @param title {string} Spinner title (shows on Android only)

View File

@ -1,12 +1,12 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Splashscreen
* @description This plugin displays and hides a splash screen during application launch. The methods below allows showing and hiding the splashscreen after the app has loaded.
* @usage
* ```ts
* import {Splashscreen} from 'ionic-native';
*
* ```typescript
* import { Splashscreen } from 'ionic-native';
*
*
* Splashscreen.show();
@ -37,4 +37,4 @@ export class Splashscreen {
})
static hide(): void {}
}
}

View File

@ -1,5 +1,8 @@
import {CordovaInstance, Plugin, Cordova} from './plugin';
import { Cordova, CordovaInstance, Plugin } from './plugin';
declare var sqlitePlugin;
/**
* @name SQLite
*
@ -8,21 +11,21 @@ declare var sqlitePlugin;
*
* @usage
*
* ```ts
* ```typescript
* import { SQLite } from 'ionic-native';
*
* let db = new SQLite();
* db.openDatabse({
* db.openDatabase({
* name: 'data.db',
* location: 'default' // the location field is required
* }).then(() => {
* db.executeSql('create table danceMoves(name VARCHAR(32))', {}).then(() => {
*
* }, (err) => {
* console.error('Unable to execute sql', err);
* })
* console.error('Unable to execute sql: ', err);
* });
* }, (err) => {
* console.error('Unable to open database', err);
* console.error('Unable to open database: ', err);
* });
* ```
*
@ -34,142 +37,142 @@ declare var sqlitePlugin;
})
export class SQLite {
private _objectInstance: any;
get databaseFeatures(): any {
return this._objectInstance.databaseFeatures;
}
private _objectInstance: any;
get databaseFeatures(): any {
return this._objectInstance.databaseFeatures;
}
constructor () {}
constructor() { }
/**
* Open or create a SQLite database file.
*
* See the plugin docs for an explanation of all options: https://github.com/litehelpers/Cordova-sqlite-storage#opening-a-database
*
* @param config the config for opening the database.
* @usage
*
* ```ts
* import { SQLite } from 'ionic-native';
*
* let db = new SQLite();
* db.openDatabse({
* name: 'data.db',
* location: 'default' // the location field is required
* }).then(() => {
* db.executeSql('create table danceMoves(name VARCHAR(32))', {}).then(() => {
*
* }, (err) => {
* console.error('Unable to execute sql', err);
* })
* }, (err) => {
* console.error('Unable to open database', err);
* });
* ```
*/
openDatabase (config: any): Promise<any> {
return new Promise((resolve, reject) => {
sqlitePlugin.openDatabase(config, db => {
this._objectInstance = db;
resolve(db);
}, error => {
console.warn(error);
reject(error);
});
/**
* Open or create a SQLite database file.
*
* See the plugin docs for an explanation of all options: https://github.com/litehelpers/Cordova-sqlite-storage#opening-a-database
*
* @param config the config for opening the database.
* @usage
*
* ```typescript
* import { SQLite } from 'ionic-native';
*
* let db = new SQLite();
* db.openDatabase({
* name: 'data.db',
* location: 'default' // the location field is required
* }).then(() => {
* db.executeSql('create table danceMoves(name VARCHAR(32))', {}).then(() => {
*
* }, (err) => {
* console.error('Unable to execute sql', err);
* })
* }, (err) => {
* console.error('Unable to open database', err);
* });
* ```
*/
openDatabase(config: any): Promise<any> {
return new Promise((resolve, reject) => {
sqlitePlugin.openDatabase(config, db => {
this._objectInstance = db;
resolve(db);
}, error => {
console.warn(error);
reject(error);
});
}
});
}
@CordovaInstance({
sync: true
})
addTransaction (transaction: any): void {}
@CordovaInstance({
sync: true
})
addTransaction(transaction: any): void { }
@CordovaInstance()
transaction (fn: any): Promise<any> {return; }
@CordovaInstance()
transaction(fn: any): Promise<any> { return; }
@CordovaInstance()
readTransaction (fn: any): Promise<any> {return; }
@CordovaInstance()
readTransaction(fn: any): Promise<any> { return; }
@CordovaInstance({
sync: true
})
startNextTransaction (): void {}
@CordovaInstance({
sync: true
})
startNextTransaction(): void { }
@CordovaInstance()
close (): Promise<any> {return; }
@CordovaInstance()
close(): Promise<any> { return; }
@CordovaInstance({
sync: true
})
start (): void {}
@CordovaInstance({
sync: true
})
start(): void { }
/**
* Execute SQL on the opened database. Note, you must call `openDatabase` first, and
* ensure it resolved and successfully opened the database.
*
* @usage
*
* ```ts
* db.executeSql('SELECT FROM puppies WHERE type = ?', ['cavalier']).then((resultSet) => {
* // Access the items through resultSet.rows
* // resultSet.rows.item(i)
* }, (err) => {})
* ```
*/
@CordovaInstance()
executeSql (statement: string, params: any): Promise<any> {return; }
/**
* Execute SQL on the opened database. Note, you must call `openDatabase` first, and
* ensure it resolved and successfully opened the database.
*
* @usage
*
* ```typescript
* db.executeSql('SELECT FROM puppies WHERE type = ?', ['cavalier']).then((resultSet) => {
* // Access the items through resultSet.rows
* // resultSet.rows.item(i)
* }, (err) => {})
* ```
*/
@CordovaInstance()
executeSql(statement: string, params: any): Promise<any> { return; }
@CordovaInstance()
addSatement (sql, values): Promise<any> {return; }
@CordovaInstance()
addStatement(sql, values): Promise<any> { return; }
@CordovaInstance()
sqlBatch (sqlStatements: any): Promise<any> {return; }
@CordovaInstance()
sqlBatch(sqlStatements: any): Promise<any> { return; }
@CordovaInstance({
sync: true
})
abortallPendingTransactions (): void {}
@CordovaInstance({
sync: true
})
abortallPendingTransactions(): void { }
@CordovaInstance({
sync: true
})
handleStatementSuccess (handler, response): void {}
@CordovaInstance({
sync: true
})
handleStatementSuccess(handler, response): void { }
@CordovaInstance({
sync: true
})
handleStatementFailure (handler, response): void {}
@CordovaInstance({
sync: true
})
handleStatementFailure(handler, response): void { }
@CordovaInstance({
sync: true
})
run (): void {}
@CordovaInstance({
sync: true
})
run(): void { }
@CordovaInstance({
sync: true
})
abort (txFailure): void {}
@CordovaInstance({
sync: true
})
abort(txFailure): void { }
@CordovaInstance({
sync: true
})
finish (): void {}
@CordovaInstance({
sync: true
})
finish(): void { }
@CordovaInstance({
sync: true
})
abortFromQ (sqlerror): void {}
@CordovaInstance({
sync: true
})
abortFromQ(sqlerror): void { }
@Cordova()
static echoTest (): Promise<any> {return; }
@Cordova()
static echoTest(): Promise<any> { return; }
@Cordova()
static deleteDatabase (first): Promise<any> {return; }
@Cordova()
static deleteDatabase(first): Promise<any> { return; }
}

View File

@ -1,4 +1,5 @@
import {Plugin, Cordova, CordovaProperty} from './plugin';
import { Cordova, CordovaProperty, Plugin } from './plugin';
declare var window;
@ -10,12 +11,11 @@ declare var window;
* Requires Cordova plugin: `cordova-plugin-statusbar`. For more info, please see the [StatusBar plugin docs](https://github.com/apache/cordova-plugin-statusbar).
*
* @usage
* ```ts
* import {StatusBar} from 'ionic-native';
* ```typescript
* import { StatusBar } from 'ionic-native';
*
* ...
*
* StatuBar.overlaysWebView(true); // let status var overlay webview
* StatusBar.overlaysWebView(true); // let status var overlay webview
*
* StatusBar.backgroundColorByHexString('#ffffff'); // set status bar to white
* ```
@ -37,7 +37,7 @@ export class StatusBar {
@Cordova({
sync: true
})
static overlaysWebView(doesOverlay: boolean) {};
static overlaysWebView(doesOverlay: boolean) { };
/**
* Use the default statusbar (dark text, for light backgrounds).
@ -45,7 +45,7 @@ export class StatusBar {
@Cordova({
sync: true
})
static styleDefault() {};
static styleDefault() { };
/**
* Use the lightContent statusbar (light text, for dark backgrounds).
@ -53,7 +53,7 @@ export class StatusBar {
@Cordova({
sync: true
})
static styleLightContent() {};
static styleLightContent() { };
/**
* Use the blackTranslucent statusbar (light text, for dark backgrounds).
@ -61,7 +61,7 @@ export class StatusBar {
@Cordova({
sync: true
})
static styleBlackTranslucent() {};
static styleBlackTranslucent() { };
/**
* Use the blackOpaque statusbar (light text, for dark backgrounds).
@ -69,7 +69,7 @@ export class StatusBar {
@Cordova({
sync: true
})
static styleBlackOpaque() {};
static styleBlackOpaque() { };
/**
* Set the status bar to a specific named color. Valid options:
@ -82,7 +82,7 @@ export class StatusBar {
@Cordova({
sync: true
})
static backgroundColorByName(colorName: string) {};
static backgroundColorByName(colorName: string) { };
/**
* Set the status bar to a specific hex color (CSS shorthand supported!).
@ -94,7 +94,7 @@ export class StatusBar {
@Cordova({
sync: true
})
static backgroundColorByHexString(hexString: string) {};
static backgroundColorByHexString(hexString: string) { };
/**
* Hide the StatusBar
@ -102,7 +102,7 @@ export class StatusBar {
@Cordova({
sync: true
})
static hide() {};
static hide() { };
/**
* Show the StatusBar
@ -110,11 +110,12 @@ export class StatusBar {
@Cordova({
sync: true
})
static show() {};
static show() { };
/**
* Whether the StatusBar is currently visible or not.
*/
@CordovaProperty
static get isVisible() { return window.StatusBar.isVisible; }
}

View File

@ -0,0 +1,47 @@
import { Plugin, Cordova } from './plugin';
export interface TTSOptions {
/** text to speak */
text: string;
/** a string like 'en-US', 'zh-CN', etc */
locale?: string;
/** speed rate, 0 ~ 1 */
rate?: number;
}
/**
* @name TTS
* @description
* Text to Speech plugin
*
* @usage
* ```
* import {TTS} from 'ionic-native';
*
* TTS.speak('Hello World')
* .then(() => console.log('Success'))
* .catch((reason: any) => console.log(reason));
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-tts',
pluginRef: 'TTS',
repo: 'https://github.com/vilic/cordova-plugin-tts'
})
export class TextToSpeech {
/**
* This function speaks
* @param options {string | TTSOptions} Text to speak or TTSOptions
* @return {Promise<any>} Returns a promise that resolves when the speaking finishes
*/
@Cordova({
successIndex: 1,
errorIndex: 2
})
static speak(options: string | TTSOptions): Promise<any> {
return;
}
}

View File

@ -1,5 +1,6 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
import { Cordova, Plugin } from './plugin';
import { Observable } from 'rxjs/Observable';
export interface ToastOptions {
/**
@ -42,12 +43,11 @@ export interface ToastOptions {
* Requires Cordova plugin: `cordova-plugin-x-toast`. For more info, please see the [Toast plugin docs](https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin).
*
* @usage
* ```ts
* import {Toast} from 'ionic-native';
* ```typescript
* import { Toast } from 'ionic-native';
*
*
*
* Toast.show("I'm a toast", "5000", "center").subscribe(
* Toast.show("I'm a toast", '5000', 'center').subscribe(
* toast => {
* console.log(toast);
* }

View File

@ -1,4 +1,5 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name TouchID
@ -7,6 +8,29 @@ import {Plugin, Cordova} from './plugin';
*
* Requires Cordova plugin: `cordova-plugin-touch-id`. For more info, please see the [TouchID plugin docs](https://github.com/EddyVerbruggen/cordova-plugin-touch-id).
*
* @usage
* ### Import Touch ID Plugin into Project
* ```typescript
* import { TouchID } from 'ionic-native';
* ```
* ### Check for Touch ID Availability
* ```typescript
* TouchID.isAvailable()
* .then(
* res => console.log('TouchID is available!'),
* err => console.error('TouchID is not available', err)
* );
* ```
* ### Invoke Touch ID w/ Custom Message
*
* ```typescript
* TouchID.verifyFingerprint('Scan your fingerprint please')
* .then(
* res => console.log('Ok', res),
* err => console.error('Error', err)
* );
* ```
*
* ### Error Codes
*
* The plugin will reject for various reasons. Your app will most likely need to respond to the cases differently.
@ -19,25 +43,6 @@ import {Plugin, Cordova} from './plugin';
* - `-4` - The scan was cancelled by the system (Home button for example)
* - `-6` - TouchID is not Available
* - `-8` - TouchID is locked out from too many tries
* @usage
* ```js
* import {TouchID} from 'ionic-native';
*
* ...
*
* TouchID.isAvailable()
* .then(
* res => console.log("TouchID is available!"),
* err => console.error("TouchID isn't available", err)
* );
*
* TouchID.verifyFingerprint('Scan your fingerprint please')
* .then(
* res => console.log("Ok", res),
* err => console.error("Error", err)
* );
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-touch-id',
@ -48,7 +53,7 @@ import {Plugin, Cordova} from './plugin';
export class TouchID {
/**
* Whether TouchID is available or not.
* Checks Whether TouchID is available or not.
*
* @return {Promise} Returns a Promise that resolves if yes, rejects if no.
*/
@ -82,4 +87,5 @@ export class TouchID {
*/
@Cordova()
static verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel(message: string, enterPasswordLabel: string): Promise<any> { return; }
}

View File

@ -0,0 +1,73 @@
import { Plugin, Cordova } from './plugin';
/**
* @name Twitter Connect
* @description
* Plugin to use Twitter Single Sign On
* Uses Twitter's Fabric SDK
* ```typescript
* import {TwitterConnect} from 'ionic-native';
*
* function onSuccess(response) {
* console.log(response);
*
* // Will console log something like:
* // {
* // userName: 'myuser',
* // userId: '12358102',
* // secret: 'tokenSecret'
* // token: 'accessTokenHere'
* // }
* }
*
* TwitterConnect.login().then(onSuccess, onError);
*
* TwitterConnect.logout().then(onLogoutSuccess, onLogoutError);
* ```
*/
@Plugin({
plugin: 'twitter-connect-plugin',
pluginRef: 'TwitterConnect',
repo: 'https://github.com/ManifestWebDesign/twitter-connect-plugin',
install: 'ionic plugin add twitter-connect-plugin --variable FABRIC_KEY=fabric_API_key'
})
export class TwitterConnect {
/**
* Logs in
* @return {Promise<TwitterConnectResponse>} returns a promise that resolves if logged in and rejects if failed to login
*/
@Cordova()
static login(): Promise<TwitterConnectResponse> {return; }
/**
* Logs out
* @return {Promise<any>} returns a promise that resolves if logged out and rejects if failed to logout
*/
@Cordova()
static logout(): Promise<any> {return; }
/**
* Returns user's profile information
* @return {Promise<any>} returns a promise that resolves if user profile is successfully retrieved and rejects if request fails
*/
@Cordova()
static showUser(): Promise<any> {return; }
}
export interface TwitterConnectResponse {
/**
* Twitter Username
*/
userName: string;
/**
* Twitter User ID
*/
userId: string;
/**
* Twitter OAuth Secret
*/
secret: string;
/**
* Twitter OAuth Token
*/
token: string;
}

View File

@ -1,14 +1,16 @@
import {Plugin, Cordova} from './plugin';
import { Cordova, Plugin } from './plugin';
/**
* @name Vibration
* @description Vibrates the device
* @usage
* ```ts
* import {Vibration} from 'ionic-native';
*
* ```typescript
* import { Vibration } from 'ionic-native';
*
*
* // Vibrate the device for a second
* // Duration is ignored on iOS.
* Vibration.vibrate(1000);
*
* // Vibrate 2 seconds
@ -37,6 +39,6 @@ export class Vibration {
@Cordova({
sync: true
})
static vibrate(time: number|Array<number>) {}
static vibrate(time: number | Array<number>) { }
}
}

200
src/plugins/video-editor.ts Normal file
View File

@ -0,0 +1,200 @@
import {Plugin, Cordova} from './plugin';
export interface TranscodeOptions {
/** The path to the video on the device. */
fileUri: string;
/** The file name for the transcoded video */
outputFileName: string;
/** Instructions on how to encode the video. Android is always mp4 */
outputFileType?: number;
/** Should the video be processed with quailty or speed in mind. iOS only */
optimizeForNetworkUse?: number;
/** Save the new video the library. Not supported in windows. Defaults to true */
saveToLibrary?: boolean;
/** Delete the original video. Android only. Defaults to false */
deleteInputFile?: boolean;
/** iOS only. Defaults to true */
maintainAspectRatio?: boolean;
/** Width of the result */
width?: number;
/** Height of the result */
height?: number;
/** Bitrate in bits. Defaults to 1 megabit (1000000). */
videoBitrate?: number;
/** Frames per second of the result. Android only. Defaults to 24. */
fps?: number;
/** Number of audio channels. iOS only. Defaults to 2. */
audioChannels?: number;
/** Sample rate for the audio. iOS only. Defaults to 44100*/
audioSampleRate?: number;
/** Sample rate for the audio. iOS only. Defaults to 128 kilobits (128000). */
audioBitrate?: number;
/** Not supported in windows, progress on the transcode. info will be a number from 0 to 100 */
progress?: (info: number) => void;
}
export interface TrimOptions {
/** Path to input video. */
fileUri: string;
/** Time to start trimming in seconds */
trimStart: number;
/** Time to end trimming in seconds */
trimEnd: number;
/** Output file name */
outputFileName: string;
/** Progress on transcode. info will be a number from 0 to 100 */
progress?: (info: any) => void;
}
export interface CreateThumbnailOptions {
/** The path to the video on the device */
fileUri: string;
/** The file name for the JPEG image */
outputFileName: string;
/** Location in the video to create the thumbnail (in seconds) */
atTime?: number;
/** Width of the thumbnail. */
width?: number;
/** Height of the thumbnail. */
height?: number;
/** Quality of the thumbnail (between 1 and 100). */
quality?: number;
}
export interface GetVideoInfoOptions {
/** The path to the video on the device. */
fileUri: string;
}
export interface VideoInfo {
/** Width of the video in pixels. */
width: number;
/** Height of the video in pixels. */
height: number;
/** Orientation of the video. Will be either portrait or landscape. */
orientation: 'portrait' | 'landscape';
/** Duration of the video in seconds. */
duration: number;
/** Size of the video in bytes. */
size: number;
/** Bitrate of the video in bits per second. */
bitrate: number;
}
/**
* @name VideoEditor
* @description Edit videos using native device APIs
*
* @usage
* ```
* import {VideoEditor} from 'ionic-native';
*
* VideoEditor.transcodeVideo({
* fileUri: '/path/to/input.mov',
* outputFileName: 'output.mp4',
* outputFileType: VideoEditor.OutputFileType.MPEG4
* })
* .then((fileUri: string) => console.log('video transcode success', fileUri))
* .catch((error: any) => console.log('video transcode error', error));
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-video-editor',
pluginRef: 'VideoEditor',
repo: 'https://github.com/jbavari/cordova-plugin-video-editor',
platforms: ['Android', 'iOS', 'Windows Phone 8']
})
export class VideoEditor {
static OptimizeForNetworkUse = {
NO: 0,
YES: 1
};
static OutputFileType = {
M4V: 0,
MPEG4: 1,
M4A: 2,
QUICK_TIME: 3
};
/**
* Transcode a video
* @param options {TranscodeOptions} Options
* @return {Promise<string>} Returns a promise that resolves to the path of the transcoded video
*/
@Cordova({
callbackOrder: 'reverse'
})
static transcodeVideo(options: TranscodeOptions): Promise<string> { return; }
/**
* Trim a video
* @param options {TrimOptions} Options
* @return {Promise<string>} Returns a promise that resolves to the path of the trimmed video
*/
@Cordova({
callbackOrder: 'reverse',
platforms: ['iOS']
})
static trim(options: TrimOptions): Promise<string> { return; }
/**
* Create a JPEG thumbnail from a video
* @param options {CreateThumbnailOptions} Options
* @return {Promise<string>} Returns a promise that resolves to the path to the jpeg image on the device
*/
@Cordova({
callbackOrder: 'reverse'
})
static createThumbnail(options: CreateThumbnailOptions): Promise<string> { return; }
/**
* Get info on a video (width, height, orientation, duration, size, & bitrate)
* @param options {GetVideoInfoOptions} Options
* @return {Promise<VideoInfo>} Returns a promise that resolves to an object containing info on the video
*/
@Cordova({
callbackOrder: 'reverse'
})
static getVideoInfo(options: GetVideoInfoOptions): Promise<VideoInfo> { return; }
}

View File

@ -0,0 +1,62 @@
import { Cordova, Plugin } from './plugin';
/**
* Options for the video playback using the `play` function.
*/
export interface VideoOptions {
/**
* Set the initial volume of the video playback, where 0.0 is 0% volume and 1.0 is 100%.
* For example: for a volume of 30% set the value to 0.3.
*/
volume?: number;
/**
* There are to options for the scaling mode. SCALE_TO_FIT which is default and SCALE_TO_FIT_WITH_CROPPING.
* These strings are the only ones which can be passed as option.
*/
scalingMode?: string;
}
/**
* @name VideoPlayer
* @description
* A Codova plugin that simply allows you to immediately play a video in fullscreen mode.
*
* Requires Cordova plugin: `com.moust.cordova.videoplayer`. For more info, please see the [VideoPlayer plugin docs](https://github.com/moust/cordova-plugin-videoplayer).
*
* @usage
* ```typescript
* import { VideoPlayer } from 'ionic-native';
*
*
* // Playing a video.
* VideoPlayer.play("file:///android_asset/www/movie.mp4").then(() => {
* console.log('video completed');
* }).catch(err => {
* console.log(err);
* });
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-videoplayer',
pluginRef: 'VideoPlayer',
repo: 'https://github.com/moust/cordova-plugin-videoplayer',
platforms: ['Android']
})
export class VideoPlayer {
/**
* Plays the video from the passed url.
* @param fileUrl {string} File url to the video.
* @param options {VideoOptions?} Optional video playback settings. See options above.
* @returns {Promise<any>} Resolves promise when the video was played successfully.
*/
@Cordova()
static play(fileUrl: string, options?: VideoOptions): Promise<any> { return; }
/**
* Stops the video playback immediatly.
*/
@Cordova({ sync: true })
static close(): void { }
}

View File

@ -1,10 +1,20 @@
import {Cordova, CordovaProperty, Plugin} from './plugin';
import { Cordova, CordovaProperty, Plugin } from './plugin';
declare var window;
/**
* @name WebIntent
* @description
* @usage
* For usage information please refer to the plugin's Github repo.
*
* ```typescript
* import {WebIntent} from 'ionic-native';
*
* WebIntent.startActivity(options).then(onSuccess, onError);
*
* ```
*/
@Plugin({
plugin: 'https://github.com/Initsogar/cordova-webintent.git',
@ -15,31 +25,31 @@ declare var window;
export class WebIntent {
@CordovaProperty
static get ACTION_VIEW () {
static get ACTION_VIEW() {
return window.plugins.webintent.ACTION_VIEW;
}
@CordovaProperty
static get EXTRA_TEXT () {
static get EXTRA_TEXT() {
return window.plugins.webintent.EXTRA_TEXT;
}
@Cordova()
static startActivity (options: {action: any, url: string}): Promise<any> {return; }
static startActivity(options: { action: any, url: string }): Promise<any> { return; }
@Cordova()
static hasExtra (extra: any): Promise<any> {return; }
static hasExtra(extra: any): Promise<any> { return; }
@Cordova()
static getExtra (extra: any): Promise<any> {return; }
static getExtra(extra: any): Promise<any> { return; }
@Cordova()
static getUri (): Promise<string> {return; };
static getUri(): Promise<string> { return; };
@Cordova()
static onNewIntent(): Promise<string> {return; };
static onNewIntent(): Promise<string> { return; };
@Cordova()
static sendBroadcast(options: {action: string, extras?: {option: boolean}}): Promise<any> {return; }
static sendBroadcast(options: { action: string, extras?: { option: boolean } }): Promise<any> { return; }
}

39
src/plugins/zip.ts Normal file
View File

@ -0,0 +1,39 @@
import { Plugin, Cordova } from './plugin';
/**
* @name Zip
* @description
* A Cordova plugin to unzip files in Android and iOS.
*
* @usage
* ```
* import {Zip} from 'ionic-native';
*
* Zip.unzip('path/to/source.zip', 'path/to/dest', (progress) => console.log('Unzipping, ' + Math.round((progress.loaded / progress.total) * 100) + '%'))
* .then((result) => {
* if(result === 0) console.log('SUCCESS');
* if(result === -1) console.log('FAILED');
* });
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-zip',
pluginRef: 'zip',
repo: 'https://github.com/MobileChromeApps/cordova-plugin-zip',
})
export class Zip {
/**
* Extracts files from a ZIP archive
* @param sourceZip {string} Source ZIP file
* @param destUrl {string} Destination folder
* @param onProgress {Function} optional callback to be called on progress update
* @return {Promise<number>} returns a promise that resolves with a number. 0 is success, -1 is error
*/
@Cordova({
successIndex: 2,
errorIndex: 4
})
static unzip(sourceZip: string, destUrl: string, onProgress: Function): Promise<number> {return; }
}

View File

@ -1,62 +1,3 @@
{
"rulesDirectory": "node_modules/tslint-eslint-rules/dist/rules",
"rules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
],
"no-duplicate-variable": true,
"no-eval": true,
"no-internal-module": true,
"no-trailing-whitespace": true,
"no-var-keyword": false,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"quotemark": [
true,
"single"
],
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": [
true,
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"no-inner-declarations": [
true,
"functions"
]
}
}
"extends": "tslint-ionic-rules"
}