Merge remote-tracking branch 'origin/master' into new-contacts

This commit is contained in:
Ibrahim Hadeed 2016-06-09 22:24:42 -04:00
commit 2c643de7cb
48 changed files with 2727 additions and 201 deletions

View File

@ -92,6 +92,10 @@ The `@Cordova` decorator has a few more options now.
`clearFunction` is used in conjunction with the `observable` option and indicates the function to be called when the Observable is disposed.
### Testing your changes
You need to run `npm run build_bundle` in the `ionic-native` project, this will create a `dist` directory. Then, you must go to your ionic application folder and replace your current `node_modules/ionic-native/dist/` with the newly generated one.
### 'Wrapping' Up
That's it! The only thing left to do is rigorously document the plugin and it's usage. Take a look at some of the other plugins for good documentation styles.

View File

@ -8,6 +8,10 @@
Ionic Native is a curated set of wrappers for Cordova plugins that make adding any native functionality you need to your [Ionic](http://ionicframework.com/), Cordova, or Web View mobile app easy.
### Documentation
For the full Ionic Native documentation, please visit [http://ionicframework.com/docs/v2/native/](http://ionicframework.com/docs/v2/native/).
### Promises and Observables
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.

View File

@ -9,19 +9,19 @@ general:
only:
- master # ignore PRs and branches
#dependencies:
# pre:
# - ./scripts/docs/prepare.sh
# cache_directories:
# - "~/ionic-site" # cache ionic-site
dependencies:
pre:
- ./scripts/docs/prepare.sh
cache_directories:
- "~/ionic-site" # cache ionic-site
test:
override:
- echo "No tests are written at the moment. But we will attempt to build the library with the latest changes."
- npm run build_bundle
#deployment:
# staging:
# branch: master
# commands:
# - ./scripts/docs/update_docs.sh
deployment:
staging:
branch: master
commands:
- ./scripts/docs/update_docs.sh

View File

@ -1,6 +1,6 @@
{
"name": "ionic-native",
"version": "1.2.0",
"version": "1.2.4",
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
"main": "dist/index.js",
"directories": {
@ -10,7 +10,7 @@
"dist"
],
"dependencies": {
"rxjs": "5.0.0-beta.2"
"rxjs": "^5.0.0-beta.6"
},
"devDependencies": {
"browserify": "^13.0.0",
@ -33,7 +33,7 @@
"semver": "^5.0.1",
"tslint": "^3.8.1",
"tslint-eslint-rules": "^1.3.0",
"typescript": "^1.7.5"
"typescript": "^1.8.10"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",

View File

@ -18,7 +18,7 @@ function run {
if [ ! -d "$SITE_DIR" ]; then
echo "checking out"
cd ./scripts
./git/clone.sh --repository="driftyco/ionic-site" \
./git/clone.sh --repository="ionic-site" \
--directory="$SITE_DIR" \
--branch="master"
ls -al $SITE_DIR

View File

@ -17,8 +17,9 @@ module.exports = function jekyll(renderDocsProcessor) {
return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
});
docs.forEach(function(doc, i) {
docs[i].URL = doc.outputPath.replace('docs/v2//','docs/v2/')
.replace('/index.md','');
doc.outputPath = doc.outputPath.toLowerCase().replace(' ', '-');
docs[i].URL = doc.outputPath.replace('docs/v2//', 'docs/v2/')
.replace('/index.md', '');
});
docs.push({

View File

@ -104,7 +104,7 @@ docType: "<$ doc.docType $>"
</h1>
<a class="improve-v2-docs" href='http://github.com/driftyco/ionic-native/edit/master/<$ doc.fileInfo.relativePath $>#L<$ doc.location.start.line $>'>
<a class="improve-v2-docs" href="http://github.com/driftyco/ionic-native/edit/master/<$ doc.fileInfo.relativePath|replace('/home/ubuntu/ionic', '')|replace('//','/') $>#L<$ doc.location.start.line $>">
Improve this doc
</a>

View File

@ -34,6 +34,11 @@ function run {
git config --global user.name "Ionitron"
git add -A
git commit -am "Automated build of native docs driftyco/$CIRCLE_PROJECT_REPONAME@$CIRCLE_SHA1"
# in case a different commit was pushed to ionic-site during doc/demo gen,
# try to rebase around it before pushing
git fetch
git rebase
git push origin master
echo "-- Updated docs for $VERSION_NAME succesfully!"

View File

@ -17,7 +17,11 @@ function run {
if [[ "$DEPTH" != "" ]]; then
ARGS="$ARGS --depth=$DEPTH"
fi
git clone https://driftyco:$GH_TOKEN@github.com/$REPOSITORY $DIRECTORY $ARGS
git config --global user.email "hi@ionicframework.com"
git config --global user.name "Ionitron"
git clone git@github.com:driftyco/$REPOSITORY.git $DIRECTORY $ARGS
cd $DIRECTORY
git fetch origin --tags
cd ../

View File

@ -1,5 +1,4 @@
import {initAngular1} from './ng1';
initAngular1();
const DEVICE_READY_TIMEOUT = 2000;
@ -11,6 +10,8 @@ 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';
@ -18,10 +19,12 @@ 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';
@ -31,20 +34,24 @@ 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 {GoogleMaps} from './plugins/googlemaps';
import {GooglePlus} from './plugins/google-plus';
import {GoogleMap} from './plugins/googlemaps';
import {GoogleAnalytics} from './plugins/googleanalytics';
import {Hotspot} from './plugins/hotspot';
import {ImagePicker} from './plugins/imagepicker';
import {InAppBrowser} from './plugins/inappbrowser';
import {Insomnia} from './plugins/insomnia';
import {Keyboard} from './plugins/keyboard';
import {LaunchNavigator} from './plugins/launchnavigator';
import {LocalNotifications} from './plugins/localnotifications';
import {MediaPlugin} from './plugins/media';
import {Network, Connection} from './plugins/network';
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';
@ -52,11 +59,13 @@ 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';
export * from './plugins/googlemaps';
export * from './plugins/3dtouch';
export {
ActionSheet,
AdMob,
@ -64,6 +73,8 @@ export {
AppRate,
AppVersion,
Badge,
BackgroundGeolocation,
BackgroundMode,
BarcodeScanner,
Base64ToGallery,
BatteryStatus,
@ -71,11 +82,13 @@ export {
BluetoothSerial,
Calendar,
Camera,
CardIO,
Clipboard,
Connection,
Contacts,
DatePicker,
DBMeter,
Deeplinks,
Device,
DeviceAccounts,
DeviceMotion,
@ -88,26 +101,29 @@ export {
Flashlight,
Geolocation,
Globalization,
GoogleMaps,
GooglePlus,
GoogleAnalytics,
Hotspot,
ImagePicker,
InAppBrowser,
Insomnia,
Keyboard,
LaunchNavigator,
LocalNotifications,
MediaPlugin,
Network,
Push,
SafariViewController,
Screenshot,
SMS,
SocialSharing,
SpinnerDialog,
Splashscreen,
SQLite,
SQLite,
StatusBar,
Toast,
TouchID,
Transfer,
Vibration,
WebIntent
}
@ -122,6 +138,7 @@ window['IonicNative'] = {
AppRate: AppRate,
AppVersion: AppVersion,
Badge: Badge,
BackgroundGeolocation: BackgroundGeolocation,
BarcodeScanner: BarcodeScanner,
Base64ToGallery: Base64ToGallery,
BatteryStatus: BatteryStatus,
@ -129,11 +146,13 @@ window['IonicNative'] = {
BluetoothSerial: BluetoothSerial,
Calendar: Calendar,
Camera: Camera,
CardIO: CardIO,
Clipboard: Clipboard,
Connection: Connection,
Contacts: Contacts,
DatePicker: DatePicker,
DBMeter: DBMeter,
Deeplinks: Deeplinks,
Device: Device,
DeviceAccounts: DeviceAccounts,
DeviceMotion: DeviceMotion,
@ -146,7 +165,8 @@ window['IonicNative'] = {
Flashlight: Flashlight,
Geolocation: Geolocation,
Globalization: Globalization,
GoogleMaps : GoogleMaps,
GooglePlus: GooglePlus,
GoogleMap : GoogleMap,
GoogleAnalytics: GoogleAnalytics,
Hotspot: Hotspot,
ImagePicker: ImagePicker,
@ -157,19 +177,24 @@ window['IonicNative'] = {
MediaPlugin: MediaPlugin,
Network: Network,
Push: Push,
SafariViewController: SafariViewController,
Screenshot: Screenshot,
SMS: SMS,
SocialSharing: SocialSharing,
SpinnerDialog: SpinnerDialog,
Splashscreen: Splashscreen,
SQLite: SQLite,
SQLite: SQLite,
StatusBar: StatusBar,
ThreeDeeTouch: ThreeDeeTouch,
Toast: Toast,
TouchID: TouchID,
Transfer: Transfer,
Vibration: Vibration,
WebIntent: WebIntent
};
initAngular1(window['IonicNative']);
// To help developers using cordova, we listen for the device ready event and
// log an error if it didn't fire in a reasonable amount of time. Generally,
// when this happens, developers should remove and reinstall plugins, since

View File

@ -1,24 +1,28 @@
declare var window;
/**
* Initialize the ngCordova Angular module if we're running in ng1
* 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.
*/
export function initAngular1() {
export function initAngular1(plugins) {
if (window.angular) {
window.angular.module('ngCordova', []);
}
}
window.angular.module('ionic.native', []);
/**
* Publish a new Angular 1 service for this plugin.
*/
export function publishAngular1Service(config: any, cls: any) {
let serviceName = '$cordova' + cls.name;
console.log('Registering Angular1 service', serviceName);
window.angular.module('ngCordova').service(serviceName, [function() {
let funcs = {};
for (var k in cls) {
for (var name in plugins) {
let serviceName = '$cordova' + name;
let cls = plugins[name];
(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;
return funcs;
}]);
})(serviceName, cls, name);
}
return funcs;
}]);
}
}
}

117
src/plugins/3dtouch.ts Normal file
View File

@ -0,0 +1,117 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
/**
* @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, ThreeDeeTouchQuickAction, ThreeDeeTouchForceTouch} from 'ionic-native';
*
* ...
*
* ThreeDeeTouch.isAvailable().then(isAvailable => console.log("3D Touch available? " + isAvailable)):
*
* ThreeDeeTouch.watchForceTouches()
* .subscribe(
* (data: ThreeDeeTouchForceTouch) => {
* console.log("Force touch %" + data.force);
* console.log("Force touch timestamp: " + data.timestamp);
* console.log("Force touch x: " + data.x);
* console.log("Force touch y: " + data.y);
* }
* );
*
*
* let actions: Array<ThreeDeeTouchQuickAction> = [
* {
* type: 'checkin',
* title: 'Check in',
* subtitle: 'Quickly check in',
* iconType: 'Compose'
* },
* {
* type: 'share',
* title: 'Share',
* subtitle: 'Share like you care',
* iconType: 'Share'
* },
* {
* type: 'search',
* title: 'Search',
* iconType: 'Search'
* },
* {
* title: 'Show favorites',
* iconTemplate: 'HeartTemplate'
* }
* ];
* ThreeDeeTouch.configureQuickActions(actions);
* ```
*/
@Plugin({
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 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; }
@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
*/
@Cordova({
observable: true
})
static onHomeIconPressed(): Observable<any> {return; }
/**
* 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 {}
}
export interface ThreeDeeTouchQuickAction {
type?: string;
title: string;
subtitle?: string;
iconType?: string;
}
export interface ThreeDeeTouchForceTouch {
force: number;
timestamp: number;
x: number;
y: number;
}

View File

@ -174,4 +174,4 @@ export class AdMob {
})
static onInterstitialDismiss (): Observable<any> {return; }
}
}

View File

@ -32,19 +32,21 @@ export class AppRate {
/**
* Rating dialog preferences
*
* useLanguage {String} null - custom BCP 47 language tag
* displayAppName {String} '' - custom application title
* promptAgainForEachNewVersion {Boolean} true - show dialog again when application version will be updated
* usesUntilPrompt {Integer} 3 - count of runs of application before dialog will be displayed
* openStoreInApp {Boolean} false - leave app or no when application page opened in app store (now supported only for iOS)
* useCustomRateDialog {Boolean} false - use custom view for rate dialog
* callbacks.onButtonClicked {Function} null - call back function. called when user clicked on rate-dialog buttons
* callbacks.onRateDialogShow {Function} null - call back function. called when rate-dialog showing
* storeAppURL.ios {String} null - application id in AppStore
* storeAppURL.android {String} null - application URL in GooglePlay
* storeAppURL.blackberry {String} null - application URL in AppWorld
* storeAppURL.windows8 {String} null - application URL in WindowsStore
* customLocale {Object} null - custom locale object
* | Option | Type | Default | Description |
* |------------------------------|------------|---------|----------------------------------------------------------------------------------------|
* | useLanguage | `String` | null | custom BCP 47 language tag |
* | displayAppName | `String` | '' | custom application title |
* | promptAgainForEachNewVersion | `Boolean` | true | show dialog again when application version will be updated |
* | usesUntilPrompt | `Integer` | 3 | count of runs of application before dialog will be displayed |
* | openStoreInApp | `Boolean` | false | leave app or no when application page opened in app store (now supported only for iOS) |
* | useCustomRateDialog | `Boolean` | false | use custom view for rate dialog |
* | callbacks.onButtonClicked | `Function` | null | call back function. called when user clicked on rate-dialog buttons |
* | callbacks.onRateDialogShow | `Function` | null | call back function. called when rate-dialog showing |
* | storeAppURL.ios | `String` | null | application id in AppStore |
* | storeAppURL.android | `String` | null | application URL in GooglePlay |
* | storeAppURL.blackberry | `String` | null | application URL in AppWorld |
* | storeAppURL.windows8 | `String` | null | application URL in WindowsStore |
* | customLocale | `Object` | null | custom locale object |
* @type {{}}
*/
@CordovaProperty

View File

@ -0,0 +1,336 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
declare var window;
export interface Location {
/**
* ID of location as stored in DB (or null)
*/
locationId: number;
/**
* Service provider
*/
serviceProvider: string;
/**
* true if location recorded as part of debug
*/
debug: boolean;
/**
* UTC time of this fix, in milliseconds since January 1, 1970.
*/
time: number;
/**
* latitude, in degrees.
*/
latitude: number;
/**
* longitude, in degrees.
*/
longitude: number;
/**
* estimated accuracy of this location, in meters.
*/
accuracy: number;
/**
* speed if it is available, in meters/second over ground.
*/
speed: number;
/**
* altitude if available, in meters above the WGS 84 reference ellipsoid.
*/
altitude: number;
/**
* bearing, in degrees.
*/
bearing: number;
/**
* A Coordinates object defining the current location
*/
coords: Coordinates;
/**
* A timestamp representing the time at which the location was retrieved.
*/
timestamp: number;
}
export interface Config {
/**
* Desired accuracy in meters. Possible values [0, 10, 100, 1000]. The lower
* the number, the more power devoted to GeoLocation resulting in higher
* accuracy readings. 1000 results in lowest power drain and least accurate
* readings. @see Apple docs (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instp/CLLocationManager/desiredAccuracy)
*/
desiredAccuracy: number;
/**
* Stationary radius in meters. When stopped, the minimum distance the device
* must move beyond the stationary location for aggressive background-tracking
* to engage.
*/
stationaryRadius: number;
/**
* When enabled, the plugin will emit sounds for life-cycle events of
* background-geolocation! See debugging sounds table.
*/
debug: boolean;
/**
* The minimum distance (measured in meters) a device must move horizontally
* before an update event is generated. @see Apple docs. (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instp/CLLocationManager/distanceFilter)
*/
distanceFilter: number;
/**
* IOS, ANDROID ONLY
* Enable this in order to force a stop() when the application terminated
* (e.g. on iOS, double-tap home button, swipe away the app).
*/
stopOnTerminate?: boolean;
/**
* ANDROID, WP8 ONLY
* The minimum time interval between location updates in seconds.
* @see Android docs (http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(long,%20float,%20android.location.Criteria,%20android.app.PendingIntent))
* and the MS doc (http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.geolocation.geolocator.reportinterval)
* for more information
*/
locationTimeout?: number;
/**
* ANDROID ONLY
* Custom notification title in the drawer.
*/
notificationTitle?: string;
/**
* ANDROID ONLY
* Custom notification text in the drawer.
*/
notificationText?: string;
/**
* ANDROID ONLY
* The accent color to use for notification. Eg. #4CAF50.
*/
notificationIconColor?: string;
/**
* ANDROID ONLY
* The filename of a custom notification icon. See android quirks.
* NOTE: Only available for API Level >=21.
*/
notificationIcon?: string;
/**
* ANDROID ONLY
* Set location service provider @see wiki (https://github.com/mauron85/cordova-plugin-background-geolocation/wiki/Android-providers)
*/
locationService?: number;
/**
* IOS ONLY
* [AutomotiveNavigation, OtherNavigation, Fitness, Other] Presumably,
* this affects iOS GPS algorithm. @see Apple docs for more information
* (https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instp/CLLocationManager/activityType)
*/
activityType?: string;
}
/**
* @name BackgroundGeolocation
* @description
* This plugin provides foreground and background geolocation with battery-saving "circular region monitoring" and "stop detection". For
* more detail, please see https://github.com/mauron85/cordova-plugin-background-geolocation
*
* @usage
*
* ```ts
* import {BackgroundGeolocation} from 'ionic-native';
*
*
*
* // When device is ready :
* platform.ready().then(() => {
*
* // BackgroundGeolocation is highly configurable. See platform specific configuration options
* let config = {
* desiredAccuracy: 10,
* stationaryRadius: 20,
* distanceFilter: 30,
* debug: true, // enable this hear sounds for background-geolocation life-cycle.
* stopOnTerminate: false, // enable this to clear background location settings when the app terminates
* };
*
* 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');
* });
*
* // Turn ON the background-geolocation system. The user will be tracked whenever they suspend the app.
* BackgroundGeolocation.start();
* }
*
* // If you wish to turn OFF background-tracking, call the #stop method.
* BackgroundGeolocation.stop();
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-mauron85-background-geolocation',
pluginRef: 'plugins.backgroundGeoLocation', // ????? see line 213 at https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/www/backgroundGeoLocation.js
repo: 'https://github.com/mauron85/cordova-plugin-background-geolocation'
})
export class BackgroundGeolocation {
/**
* Configure the plugin.
* Success callback will be called with one argument - Location object, which tries to mimic w3c Coordinates interface.
* See http://dev.w3.org/geo/api/spec-source.html#coordinates_interface
* Callback to be executed every time a geolocation is recorded in the background.
*
* Fail callback to be executed every time a geolocation error occurs.
*
* Options a json object of type Config
*/
@Cordova({
callbackOrder: 'reverse'
})
static configure(options: Config): Promise<Location> { return; }
/**
* Turn ON the background-geolocation system.
* The user will be tracked whenever they suspend the app.
*/
@Cordova()
static start(): Promise<any> { return; }
/**
* Turn OFF background-tracking
*/
@Cordova()
static stop(): Promise<any> { return; }
/**
* Inform the native plugin that you're finished, the background-task may be completed
* NOTE: IOS, WP only
*/
@Cordova()
static finish() { }
/**
* Force the plugin to enter "moving" or "stationary" state
* NOTE: IOS, WP only
*/
@Cordova()
static changePace(isMoving: boolean) { }
/**
* Setup configuration
*/
@Cordova({
callbackOrder: 'reverse'
})
static setConfig(options: Config): Promise<any> { return; }
/**
* Returns current stationaryLocation if available. null if not
* NOTE: IOS, WP only
*/
@Cordova()
static getStationaryLocation(): Promise<Location> { return; }
/**
* Add a stationary-region listener. Whenever the devices enters "stationary-mode",
* your #success callback will be executed with #location param containing #radius of region
* NOTE: IOS, WP only
*/
@Cordova()
static onStationary(): Promise<any> { return; }
/**
* Check if location is enabled on the device
* @returns {Promise<number>} Returns a promise with int argument that takes values 0, 1 (true).
* NOTE: ANDROID only
*/
@Cordova()
static isLocationEnabled(): Promise<number> { return; }
/**
* Display device location settings
*/
@Cordova()
static showLocationSettings() { }
/**
* Method can be used to detect user changes in location services settings.
* If user enable or disable location services then success callback will be executed.
* In case or error (SettingNotFoundException) fail callback will be executed.
* NOTE: ANDROID only
*/
@Cordova()
static watchLocationMode(): Promise<boolean> { return; }
/**
* Stop watching for location mode changes.
* NOTE: ANDROID only
*/
@Cordova()
static stopWatchingLocationMode() { }
/**
* Method will return all stored locations.
* Locations are stored when:
* - config.stopOnTerminate is false and main activity was killed
* by the system
* or
* - option.debug is true
* NOTE: ANDROID only
*/
@Cordova()
static getLocations(): Promise<any> { return; }
/**
* Delete stored location by given locationId.
* NOTE: ANDROID only
*/
@Cordova()
static deleteLocation(locationId: number): Promise<any> { return; }
/**
* Delete all stored locations.
* NOTE: ANDROID only
*/
@Cordova()
static deleteAllLocations(): Promise<any> { return; }
}

View File

@ -0,0 +1,105 @@
import {Plugin, Cordova} from './plugin';
/**
* @name Background Mode
* @description
* 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';
*
* BackgroundMode.enable();
*/
@Plugin({
plugin: 'de.appplant.cordova.plugin.background-mode',
pluginRef: 'cordova.plugins.backgroundMode',
repo: 'https://github.com/katzer/cordova-plugin-background-mode',
platforms: ['Android', 'iOS', 'Windows Phone 8']
})
export class BackgroundMode {
/**
* Enable the background mode.
* Once called, prevents the app from being paused while in background.
*/
@Cordova({
sync: true
})
static enable(): void {}
/**
* Disable the background mode.
* Once the background mode has been disabled, the app will be paused when in background.
*/
@Cordova()
static disable(): void {}
/**
* Checks if background mode is enabled or not.
*/
@Cordova()
static isEnabled(): Promise<boolean> {return; }
/**
* Can be used to get the information if the background mode is active.
*/
@Cordova()
static isActive(): Promise<boolean> {return; }
/**
* Override the default title, ticker and text.
* Available only for Android platform.
*/
@Cordova({
platforms: ['Android']
})
static setDefaults(options?: Configure): void {}
/**
* Modify the displayed information.
* Available only for Android platform.
*/
@Cordova({
platforms: ['Android']
})
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
*/
@Cordova({
sync: true
})
static on(eventName: string, callback: any): void {}
}
/**
* Configurations items that can be updated.
*/
export interface Configure {
/**
*Title of the background task
*/
title?: String;
/**
*The text that scrolls itself on statusbar
*/
ticker?: String;
/**
*Description of background task
*/
text?: String;
/**
*Boolean, if true plugin will not display a notification. Default is false.
*/
silent?: boolean;
/**
*Boolean. By default the app will come to foreground when taping on the notification. If false, plugin wont come to foreground when tapped.
*/
resume?: boolean;
}

View File

@ -32,7 +32,7 @@ export class BarcodeScanner {
* @return Returns a Promise that resolves with scanner data, or rejects with an error.
*/
@Cordova()
static scan(): Promise<any> { return; }
static scan(options?: any): Promise<any> { return; }
// Not well supported
// @Cordova()

View File

@ -25,7 +25,7 @@ import {Observable} from 'rxjs/Observable';
* ```
*/
@Plugin({
plugin: 'cordova-plugin-batterystatus',
plugin: 'cordova-plugin-battery-status',
repo: 'https://github.com/apache/cordova-plugin-battery-status',
platforms: ['Amazon Fire OS', 'iOS', 'Android', 'BlackBerry 10', 'Windows Phone 7', 'Windows Phone 8', 'Windows', 'Firefox OS', 'Browser']
})

View File

@ -16,29 +16,27 @@ export class BluetoothSerial {
/**
* Connect to a Bluetooth device
* Returns an Observable. Subscribe to connect, unsubscribe to disconnect.
* @param macAddress_or_uuid Identifier of the remote device
*/
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
platforms: ['Android', 'iOS', 'Windows Phone'],
observable: true,
clearFunction: 'disconnect'
})
static connect (macAddress_or_uuid: string): Promise<any> {return; }
static connect (macAddress_or_uuid: string): Observable<any> {return; }
/**
* Connect insecurely to a Bluetooth device
* Returns an Observable. Subscribe to connect, unsubscribe to disconnect.
* @param macAddress Identifier of the remote device
*/
@Cordova({
platforms: ['Android']
platforms: ['Android'],
observable: true,
clearFunction: 'disconnect'
})
static connectInsecure (macAddress: string): Promise<any> {return; }
/**
* Disconnect
*/
@Cordova({
platforms: ['Android', 'iOS', 'Windows Phone']
})
static disconnect (): Promise<any> {return; }
static connectInsecure (macAddress: string): Observable<any> {return; }
/**
* Writes data to the serial port
@ -223,4 +221,4 @@ export class BluetoothSerial {
}
}

View File

@ -33,6 +33,26 @@ export interface Calendar {
platforms: ['Android', 'iOS']
})
export class Calendar {
/**
* This function checks if we have permission to read/write from/to the calendar.
* The promise will resolve with `true` when:
* - You're running on iOS, or
* - You're targetting API level lower than 23, or
* - You're using Android < 6, or
* - You've already granted permission
*
* If this returns false, you should call `requestReadWritePermissions` function
*/
@Cordova()
static hasReadWritePermissions(): Promise<boolean> { return; }
/**
* Requests read/write permissions
*/
@Cordova({sync: true})
static requestReadWritePermissions(): void {}
/**
* Create a calendar. (iOS only)
*
@ -251,7 +271,7 @@ export class Calendar {
* @return A Promise that resolves with the list of calendars, or rejects with an error.
*/
@Cordova()
static listCalendars() { return; }
static listCalendars(): Promise<any> { return; }
/**
* Get a list of all future events in the specified calendar. (iOS only)

73
src/plugins/card-io.ts Normal file
View File

@ -0,0 +1,73 @@
import {Plugin, Cordova} from './plugin';
/**
* @name CardIO
* @description
* @usage
* ```
* import {CardIO} from 'ionic-native';
*
* ...
*
* CardIO.canScan()
* .then(
* (res: boolean) => {
* if(res){
* let options = {
* requireExpiry: true,
* requireCCV: false,
* requirePostalCode: false
* };
* CardIO.scan(options);
* }
* }
* );
* ```
*/
@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']
})
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; }
/**
* Scan a credit card with card.io.
* @param options
*/
@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; }
}
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;
}

View File

@ -68,4 +68,4 @@ export class DBMeter {
@Cordova()
static delete(): Promise<any> {return; }
}
}

74
src/plugins/deeplinks.ts Normal file
View File

@ -0,0 +1,74 @@
import {Plugin, Cordova} from './plugin';
import {Observable} from 'rxjs/Observable';
export interface DeeplinkMatch {
/**
* The route info for the matched route
*/
routeInfo: any;
/**
* The arguments passed to the route through GET params along with
* any internal native data available as "extras" at the time
* the route was matched (for example, Facebook sometimes adds extra data)
*/
args: any;
}
/**
* @name Ionic Deeplinks
* @description This plugin handles deeplinks on iOS and Android for both custom URL scheme links
* and Universal App Links.
*
* @usage
* ```ts
* import {IonicDeeplinks} from 'ionic-native';
*
* ```
*/
@Plugin({
plugin: 'ionic-plugin-deeplinks',
pluginRef: 'IonicDeeplink',
repo: 'https://github.com/driftyo/ionic-plugin-deeplinks',
platforms: ['iOS', 'Android']
})
export class Deeplinks {
/**
* Define a set of paths to match against incoming deeplinks.
*
* @param {paths} Define a set of paths to match against incoming deeplinks.
* paths takes an object of the form { 'path': data }. If a deeplink
* matches the path, the resulting path-data pair will be returned in the
* promise result which you can then use to navigate in the app as you see fit.
* @returns {Promise} Returns a Promise that resolves when a deeplink comes through, and
* is rejected if a deeplink comes through that does not match a given path.
*/
@Cordova({
observable: true
})
static route(paths): Observable<DeeplinkMatch> {return; }
/**
*
* This is a convenience version of `route` that takes a reference to a NavController
* from Ionic 2, or a custom class that conforms to this protocol:
*
* NavController.push = function(View, Params){}
*
* This handler will automatically navigate when a route matches. If you need finer-grained
* control over the behavior of a matching deeplink, use the plain `route` method.
*
* @param {paths} Define a set of paths to match against incoming deeplinks.
* paths takes an object of the form { 'path': data }. If a deeplink
* matches the path, the resulting path-data pair will be returned in the
* promise result which you can then use to navigate in the app as you see fit.
*
* @returns {Promise} Returns a Promise that resolves when a deeplink comes through, and
* is rejected if a deeplink comes through that does not match a given path.
*/
@Cordova({
observable: true
})
static routeWithNavController(navController, paths): Observable<DeeplinkMatch> {return; }
}

View File

@ -101,4 +101,4 @@ export class DeviceMotion {
static watchAcceleration(options?: AccelerometerOptions): Observable<AccelerationData> {
return;
}
}
}

View File

@ -89,7 +89,7 @@ export class DeviceOrientation {
@Cordova({
callbackOrder: 'reverse',
observable: true,
cancelFunction: 'clearWatch'
clearFunction: 'clearWatch'
})
static watchHeading(options?: CompassOptions): Observable<CompassHeading> { return; }

View File

@ -2,7 +2,8 @@ import {Plugin, Cordova} from './plugin';
@Plugin({
plugin: 'cordova.plugins.diagnostic',
pluginRef: 'cordova.plugins.diagnostic'
pluginRef: 'cordova.plugins.diagnostic',
repo: 'https://github.com/floatinghotpot/cordova-plugin-admob'
})
export class Diagnostic {
/**
@ -20,7 +21,7 @@ export class Diagnostic {
/**
* 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" />
* On Android this requires permission. `<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />`
*/
@Cordova()
static isWifiEnabled() {
@ -185,4 +186,4 @@ export class Diagnostic {
}
}

View File

@ -1,21 +1,7 @@
import {Plugin, Cordova} from './plugin';
import {Email} from './types/email.type';
declare var cordova;
/**
* Email object for Opening Email Composer
*/
export interface Email {
app?: string;
to: string | Array<string>;
cc: string | Array<string>;
bcc: string | Array<string>;
attachments: Array<any>;
subject: string;
body: string;
isHtml: boolean;
}
/**
* @name Email Composer
* @description
@ -49,7 +35,7 @@ export interface Email {
* };
*
* // Send a text message using default options
* EmailComposer.send(email);
* EmailComposer.open(email);
*
* ```
*/
@ -64,13 +50,13 @@ export class EmailComposer {
/**
* Verifies if sending emails is supported on the device.
*
* @param app {string?} An optional app id or uri scheme. Defaults to mailto.
* @param scope {any?} An optional scope for the promise
* @returns {Promise<boolean>} Resolves promise with boolean whether EmailComposer is available
* @param app {string?} An optional app id or uri scheme.
* @returns {Promise<boolean>} Resolves if available, rejects if not available
*/
static isAvailable (app?: string, scope?: any): Promise<boolean> {
static isAvailable (app?: string): Promise<any> {
return new Promise<boolean>((resolve, reject) => {
cordova.plugins.email.isAvailable(app, resolve, scope);
if (app) cordova.plugins.email.isAvailable(app, (isAvailable) => { if (isAvailable) resolve(); else reject(); });
else cordova.plugins.email.isAvailable((isAvailable) => { if (isAvailable) resolve(); else reject(); });
});
}

View File

@ -20,7 +20,7 @@ import {Plugin, Cordova} from './plugin';
* Then type in the following command in your Terminal, where APP_ID and APP_NAME are the values from the Facebook Developer portal.
*
* ```bash
* cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="123456789" --variable APP_NAME="myApplication"
* ionic plugin add cordova-plugin-facebook4 --save --variable APP_ID="123456789" --variable APP_NAME="myApplication"
* ```
*
* After, you'll need to add the native platforms you'll be using to your app in the Facebook Developer portal under your app's Settings:
@ -85,10 +85,15 @@ import {Plugin, Cordova} from './plugin';
})
export class Facebook {
// @Cordova()
// static browserInit(appId: number){
// return new Promise<any>((res, rej) => {});
// }
/**
* Browser wrapper
* @param appId
* @param version
*/
@Cordova()
static browserInit(appId: number, version?: string): Promise<any> {
return;
}
/**
* Login to Facebook to authenticate this app.

View File

@ -51,6 +51,10 @@ export class File {
rejectFn('directory cannot start with \/');
}
if (!(/\/$/.test(dir))) {
path += '/';
}
try {
var directory = path + dir;
@ -118,7 +122,7 @@ export class File {
}
/**
* Remove a directory at a given path
* Remove a directory at a given path.
*
* @param {string} path The path to the directory
* @param {string} dirName The directory name
@ -158,7 +162,7 @@ export class File {
}
/**
* Move a directory to a given path
* Move a directory to a given path.
*
* @param {string} path The source path to the directory
* @param {string} dirName The source directory name
@ -252,7 +256,7 @@ export class File {
}
/**
* List files and directory from a given path
* List files and directory from a given path.
*
* @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
* @param {string} dirName Name of directory
@ -351,6 +355,10 @@ export class File {
rejectFn('file cannot start with \/');
}
if (!(/\/$/.test(file))) {
path += '/';
}
try {
var directory = path + file;
@ -462,7 +470,57 @@ export class File {
// static writeExistingFile(path: string, fileName: string, text: string): Promise<any> { return }
// static readAsText(path: string, file: string): Promise<any> { return }
/**
* Read a file as string.
*
* @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
* @param {string} fileName Name of file to move
* @return Returns a Promise that resolves or rejects with an error.
*/
static readAsText(path: string, fileName: string): Promise<any> {
let resolveFn, rejectFn;
let promise = new Promise((resolve, reject) => {resolveFn = resolve; rejectFn = reject; });
if ((/^\//.test(fileName))) {
rejectFn('file-name cannot start with \/');
}
try {
window.resolveLocalFileSystemURL(path, function (fileSystem) {
fileSystem.getFile(fileName, {create: false}, function (fileEntry) {
fileEntry.file(function (file) {
var reader = new FileReader();
reader.onloadend = function(e) {
if (this.result !== undefined && this.result !== null) {
resolveFn(this.result);
} else if (this.error !== undefined && this.error !== null) {
rejectFn(this.error);
} else {
rejectFn({code: null, message: 'READER_ONLOADEND_ERR'});
}
};
reader.readAsText(file);
}, function (error) {
error.message = File.cordovaFileError[error.code];
rejectFn(error);
});
}, function (err) {
err.message = File.cordovaFileError[err.code];
rejectFn(err);
});
}, function (er) {
er.message = File.cordovaFileError[er.code];
rejectFn(er);
});
} catch (e) {
e.message = File.cordovaFileError[e.code];
rejectFn(e);
}
return promise;
}
// static readAsDataURL(path: string, file: string): Promise<any> { return }

194
src/plugins/filetransfer.ts Normal file
View File

@ -0,0 +1,194 @@
import {Plugin, CordovaInstance} from './plugin';
declare var FileTransfer;
export interface FileUploadOptions {
/**
* The name of the form element.
* Defaults to 'file'.
*/
fileKey?: string;
/**
* The file name to use when saving the file on the server.
* Defaults to 'image.jpg'.
*/
fileName?: string;
/**
* The HTTP method to use - either PUT or POST.
* Defaults to POST.
*/
httpMethod?: string;
/**
* The mime type of the data to upload.
* Defaults to image/jpeg.
*/
mimeType?: string;
/**
* A set of optional key/value pairs to pass in the HTTP request.
*/
params?: { [s: string]: any; };
/**
* Whether to upload the data in chunked streaming mode.
* Defaults to true.
*/
chunkedMode?: boolean;
/**
* A map of header name/header values. Use an array to specify more
* than one value. On iOS, FireOS, and Android, if a header named
* Content-Type is present, multipart form data will NOT be used.
*/
headers?: { [s: string]: any; };
}
export interface FileUploadResult {
/**
* The number of bytes sent to the server as part of the upload.
*/
bytesSent: number;
/**
* The HTTP response code returned by the server.
*/
responseCode: number;
/**
* The HTTP response returned by the server.
*/
response: string;
/**
* The HTTP response headers by the server.
*/
headers: { [s: string]: any; };
}
export interface FileTransferError {
/**
* One of the predefined error codes listed below.
*/
code: number;
/**
* URL to the source.
*/
source: string;
/**
* URL to the target.
*/
target: string;
/**
* HTTP status code. This attribute is only available when a response
* code is received from the HTTP connection.
*/
http_status: number;
/**
* Response body. This attribute is only available when a response is received from the HTTP connection.
*/
body: string;
/**
* Either e.getMessage or e.toString.
*/
exception: string;
}
/**
* @name Transfer
* @description This plugin allows you to upload and download files.
* Example:
* Create instance:
* const fileTransfer = new Transfer();
*
* Upload a file:
* fileTransfer.upload(..).then(..).catch(..);
*
* Download a file:
* fileTransfer.download(..).then(..).catch(..);
*
* Abort active transfer:
* fileTransfer.abort();
*/
@Plugin({
plugin: 'cordova-plugin-file-transfer',
pluginRef: 'FileTransfer',
repo: 'https://github.com/apache/cordova-plugin-file-transfer'
})
export class Transfer {
public static FILE_NOT_FOUND_ERR: number = 1;
public static INVALID_URL_ERR: number = 2;
public static CONNECTION_ERR: number = 3;
public static ABORT_ERR: number = 4;
public static NOT_MODIFIED_ERR: number = 4;
private _objectInstance: any;
constructor() {
this._objectInstance = new FileTransfer();
}
/**
* Sends a file to a server.
*
* @param {string} fileUrl Filesystem URL representing the file on the device or a data URI. For backwards compatibility, this can also be the full path of the file on the device.
* @param {string} url URL of the server to receive the file, as encoded by encodeURI().
* @param {FileUploadOptions} options Optional parameters.
* @param {boolean} trustAllHosts: Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful since Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS.
* @return Returns a Promise that resolves to a FileUploadResult and rejects with FileTransferError.
*/
@CordovaInstance({
successIndex: 2,
errorIndex: 3
})
upload(fileUrl: string, url: string, options?: FileUploadOptions, trustAllHosts?: boolean): Promise<FileUploadResult> {
return;
}
/**
* Downloads a file from server.
*
* @param {string} source URL of the server to download the file, as encoded by encodeURI().
* @param {stirng} target Filesystem url representing the file on the device. For backwards compatibility, this can also be the full path of the file on the device.
* @param {boolean} trustAllHosts Optional parameter, defaults to false. If set to true, it accepts all security certificates. This is useful because Android rejects self-signed security certificates. Not recommended for production use. Supported on Android and iOS.
* @param {object} Optional parameters, currently only supports headers (such as Authorization (Basic Authentication), etc).
* @return Returns a Promise that resolves to a FileEntry object.
*/
@CordovaInstance({
successIndex: 2,
errorIndex: 3
})
download(source: string, target: string, trustAllHosts?: boolean, options?: { [s: string]: any; }): Promise<any> {
return;
}
/**
* Registers a listener that gets called whenever a new chunk of data is transferred.
* @param {function} Listener that takes a progress event.
*/
onProgress(listener: (event: ProgressEvent) => any): void {
this._objectInstance.onprogress = listener;
}
/**
* Aborts an in-progress transfer. The onerror callback is passed a FileTransferError
* object which has an error code of FileTransferError.ABORT_ERR.
*/
@CordovaInstance({
sync: true
})
abort(): void {}
}

View File

@ -23,8 +23,8 @@ export class Flashlight {
/**
* Checks if the flash light is available
* @returns {Promise<boolean>} Returns a promise that resolves with a boolean stating if the flash light is available.
* Checks if the flashlight is available
* @returns {Promise<boolean>} Returns a promise that resolves with a boolean stating if the flashlight is available.
*/
@Cordova()
static available(): Promise<boolean> { return; }
@ -37,7 +37,7 @@ export class Flashlight {
static switchOn(): Promise<boolean> { return; }
/**
* Switches the flash light off
* Switches the flashlight off
* @returns {Promise<boolean>}
*/
@Cordova()
@ -52,7 +52,7 @@ export class Flashlight {
/**
* Checks if the flash light is turned on.
* Checks if the flashlight is turned on.
* Returns a boolean
*/
@Cordova({
@ -60,4 +60,4 @@ export class Flashlight {
})
static isSwitchedOn(): boolean { return; }
}
}

View File

@ -107,7 +107,7 @@ export class Globalization {
successIndex: 1,
errorIndex: 2
})
static stringToNumber(stringToConvert: string, options: {type: string}): Promise<{value}> {return; }
static stringToNumber(stringToConvert: string, options: {type: string}): Promise<{value: number|string}> {return; }
/**
*

View File

@ -0,0 +1,46 @@
import {Plugin, Cordova} from './plugin';
/**
* @name Google Plus
* @description
* @usage
* ```
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-googleplus',
pluginRef: 'window.plugins.googleplus',
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-googleplus',
platforms: ['Web', 'Android', 'iOS'],
install: 'ionic plugin add cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=myreversedclientid'
})
export class GooglePlus {
/**
* The login function walks the user through the Google Auth process.
* @param options
*/
@Cordova()
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; }
/**
* This will clear the OAuth2 token.
*/
@Cordova()
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; }
}

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,22 @@
import {Plugin, Cordova} from './plugin';
import {Network} from './types/network.type';
import {NetworkConfig} from './types/network-config.type';
import {ConnectionInfo} from './types/connection-info.type';
import {HotspotDevice} from './types/hotspot-device.type';
/**
* @name Hotspot
* @description
* @usage
* ```js
* import {Hotspot} from 'ionic-native';
*
* import {Hotspot, Network} from 'ionic-native';
*
* ...
* Hotspot.scanWifi().then((networks: Array<Network>) => {
* console.log(networks);
* });
* ...
*
* ```
*/
@ -23,84 +32,191 @@ export class Hotspot {
static isAvailable(): Promise<boolean> {return; }
@Cordova()
static toggleWifi(): Promise<any> {return; }
static toggleWifi(): Promise<boolean> {return; }
/**
* Configures and starts hotspot with SSID and Password
*
* @param {string} SSID - SSID of your new Access Point
* @param {string} mode - encryption mode (Open, WEP, WPA, WPA_PSK)
* @param {string} password - password for your new Access Point
*
* @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; }
/**
* Turns on Access Point
*
* @return {Promise<boolean>} - true if AP is started
*/
@Cordova()
static startHotspot(): Promise<boolean> {return; }
/**
* Configures hotspot with SSID and Password
*
* @param {string} SSID - SSID of your new Access Point
* @param {string} mode - encryption mode (Open, WEP, WPA, WPA_PSK)
* @param {string} password - password for your new Access Point
*
* @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; }
/**
* Turns off Access Point
*
* @return {Promise<boolean>} - Promise to turn off the hotspot, true on success, false on failure
*/
@Cordova()
static stopHotspot(): Promise<boolean> {return; }
/**
* Checks if hotspot is enabled
*
* @return {Promise<void>} - Promise that hotspot is enabled, rejected if it is not enabled
*/
@Cordova()
static isHotspotEnabled(): Promise<void> {return; }
@Cordova()
static createHotspot(ssid: string, mode: string, password: string): Promise<any> {return; }
static getAllHotspotDevices(): Promise<Array<HotspotDevice>> {return; }
/**
* Connect to a WiFi network
*
* @param {string} ssid
* SSID to connect
* @param {string} password
* password to use
*
* @return {Promise<void>}
* Promise that connection to the WiFi network was successfull, rejected if unsuccessful
*/
@Cordova()
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
*/
@Cordova()
static connectToWifiAuthEncrypt(ssid: string, password: string, authentication: string, encryption: Array<string>): Promise<void> {return; }
/**
* Add a WiFi network
*
* @param {string} ssid
* SSID of network
* @param {string} mode
* Authentication mode of (Open, WEP, WPA, WPA_PSK)
* @param {string} password
* Password for network
*
* @return {Promise<void>}
* Promise that adding the WiFi network was successfull, rejected if unsuccessful
*/
@Cordova()
static addWifiNetwork(ssid: string, mode: string, password: string): Promise<void> {return; }
/**
* Remove a WiFi network
*
* @param {string} ssid
* SSID of network
*
* @return {Promise<void>}
* Promise that removing the WiFi network was successfull, rejected if unsuccessful
*/
@Cordova()
static removeWifiNetwork(ssid: string): Promise<void> {return; }
@Cordova()
static startHotspot(): Promise<any> {return; }
static isConnectedToInternet(): Promise<boolean> {return; }
@Cordova()
static configureHotspot(ssid: string, mode: string, password: string): Promise<any> {return; }
static isConnectedToInternetViaWifi(): Promise<boolean> {return; }
@Cordova()
static stopHotspot(): Promise<any> {return; }
static isWifiOn(): Promise<boolean> {return; }
@Cordova()
static isHotspotEnabled(): Promise<any> {return; }
static isWifiSupported(): Promise<boolean> {return; }
@Cordova()
static getAllHotspotDevices(): Promise<any> {return; }
static isWifiDirectSupported(): Promise<boolean> {return; }
@Cordova()
static connectToHotspot(ssid, password): Promise<any> {return; }
static scanWifi(): Promise<Array<Network>> {return; }
@Cordova()
static connectToWifiAuthEncrypt(ssid, password, authentication, encryption): Promise<any> {return; }
static scanWifiByLevel(): Promise<Array<Network>> {return; }
@Cordova()
static addWifiNetwork(ssid, mode, password): Promise<any> {return; }
static startWifiPeriodicallyScan(interval: number, duration: number): Promise<any> {return; }
@Cordova()
static removeWifiNetwork(ssid): Promise<any> {return; }
static stopWifiPeriodicallyScan(): Promise<any> {return; }
@Cordova()
static isConnectedToInternet(): Promise<any> {return; }
static getNetConfig(): Promise<NetworkConfig> {return; }
@Cordova()
static isConnectedToInternetViaWifi(): Promise<any> {return; }
static getConnectionInfo(): Promise<ConnectionInfo> {return; }
@Cordova()
static isWifiOn(): Promise<any> {return; }
static pingHost(ip: string): Promise<string> {return; }
/**
* Gets MAC Address associated with IP Address from ARP File
*
* @param {string} ip - IP Address that you want the MAC Address of
*
* @return {Promise<string>} - A Promise for the MAC Address
*/
@Cordova()
static isWifiSupported(): Promise<any> {return; }
static getMacAddressOfHost(ip: string): Promise<string> {return; }
/**
* Checks if IP is live using DNS
*
* @param {string} ip - IP Address you want to test
*
* @return {Promise<boolean>} - A Promise for whether the IP Address is reachable
*/
@Cordova()
static isWifiDirectSupported(): Promise<any> {return; }
static isDnsLive(ip: string): Promise<boolean> {return; }
/**
* Checks if IP is live using socket And PORT
*
* @param {string} ip - IP Address you want to test
*
* @return {Promise<boolean>} - A Promise for whether the IP Address is reachable
*/
@Cordova()
static scanWifi(): Promise<any> {return; }
static isPortLive(ip: string): Promise<boolean> {return; }
/**
* Checks if device is rooted
*
* @return {Promise<boolean>} - A Promise for whether the device is rooted
*/
@Cordova()
static scanWifiByLevel(): Promise<any> {return; }
@Cordova()
static startPeriodicallyScan(interval, duration): Promise<any> {return; }
@Cordova()
static stopPeriodicallyScan(): Promise<any> {return; }
@Cordova()
static getNetConfig(): Promise<any> {return; }
@Cordova()
static getConnectionInfo(): Promise<any> {return; }
@Cordova()
static pingHost(ip): Promise<any> {return; }
@Cordova()
static getMacAddressOfHost(ip): Promise<any> {return; }
@Cordova()
static isDnsLive(ip): Promise<any> {return; }
@Cordova()
static isPortLife(ip): Promise<any> {return; }
@Cordova()
static isRooted(): Promise<any> {return; }
static isRooted(): Promise<boolean> {return; }
}

47
src/plugins/insomnia.ts Normal file
View File

@ -0,0 +1,47 @@
import {Plugin, Cordova} from './plugin';
/**
* @name Insomnia
* @description
* Prevent the screen of the mobile device from falling asleep.
*
* @usage
* ```js
* import {Insomnia} from 'ionic-native';
*
* Insomnia.keepAwake()
* .then(
* () => console.log('success'),
* () => console.log('error')
* );
*
* Insomnia.allowSleepAgain()
* .then(
* () => console.log('success'),
* () => console.log('error')
* );
* ```
*
*/
@Plugin({
plugin: 'https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin.git',
pluginRef: 'plugins.insomnia',
repo: 'https://github.com/EddyVerbruggen/Insomnia-PhoneGap-Plugin',
platforms: ['Android', 'iOS', 'Windows Phone 8']
})
export class Insomnia {
/**
* Keeps awake the application
* @returns {Promise}
*/
@Cordova()
static keepAwake(): Promise<any> { return; }
/**
* Allows the application to sleep again
* @returns {Promise}
*/
@Cordova()
static allowSleepAgain(): Promise<any> { return; }
}

View File

@ -37,7 +37,7 @@ export class Keyboard {
static show(): void {}
/**
* Close the keyboard if open
* Close the keyboard if open.
*/
@Cordova({
sync: true,
@ -75,4 +75,4 @@ export class Keyboard {
})
static onKeyboardHide(): Observable<any> {return; }
}
}

View File

@ -25,14 +25,14 @@ declare var navigator: any;
* let connectSubscription = Network.onConnect().subscribe(() => {
* console.log('network connected!');*
* // We just got a connection but we need to wait briefly
* // before we determine the connection type. Might need to wait
*// before we determine the connection type. Might need to wait
* // prior to doing any api requests as well.
* setTimeout(() => {
* console.log(Network.connection);
* if (Network.connection === Connection.WIFI) {
* console.log('we got a wifi connection, woohoo!');
* }
* });
* }, 3000);
* });
*
* // stop connect watch

View File

@ -1,7 +1,5 @@
import {get} from '../util';
import {publishAngular1Service} from '../ng1';
declare var window;
declare var Promise;
declare var $q;
@ -160,7 +158,7 @@ function callInstance(pluginObj: any, methodName: string, args: any[], opts: any
return pluginObj._objectInstance[methodName].apply(pluginObj._objectInstance, args);
}
function wrapInstance (pluginObj: any, methodName: string, args: any[], opts: any = {}) {
function wrapInstance (pluginObj: any, methodName: string, opts: any = {}) {
return (...args) => {
if (opts.sync) {
return callInstance(pluginObj, methodName, args, opts);
@ -335,4 +333,4 @@ export function InstanceProperty(target: Function, key: string, descriptor: Type
};
return descriptor;
}
}

View File

@ -0,0 +1,101 @@
import {Plugin, Cordova} from './plugin';
/**
* @name SafariViewController
* @description
* @usage
* ```
* import {SafariViewController} from 'ionic-native';
*
* ...
*
* SafariViewController.isAvailable()
* .then(
* (available) => {
* if(available){
*
* SafariViewController.show({
* url: 'http://ionic.io',
* hidden: false,
* animated: false,
* transition: 'curl',
* enterReaderModeIfAvailable: true,
* tintColor: '#ff0000'
* })
* .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");
* },
* (error: any) => console.error(error)
* );
*
* } else {
* // use fallback browser, example InAppBrowser
* }
* }
* );
* ```
*/
@Plugin({
plugin: 'cordova-plugin-safariviewcontroller',
pluginRef: 'SafariViewController',
platforms: ['iOS'],
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-safariviewcontroller'
})
export class SafariViewController {
/**
* Checks if SafariViewController is available
*/
@Cordova()
static isAvailable(): Promise<boolean> {return; }
/**
* Shows Safari View Controller
* @param options
*/
@Cordova({
callbackOrder: 'reverse'
})
static show(options?: SafariViewControllerOptions): void {}
/**
* Hides Safari View Controller
*/
@Cordova({
sync: true
})
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; }
/**
* 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; }
}
export interface SafariViewControllerOptions {
url?: string;
hidden?: boolean;
toolbarColor?: string;
animated?: boolean;
showDefaultShareMenuItem?: boolean;
enterReaderModeIfAvailable?: boolean;
tintColor?: string;
transition?: string;
}

View File

@ -1,4 +1,5 @@
import {Cordova, Plugin} from './plugin';
declare var navigator: any;
@Plugin({
plugin: 'https://github.com/gitawego/cordova-screenshot.git',
pluginRef: 'navigator.screenshot',
@ -8,29 +9,52 @@ export class Screenshot {
/**
* Takes screenshot and saves the image
*
*
* @param {string} format. Format can take the value of either 'jpg' or 'png'
* On ios, only 'jpg' format is supported
* @param {number} quality. Determines the quality of the screenshot.
* @param {number} quality. Determines the quality of the screenshot.
* Default quality is set to 100.
* @param {string} filename. Name of the file as stored on the storage
* @param {string} filename. Name of the file as stored on the storage
*/
@Cordova({
successIndex: 1,
errorIndex: 0
})
static save (format?: string, quality?: number, filename?: string): Promise<any> {return; }
static save (format?: string, quality?: number, filename?: string): Promise<any> {
return new Promise<any>(
(resolve, reject) => {
navigator.screenshot.save(
(error, result) => {
if (error) {
reject(error);
}else {
resolve(result);
}
},
format,
quality,
filename
);
}
);
}
/**
* Takes screenshot and returns the image as an URI
*
* @param {number} quality. Determines the quality of the screenshot.
*
* @param {number} quality. Determines the quality of the screenshot.
* Default quality is set to 100.
*/
@Cordova({
successIndex: 1,
errorIndex: 0
})
static URI (quality?: number): Promise<any> {return; }
}
static URI (quality?: number): Promise<any> {
return new Promise<any>(
(resolve, reject) => {
navigator.screenshot.URI(
(error, result) => {
if (error) {
reject(error);
}else {
resolve(result);
}
},
quality
);
}
);
}
}

View File

@ -9,7 +9,7 @@ export interface ToastOptions {
/**
* Duration in ms to show
*/
duration?: string;
duration?: number;
/**
* Position
*/

View File

@ -0,0 +1,30 @@
/**
* @name ConnectionInfo
*/
export interface ConnectionInfo {
/**
* @property {string} SSID
* The service set identifier (SSID) of the current 802.11 network.
*/
SSID: string;
/**
* @property {string} BSSID
* The basic service set identifier (BSSID) of the current access point.
*/
BSSID: string;
/**
* @property {string} linkSpeed
* The current link speed in Mbps
*/
linkSpeed: string;
/**
* @property {string} IPAddress
* The IP Address
*/
IPAddress: string;
/**
* @property {string} networkID
* Each configured network has a unique small integer ID, used to identify the network when performing operations on the supplicant.
*/
networkID: string;
}

View File

@ -0,0 +1,13 @@
/**
* Email object for Opening Email Composer
*/
export interface Email {
app?: string;
to?: string | Array<string>;
cc?: string | Array<string>;
bcc?: string | Array<string>;
attachments?: Array<any>;
subject?: string;
body?: string;
isHtml?: boolean;
}

View File

@ -0,0 +1,15 @@
/**
* @name HotspotDevice
*/
export interface HotspotDevice {
/**
* @property {string} ip
* Hotspot IP Address
*/
ip: string;
/**
* @property {string} mac
* Hotspot MAC Address
*/
mac: string;
}

View File

@ -0,0 +1,21 @@
/**
* @name ConnectionInfo
*/
export interface NetworkConfig {
/**
* @property {string} deviceIPAddress - Device IP Address
*/
deviceIPAddress: string;
/**
* @property {string} deviceMacAddress - Device MAC Address
*/
deviceMacAddress: string;
/**
* @property {string} gatewayIPAddress - Gateway IP Address
*/
gatewayIPAddress: string;
/**
* @property {string} gatewayMacAddress - Gateway MAC Address
*/
gatewayMacAddress: string;
}

View File

@ -0,0 +1,37 @@
/**
* @name Network
* @description
* Based on [ScanResult](http://developer.android.com/reference/android/net/wifi/ScanResult.html)
*/
export interface Network {
/**
* @property {string} SSID
* Human readable network name
*/
SSID: string;
/**
* @property {string} BSSID
* MAC Address of the access point
*/
BSSID: string;
/**
* @property {number (int)} frequency
* The primary 20 MHz frequency (in MHz) of the channel over which the client is communicating with the access point.
*/
frequency: number;
/**
* @property {number} level
* The detected signal level in dBm, also known as the RSSI.
*/
level: number;
/**
* @property {number} timestamp
* Timestamp in microseconds (since boot) when this result was last seen.
*/
timestamp: number;
/**
* @property {string} capabilities
* Describes the authentication, key management, and encryption schemes supported by the access point.
*/
capabilities: string;
}

View File

@ -35,4 +35,4 @@ export class WebIntent {
@Cordova()
static sendBroadcast(options: {action: string, extras?: {option: boolean}}): Promise<any> {return; }
}
}