Compare commits

..

42 Commits

Author SHA1 Message Date
Ibby
5b060345d2 chore(): update changelog 2016-10-11 04:30:55 -04:00
Ibby
1784036ef7 chore(): update changelog 2016-10-11 04:22:46 -04:00
Ibby
7a8577007c 2.2.0 2016-10-11 04:19:02 -04:00
Ibrahim Hadeed
7c6e6d8b6b fix(onesignal): update to match latest api (#671)
closes #667
2016-10-11 01:12:43 -07:00
Ramon Henrique Ornelas
c5fd83ddb6 style(onesignal): add semicolon fix lint (#672) 2016-10-11 01:12:32 -07:00
Ramon Henrique Ornelas
7b2fe69c7c docs(camera-preview): change repo no longer maintaned fix #360
* docs(camera-preview): change repo no longer maintaned  fix #360

* refactor(camera-preview): delete dead code
2016-10-11 01:11:05 -07:00
Ibrahim Hadeed
f0961c7b23 feat(http): add cordovaHTTP wrapper (#674) 2016-10-11 01:06:41 -07:00
Ibby
35c8bbd49e fix(native-transitions): add missing interface properties 2016-10-10 20:50:10 -04:00
Ibby
1a343c1ea5 Merge branch 'master' of https://github.com/driftyco/ionic-native 2016-10-10 20:10:43 -04:00
Ibby
4fef8ff326 refractor(onesignal): add OneSignalNotification interface 2016-10-10 20:10:14 -04:00
Xueron Nee
13681756ae fix(thmeable-browser): fix the name of the plugin (#663) 2016-10-09 04:33:54 -04:00
Ibby
4a798281e4 chore(): update changelog 2016-10-08 20:57:54 -04:00
Ibby
79670b7878 2.1.9 2016-10-08 20:57:47 -04:00
Ibby
720084578d fix(paypal): add optional details param to paypalpayment 2016-10-08 20:44:32 -04:00
Patrick Bußmann
3dd6a92ccf fix(paypal): problems with selection of PayPal environment (#662)
* Fixed bugs with selection of environment and added missing prepareToRender function

* Updated PayPal usage example
2016-10-08 20:34:27 -04:00
Ramon Henrique Ornelas
7d1686ef93 refactor(googlemaps): throw warnings plugin_not_installed (#655)
* refactor(googlemaps): adjust imports to warnings console and delete @author comments

* refactor(googlemaps): throw warnings plugin_not_installed

* refactor(googlemaps): delete warnings of the methods added Promise.reject case plugin_not_instalet
2016-10-08 20:29:53 -04:00
Ibby
b40b0fff98 chore(): update changelog 2016-10-08 18:50:49 -04:00
Ibby
4dba0580ac 2.1.8 2016-10-08 18:50:36 -04:00
Ibby
11653ce752 fix(googlemaps): fixes GoogleMapsLatLng class
closes 658
2016-10-08 18:48:28 -04:00
Ramon Henrique Ornelas
d3e6f3ba41 refactor(plugin): improvement pull #654 (#661) 2016-10-08 15:07:01 -04:00
Thiery Laverdure
2c6cc37a5f docs(calendar): fix typo (#660) 2016-10-08 14:54:02 -04:00
Ibby
4c7defb2ec chore(): update changelog 2016-10-06 20:38:32 -04:00
Ibby
2da02e6d46 2.1.7 2016-10-06 20:38:21 -04:00
Ibby
7a91c87a72 test(): sync methods no longer get resolve/reject 2016-10-06 20:37:41 -04:00
Patrick Bußmann
598f8a9e7c fix(paypal): fixed currency code not found issue (#653) 2016-10-06 20:34:45 -04:00
ziggyJ
6f0f02bb66 fix google maps setPadding not working issue #573 (#654) 2016-10-06 20:33:42 -04:00
Ramon Henrique Ornelas
e4bde77bd4 chore(): deleted ionic-gulp-tslint change for gulp-tslint directly (#611) 2016-10-06 00:37:34 -04:00
Ibby
c24b331866 chore(): update changelog 2016-10-06 00:27:24 -04:00
Ibby
4ac348bd0f 2.1.6 2016-10-06 00:27:04 -04:00
Ibby
f0026572e7 fix(paypal): fix helper classes 2016-10-06 00:26:59 -04:00
Ibby
e30ccabf7b 2.1.5 2016-10-05 23:19:55 -04:00
Ibby
6b286db51a chore(): add successIndex at the correct position if we have optional params 2016-10-05 23:19:45 -04:00
Ibby
d79d62bfa0 docs(hotspot): remove unecessary doc tags 2016-10-05 22:46:22 -04:00
Ibby
2bdd3a3868 chore(): update changelog 2016-10-05 22:43:59 -04:00
Ibby
09d481e1d6 2.1.4 2016-10-05 22:43:31 -04:00
Ibby
6f23bef5d1 fix(google-analytics): specify successIndex and errorIndex for methods with optional params 2016-10-05 22:43:20 -04:00
Ibby
84f54d64aa chore(): update changelog 2016-10-05 22:42:35 -04:00
Ibby
c9ddec3bb5 2.1.3 2016-10-05 22:36:10 -04:00
Ibby
f62e1081e1 fix(google-analytics): add newSession param 2016-10-05 22:35:52 -04:00
Ibby
7dba41cbe1 docs(google-analytics): add missing docs 2016-10-05 22:30:40 -04:00
Ibby
77b0277290 fix(google-analytics): add missing methods, fix return types 2016-10-05 22:27:28 -04:00
Ibby
40325cad9f fix(google-analytics): fix depreciated plugin reference 2016-10-05 22:20:55 -04:00
16 changed files with 851 additions and 403 deletions

View File

@@ -1,3 +1,98 @@
<a name="2.2.0"></a>
# [2.2.0](https://github.com/driftyco/ionic-native/compare/v2.1.9...v2.2.0) (2016-10-11)
## BREAKING CHANGES
### OneSignal
The wrapper for this plugin has been updated to the match latest version of the plugin (2.x). If you are still using and older version of the plugin (1.x), you should use ionic-native v.2.1.x.
### ThemeableBrowser
The wrapper for this plugin (and related interfaces) has been refactored to replace "Themable" with "Themeable". Please fix your existing code to match the new class and interfaces names.
----
### Bug Fixes
* **native-transitions:** add missing interface properties ([35c8bbd](https://github.com/driftyco/ionic-native/commit/35c8bbd))
* **onesignal:** update to match latest api ([#671](https://github.com/driftyco/ionic-native/issues/671)) ([7c6e6d8](https://github.com/driftyco/ionic-native/commit/7c6e6d8)), closes [#667](https://github.com/driftyco/ionic-native/issues/667)
* **thmeable-browser:** fix the name of the plugin ([#663](https://github.com/driftyco/ionic-native/issues/663)) ([1368175](https://github.com/driftyco/ionic-native/commit/1368175))
### Features
* **http:** add cordovaHTTP wrapper ([#674](https://github.com/driftyco/ionic-native/issues/674)) ([f0961c7](https://github.com/driftyco/ionic-native/commit/f0961c7))
<a name="2.1.9"></a>
## [2.1.9](https://github.com/driftyco/ionic-native/compare/v2.1.8...v2.1.9) (2016-10-09)
### Bug Fixes
* **paypal:** add optional details param to paypalpayment ([7200845](https://github.com/driftyco/ionic-native/commit/7200845))
* **paypal:** problems with selection of PayPal environment ([#662](https://github.com/driftyco/ionic-native/issues/662)) ([3dd6a92](https://github.com/driftyco/ionic-native/commit/3dd6a92))
<a name="2.1.8"></a>
## [2.1.8](https://github.com/driftyco/ionic-native/compare/v2.1.7...v2.1.8) (2016-10-08)
### Bug Fixes
* **googlemaps:** fixes GoogleMapsLatLng class ([11653ce](https://github.com/driftyco/ionic-native/commit/11653ce))
<a name="2.1.7"></a>
## [2.1.7](https://github.com/driftyco/ionic-native/compare/v2.1.6...v2.1.7) (2016-10-07)
### Bug Fixes
* **paypal:** fixed currency code not found issue ([#653](https://github.com/driftyco/ionic-native/issues/653)) ([598f8a9](https://github.com/driftyco/ionic-native/commit/598f8a9))
<a name="2.1.6"></a>
## [2.1.6](https://github.com/driftyco/ionic-native/compare/v2.1.5...v2.1.6) (2016-10-06)
### Bug Fixes
* **paypal:** fix helper classes ([f002657](https://github.com/driftyco/ionic-native/commit/f002657))
<a name="2.1.5"></a>
## [2.1.5](https://github.com/driftyco/ionic-native/compare/v2.1.4...v2.1.5) (2016-10-06)
<a name="2.1.4"></a>
## [2.1.4](https://github.com/driftyco/ionic-native/compare/v2.1.3...v2.1.4) (2016-10-06)
### Bug Fixes
* **google-analytics:** specify successIndex and errorIndex for methods with optional params ([6f23bef](https://github.com/driftyco/ionic-native/commit/6f23bef))
<a name="2.1.3"></a>
## [2.1.3](https://github.com/driftyco/ionic-native/compare/v2.1.2...v2.1.3) (2016-10-06)
### Bug Fixes
* **google-analytics:** add missing methods, fix return types ([77b0277](https://github.com/driftyco/ionic-native/commit/77b0277))
* **google-analytics:** add newSession param ([f62e108](https://github.com/driftyco/ionic-native/commit/f62e108))
* **google-analytics:** fix depreciated plugin reference ([40325ca](https://github.com/driftyco/ionic-native/commit/40325ca))
<a name="2.1.2"></a>
## [2.1.2](https://github.com/driftyco/ionic-native/compare/v2.1.1...v2.1.2) (2016-10-06)

View File

@@ -2,7 +2,7 @@ var gulp = require('gulp');
var minimist = require('minimist');
var uglify = require('gulp-uglify');
var rename = require("gulp-rename");
var tslint = require('ionic-gulp-tslint');
var tslint = require('gulp-tslint');
var decamelize = require('decamelize');
var replace = require('gulp-replace');
@@ -28,7 +28,12 @@ gulp.task("minify:dist", function(){
});
gulp.task('lint', function() {
tslint({src: 'src/**/*.ts'});
gulp.src('src/**/*.ts')
.pipe(tslint({
formatter: "verbose",
configuration: 'tslint.json'
}))
.pipe(tslint.report())
});
gulp.task('plugin:create', function(){

View File

@@ -1,6 +1,6 @@
{
"name": "ionic-native",
"version": "2.1.2",
"version": "2.2.0",
"description": "Native plugin wrappers for Cordova and Ionic with TypeScript, ES6+, Promise and Observable support",
"main": "dist/es5/index.js",
"module": "dist/esm/index.js",
@@ -26,9 +26,8 @@
"gulp": "^3.9.1",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-tslint": "^5.0.0",
"gulp-tslint": "^6.1.2",
"gulp-uglify": "^1.5.4",
"ionic-gulp-tslint": "^1.0.0",
"jasmine-core": "~2.5.0",
"karma": "~1.2.0",
"karma-browserify": "~5.1.0",
@@ -41,7 +40,7 @@
"q": "1.4.1",
"semver": "^5.0.1",
"tsify": "~1.0.4",
"tslint": "^3.8.1",
"tslint": "^3.15.1",
"tslint-ionic-rules": "0.0.5",
"typescript": "^2.0.1",
"watchify": "~3.7.0"

View File

@@ -100,7 +100,7 @@ import { ThreeDeeTouch } from './plugins/3dtouch';
import { Toast } from './plugins/toast';
import { TouchID } from './plugins/touchid';
import { TextToSpeech } from './plugins/text-to-speech';
import { ThemableBrowser } from './plugins/themable-browser';
import { ThemeableBrowser } from './plugins/themeable-browser';
import { TwitterConnect } from './plugins/twitter-connect';
import { Vibration } from './plugins/vibration';
import { VideoEditor } from './plugins/video-editor';
@@ -158,6 +158,7 @@ export * from './plugins/google-plus';
export * from './plugins/googleanalytics';
export * from './plugins/googlemaps';
export * from './plugins/hotspot';
export * from './plugins/http';
export * from './plugins/httpd';
export * from './plugins/ibeacon';
export * from './plugins/imagepicker';
@@ -204,7 +205,7 @@ export * from './plugins/statusbar';
export * from './plugins/stepcounter';
export * from './plugins/streaming-media';
export * from './plugins/text-to-speech';
export * from './plugins/themable-browser';
export * from './plugins/themeable-browser';
export * from './plugins/toast';
export * from './plugins/touchid';
export * from './plugins/twitter-connect';
@@ -314,7 +315,7 @@ window['IonicNative'] = {
TouchID,
Transfer,
TextToSpeech,
ThemableBrowser,
ThemeableBrowser,
TwitterConnect,
VideoEditor,
VideoPlayer,

View File

@@ -53,7 +53,7 @@ export class Calendar {
* - You're using Android < 6, or
* - You've already granted permission
*
* If this returns false, you should call `requestReadWritePermissions` function
* If this returns false, you should call the `requestReadWritePermission` function
* @returns {Promise<boolean>}
*/
@Cordova()

View File

@@ -19,7 +19,7 @@ export interface CameraPreviewSize {
* @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).
* For more info, please see the [Cordova Camera Preview Plugin Docs](https://github.com/westonganger/cordova-plugin-camera-preview').
*
* @usage
* ```
@@ -71,7 +71,7 @@ export interface CameraPreviewSize {
@Plugin({
plugin: 'cordova-plugin-camera-preview',
pluginRef: 'cordova.plugins.camerapreview',
repo: 'https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview',
repo: 'https://github.com/westonganger/cordova-plugin-camera-preview',
platforms: ['Android', 'iOS']
})
export class CameraPreview {
@@ -139,14 +139,6 @@ export class CameraPreview {
})
static hide(): void { };
/**
* Set the default mode for the Flash.
*/
// @Cordova({
// sync: true
// })
// static setFlashMode(mode: number): void { };
/**
* Set camera color effect.
*/
@@ -154,15 +146,4 @@ export class CameraPreview {
sync: true
})
static setColorEffect(effect: string): void { };
/**
* @private
* @enum {number}
*/
static FlashMode = {
OFF: 0,
ON: 1,
AUTO: 2
};
}

View File

@@ -14,7 +14,7 @@ declare var window;
*/
@Plugin({
plugin: 'cordova-plugin-google-analytics',
pluginRef: 'analytics',
pluginRef: 'ga',
repo: 'https://github.com/danwilson/google-analytics-plugin',
platforms: ['Android', 'iOS']
})
@@ -23,45 +23,128 @@ 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
* @return {Promise<any>}
*/
@Cordova()
static startTrackerWithId(id: string): Promise<any> { return; }
/**
* Enabling Advertising Features in Google Analytics allows you to take advantage of Remarketing, Demographics & Interests reports, and more
* @param allow {boolean}
* @return {Promise<any>}
*/
@Cordova()
static setAllowIDFACollection(allow: boolean): Promise<any> { return; }
/**
* Set a UserId
* https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id
* @param {string} id User ID
* @return {Promise<any>}
*/
@Cordova()
static setUserId(id: string): Promise<any> { return; }
/**
* Set a anonymize Ip address
* @param anonymize {boolean} Set to true to anonymize the IP Address
* @return {Promise<any>}
*/
@Cordova()
static setAnonymizeIp(anonymize: boolean): Promise<any> { return; }
/**
* Sets the app version
* @param appVersion {string} App version
* @return {Promise<any>}
*/
@Cordova()
static setAppVersion(appVersion: string): Promise<any> { return; }
/**
* Set OptOut
* @param optout {boolean}
* @return {Promise<any>}
*/
@Cordova()
static setOptOut(optout: boolean): Promise<any> { return; }
/**
* Enable verbose logging
* @return {Promise<any>}
*/
@Cordova()
static debugMode(): Promise<any> { return; }
/**
* Track custom metric
* @param key {string}
* @param value {any}
* @return {Promise<any>}
*/
@Cordova({
successIndex: 2,
errorIndex: 3
})
static trackMetric(key: string, value?: any): 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
* @param title {string} Screen title
* @param campaignUrl {string} Campaign url for measuring referrals
* @param newSession {boolean} Set to true to create a new session
* @return {Promise<any>}
*/
@Cordova({
successIndex: 3,
errorIndex: 4
})
static trackView(title: string, campaignUrl?: string, newSession?: boolean): Promise<any> { return; }
/**
* Add a Custom Dimension
* https://developers.google.com/analytics/devguides/platform/customdimsmets
* @param key {string}
* @param value {string}
* @return {Promise<any>}
*/
@Cordova()
static trackView(title: string, campaignUrl?: string): Promise<any> { return; }
static addCustomDimension(key: number, value: 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
* @param category {string}
* @param action {string}
* @param label {string}
* @param value {number}
* @param newSession {boolean} Set to true to create a new session
* @return {Promise<any>}
*/
@Cordova()
static trackEvent(category: string, action: string, label?: string, value?: number): Promise<any> { return; }
@Cordova({
successIndex: 5,
errorIndex: 6
})
static trackEvent(category: string, action: string, label?: string, value?: number, newSession?: boolean): Promise<any> { return; }
/**
* Track an exception
* @param {string} description
* @param {boolean} fatal
* @param description {string}
* @param fatal {boolean}
* @return {Promise<any>}
*/
@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
* @param category {string}
* @param intervalInMilliseconds {number}
* @param variable {string}
* @param label {string}
* @return {Promise<any>}
*/
@Cordova()
static trackTiming(category: string, intervalInMilliseconds: number, variable: string, label: string): Promise<any> { return; }
@@ -69,12 +152,13 @@ export class GoogleAnalytics {
/**
* 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
* @param id {string}
* @param affiliation {string}
* @param revenue {number}
* @param tax {number}
* @param shipping {number}
* @param currencyCode {string}
* @return {Promise<any>}
*/
@Cordova()
static addTransaction(id: string, affiliation: string, revenue: number, tax: number, shipping: number, currencyCode: string): Promise<any> { return; }
@@ -89,57 +173,15 @@ export class GoogleAnalytics {
* @param {number} price
* @param {number} quantity
* @param {string} currencyCode
* @return {Promise<any>}
*/
@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; }
/**
* Set a UserId
* https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id
* @param {string} id
*/
@Cordova({sync: true})
static setUserId(id: string): void { }
/**
* Sets the app version
* @param appVersion
*/
@Cordova({sync: true})
static setAppVersion(appVersion: string): void { }
/**
* 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
* @param shouldEnable {boolean}
* @return {Promise<any>}
*/
@Cordova()
static enableUncaughtExceptionReporting(shouldEnable: boolean): Promise<any> { return; }

View File

@@ -1,11 +1,6 @@
import {Cordova, CordovaInstance, Plugin, InstanceProperty} from './plugin';
import { Cordova, CordovaInstance, Plugin, InstanceProperty, getPlugin, pluginWarn } from './plugin';
import { Observable } from 'rxjs/Observable';
/**
* @private
* Created by Ibrahim on 3/29/2016.
*/
declare var plugin: any;
/**
@@ -88,12 +83,13 @@ export const GoogleMapsAnimation = {
* });
* ```
*/
@Plugin({
let pluginMap = {
pluginRef: 'plugin.google.maps.Map',
plugin: 'cordova-plugin-googlemaps',
repo: 'https://github.com/mapsplugin/cordova-plugin-googlemaps',
install: 'ionic plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"'
})
};
@Plugin(pluginMap)
export class GoogleMap {
_objectInstance: any;
@@ -106,8 +102,14 @@ export class GoogleMap {
static isAvailable(): Promise<boolean> { return; }
constructor(element: string|HTMLElement, options?: any) {
if (typeof element === 'string') element = document.getElementById(<string>element);
this._objectInstance = plugin.google.maps.Map.getMap(element, options);
if (!!getPlugin('plugin.google.maps.Map')) {
if (typeof element === 'string') {
element = document.getElementById(<string>element);
}
this._objectInstance = plugin.google.maps.Map.getMap(element, options);
} else {
pluginWarn(pluginMap);
}
}
/**
@@ -116,6 +118,12 @@ export class GoogleMap {
* @return {Observable<any>}
*/
on(event: any): Observable<any> {
if (!this._objectInstance) {
return new Observable((observer) => {
observer.error({ error: 'plugin_not_installed' });
});
}
return new Observable(
(observer) => {
this._objectInstance.on(event, observer.next.bind(observer));
@@ -130,6 +138,9 @@ export class GoogleMap {
* @return {Promise<any>}
*/
one(event: any): Promise<any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<any>(
resolve => this._objectInstance.one(event, resolve)
);
@@ -207,7 +218,10 @@ export class GoogleMap {
@CordovaInstance({ sync: true })
setAllGesturesEnabled(enabled: boolean): void { }
addMarker(options: GoogleMapsMarkerOptions): Promise<GoogleMapsMarker> {
addMarker(options: GoogleMapsMarkerOptions): Promise<GoogleMapsMarker | any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<GoogleMapsMarker>(
(resolve, reject) => {
this._objectInstance.addMarker(options, (marker: any) => {
@@ -221,7 +235,10 @@ export class GoogleMap {
);
}
addCircle(options: GoogleMapsCircleOptions): Promise<GoogleMapsCircle> {
addCircle(options: GoogleMapsCircleOptions): Promise<GoogleMapsCircle | any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<GoogleMapsCircle>(
(resolve, reject) => {
this._objectInstance.addCircle(options, (circle: any) => {
@@ -235,7 +252,10 @@ export class GoogleMap {
);
}
addPolygon(options: GoogleMapsPolygonOptions): Promise<GoogleMapsPolygon> {
addPolygon(options: GoogleMapsPolygonOptions): Promise<GoogleMapsPolygon | any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<GoogleMapsPolygon>(
(resolve, reject) => {
this._objectInstance.addPolygon(options, (polygon: any) => {
@@ -249,7 +269,10 @@ export class GoogleMap {
);
}
addPolyline(options: GoogleMapsPolylineOptions): Promise<GoogleMapsPolyline> {
addPolyline(options: GoogleMapsPolylineOptions): Promise<GoogleMapsPolyline | any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<GoogleMapsPolyline>(
(resolve, reject) => {
this._objectInstance.addPolyline(options, (polyline: any) => {
@@ -263,7 +286,10 @@ export class GoogleMap {
);
}
addTileOverlay(options: GoogleMapsTileOverlayOptions): Promise<GoogleMapsTileOverlay> {
addTileOverlay(options: GoogleMapsTileOverlayOptions): Promise<GoogleMapsTileOverlay | any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<GoogleMapsTileOverlay>(
(resolve, reject) => {
this._objectInstance.addTileOverlay(options, (tileOverlay: any) => {
@@ -277,7 +303,10 @@ export class GoogleMap {
);
}
addGroundOverlay(options: GoogleMapsGroundOverlayOptions): Promise<GoogleMapsGroundOverlay> {
addGroundOverlay(options: GoogleMapsGroundOverlayOptions): Promise<GoogleMapsGroundOverlay | any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<GoogleMapsGroundOverlay>(
(resolve, reject) => {
this._objectInstance.addGroundOverlay(options, (groundOverlay: any) => {
@@ -291,7 +320,10 @@ export class GoogleMap {
);
}
addKmlOverlay(options: GoogleMapsKmlOverlayOptions): Promise<GoogleMapsKmlOverlay> {
addKmlOverlay(options: GoogleMapsKmlOverlayOptions): Promise<GoogleMapsKmlOverlay | any> {
if (!this._objectInstance) {
return Promise.reject({ error: 'plugin_not_installed' });
}
return new Promise<GoogleMapsKmlOverlay>(
(resolve, reject) => {
this._objectInstance.addKmlOverlay(options, (kmlOverlay: any) => {
@@ -879,21 +911,22 @@ export class GoogleMapsLatLngBounds {
* @private
*/
export class GoogleMapsLatLng {
private _objectInstance: any;
@InstanceProperty get lat(): number { return; }
@InstanceProperty get lng(): number { return; }
lat: number;
lng: number;
constructor(lat: number, lng: number) {
this._objectInstance = new plugin.google.maps.LatLng(lat, lng);
this.lat = lat;
this.lng = lng;
}
equals(other: GoogleMapsLatLng): boolean {
return this.lat === other.lat && this.lng === other.lng;
}
@CordovaInstance({ sync: true })
toString(): string { return; }
toString(): string {
return this.lat + ',' + this.lng;
}
toUrlValue(precision?: number): string {
precision = precision || 6;
@@ -941,9 +974,10 @@ export class Geocoder {
* @param {GeocoderRequest} request Request object with either an address or a position
* @returns {Promise<GeocoderResult[]>}
*/
static geocode(request: GeocoderRequest): Promise<GeocoderResult[]> {
static geocode(request: GeocoderRequest): Promise<GeocoderResult[] | any> {
return new Promise<GeocoderResult[]>((resolve, reject) => {
if (!plugin || !plugin.google || !plugin.google.maps || !plugin.google.maps.Geocoder) {
pluginWarn(pluginMap);
reject({ error: 'plugin_not_installed' });
} else {
plugin.google.maps.Geocoder.geocode(request, resolve);

View File

@@ -217,27 +217,27 @@ export class Hotspot {
export interface ConnectionInfo {
/**
* @property {string} SSID
* SSID
* The service set identifier (SSID) of the current 802.11 network.
*/
SSID: string;
/**
* @property {string} BSSID
* BSSID
* The basic service set identifier (BSSID) of the current access point.
*/
BSSID: string;
/**
* @property {string} linkSpeed
* linkSpeed
* The current link speed in Mbps
*/
linkSpeed: string;
/**
* @property {string} IPAddress
* IPAddress
* The IP Address
*/
IPAddress: string;
/**
* @property {string} networkID
* networkID
* Each configured network has a unique small integer ID, used to identify the network when performing operations on the supplicant.
*/
networkID: string;
@@ -245,62 +245,62 @@ export interface ConnectionInfo {
export interface HotspotNetwork {
/**
* @property {string} SSID
* SSID
* Human readable network name
*/
SSID: string;
/**
* @property {string} BSSID
* BSSID
* MAC Address of the access point
*/
BSSID: string;
/**
* @property {number (int)} frequency
* 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
* level
* The detected signal level in dBm, also known as the RSSI.
*/
level: number;
/**
* @property {number} timestamp
* timestamp
* Timestamp in microseconds (since boot) when this result was last seen.
*/
timestamp: number;
/**
* @property {string} capabilities
* capabilities
* Describes the authentication, key management, and encryption schemes supported by the access point.
*/
capabilities: string;
}
export interface HotspotNetworkConfig {
/**
* @property {string} deviceIPAddress - Device IP Address
* deviceIPAddress - Device IP Address
*/
deviceIPAddress: string;
/**
* @property {string} deviceMacAddress - Device MAC Address
* deviceMacAddress - Device MAC Address
*/
deviceMacAddress: string;
/**
* @property {string} gatewayIPAddress - Gateway IP Address
* gatewayIPAddress - Gateway IP Address
*/
gatewayIPAddress: string;
/**
* @property {string} gatewayMacAddress - Gateway MAC Address
* gatewayMacAddress - Gateway MAC Address
*/
gatewayMacAddress: string;
}
export interface HotspotDevice {
/**
* @property {string} ip
* ip
* Hotspot IP Address
*/
ip: string;
/**
* @property {string} mac
* mac
* Hotspot MAC Address
*/
mac: string;

158
src/plugins/http.ts Normal file
View File

@@ -0,0 +1,158 @@
import {Plugin, Cordova} from './plugin';
/**
* @name HTTP
* @description
* Cordova / Phonegap plugin for communicating with HTTP servers. Supports iOS and Android.
*
* Advantages over Javascript requests:
* - Background threading - all requests are done in a background thread
* - SSL Pinning
*
* @usage
* ```
* import { HTTP } from 'ionic-native';
*
* HTTP.get('http://ionic.io', {}, {})
* .then(data => {
*
* console.log(data.status);
* console.log(data.data); // data received by server
* console.log(data.headers);
*
* })
* .catch(error => {
*
* console.log(error.status);
* console.log(error.error); // error message as string
* console.log(error.headers);
*
* });
*
* ```
* @interfaces
* HTTPResponse
*/
@Plugin({
plugin: 'cordova-plugin-http',
pluginRef: 'cordovaHTTP',
repo: 'https://github.com/wymsee/cordova-HTTP'
})
export class HTTP {
/**
* This returns an object representing a basic HTTP Authorization header of the form.
* @param username {string} Username
* @param password {string} Password
* @return {Object} an object representing a basic HTTP Authorization header of the form {'Authorization': 'Basic base64encodedusernameandpassword'}
*/
@Cordova({ sync: true })
static getBasicAuthHeader(username: string, password: string): { Authorization: string; } { return; }
/**
* This sets up all future requests to use Basic HTTP authentication with the given username and password.
* @param username {string} Username
* @param password {string} Password
*/
@Cordova({ sync: true })
static useBasicAuth(username: string, password: string): void { }
/**
* Set a header for all future requests. Takes a header and a value.
* @param header {string} The name of the header
* @param value {string} The value of the header
*/
@Cordova({ sync: true })
static setHeader(header: string, value: string): void { }
/**
* Enable or disable SSL Pinning. This defaults to false.
*
* To use SSL pinning you must include at least one .cer SSL certificate in your app project. You can pin to your server certificate or to one of the issuing CA certificates. For ios include your certificate in the root level of your bundle (just add the .cer file to your project/target at the root level). For android include your certificate in your project's platforms/android/assets folder. In both cases all .cer files found will be loaded automatically. If you only have a .pem certificate see this stackoverflow answer. You want to convert it to a DER encoded certificate with a .cer extension.
*
* As an alternative, you can store your .cer files in the www/certificates folder.
* @param enable {boolean} Set to true to enable
* @return {Promise<any>} returns a promise that will resolve on success, and reject on failure
*/
@Cordova()
static enableSSLPinning(enable: boolean): Promise<void> { return; }
/**
* Accept all SSL certificates. Or disabled accepting all certificates. Defaults to false.
* @param accept {boolean} Set to true to accept
* @return {Promise<any>} returns a promise that will resolve on success, and reject on failure
*/
@Cordova()
static acceptAllCerts(accept: boolean): Promise<void> { return; }
/**
* Whether or not to validate the domain name in the certificate. This defaults to true.
* @param validate {boolean} Set to true to validate
* @return {Promise<any>} returns a promise that will resolve on success, and reject on failure
*/
@Cordova()
static validateDomainName(validate: boolean): Promise<void> { return; }
/**
* Make a POST request
* @param url {string} The url to send the request to
* @param body {Object} The body of the request
* @param headers {Object} The headers to set for this request
* @return {Promise<HTTPResponse>} returns a promise that resolve on success, and reject on failure
*/
@Cordova()
static post(url: string, body: any, headers: any): Promise<HTTPResponse> { return; }
/**
*
* @param url {string} The url to send the request to
* @param parameters {Object} Parameters to send with the request
* @param headers {Object} The headers to set for this request
* @return {Promise<HTTPResponse>} returns a promise that resolve on success, and reject on failure
*/
@Cordova()
static get(url: string, parameters: any, headers: any): Promise<HTTPResponse> { return; }
/**
*
* @param url {string} The url to send the request to
* @param body {Object} The body of the request
* @param headers {Object} The headers to set for this request
* @param filePath {string} The local path of the file to upload
* @param fileParameter {string} The name of the parameter to pass the file along as
* @return {Promise<HTTPResponse>} returns a promise that resolve on success, and reject on failure
*/
@Cordova()
static uploadFile(url: string, body: any, headers: any, filePath: string, fileParameter: string): Promise<HTTPResponse> { return; }
/**
*
* @param url {string} The url to send the request to
* @param body {Object} The body of the request
* @param headers {Object} The headers to set for this request
* @param filePath {string} The path to donwload the file to, including the file name.
* @return {Promise<HTTPResponse>} returns a promise that resolve on success, and reject on failure
*/
@Cordova()
static downloadFile(url: string, body: any, headers: any, filePath: string): Promise<HTTPResponse> { return; }
}
export interface HTTPResponse {
/**
* The status number of the response
*/
status: number;
/**
* The data that is in the response. This property usually exists when a promise returned by a request method resolves.
*/
data?: any;
/**
* The headers of the response
*/
headers: any;
/**
* Error response from the server. This property usually exists when a promise returned by a request method rejects.
*/
error?: string;
}

View File

@@ -81,6 +81,9 @@ export interface TransitionOptions {
iosdelay?: number;
androiddelay?: number;
winphonedelay?: number;
fixedPixelsTops?: number;
fixedPixelsTop?: number;
fixedPixelsBottom?: number;
action?: string;
origin?: string;
href?: string;
}

View File

@@ -14,13 +14,19 @@ import { Observable } from 'rxjs/Observable';
* ```typescript
* import { OneSignal } from 'ionic-native';
*
* OneSignal.init('b2f7f966-d8cc-11e4-bed1-df8f05be55ba',
* {googleProjectNumber: '703322744261'})
* .subscribe(jsonData => {
* console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
* });
* OneSignal.startInit('b2f7f966-d8cc-11e4-bed1-df8f05be55ba', '703322744261');
*
* OneSignal.enableInAppAlertNotification(true);
*
* OneSignal.handleNotificationReceived().subscribe(() => {
* // do something when notification is received
* });
*
* OneSignal.handleNotificationOpened().subscribe(() => {
* // do something when a notification is opened
* });
*
* OneSignal.endInit();
* ```
*
*/
@@ -32,26 +38,71 @@ import { Observable } from 'rxjs/Observable';
export class OneSignal {
/**
* Only required method you need to call to setup OneSignal to receive push notifications. Call this from the `deviceready` event.
*
* @param {string} 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.
* @private
*/
@Cordova({ observable: true })
static init(appId: string,
options: {
googleProjectNumber: string,
autoRegister: boolean
}): Observable<any> { return; }
static OSInFocusDisplayOption = {
None: 0,
InAppAlert : 1,
Notification : 2
};
/**
* 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.
* Start the initialization process. Once you are done configuring OneSignal, call the endInit function.
*
* @param {string} appId Your AppId from your OneSignal app
* @param {string} googleProjectNumber The Google Project Number (which you can get from the Google Developer Portal) and the autoRegister option.
*/
@Cordova({ sync: true })
static registerForPushNotifications(): void { }
static startInit(appId: string, googleProjectNumber: string): any { return; }
/**
* Callback to run when a notification is received
* @return {Observable<any>}
*/
@Cordova({
observable: true
})
static handleNotificationReceived(): Observable<any> { return; }
/**
* Callback to run when a notification is opened
* @return {Observable<any>}
*/
@Cordova({
observable: true
})
static handleNotificationOpened(): Observable<any> { return; }
/**
*
* @param settings
*/
@Cordova({ sync: true })
static iOSSettings(settings: {
kOSSettingsKeyInAppLaunchURL: boolean;
kOSSettingsKeyAutoPrompt: boolean;
}): any { return; }
@Cordova({ sync: true })
static endInit(): any { return; }
/**
* 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; }
/**
* 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; }
/**
@@ -65,47 +116,36 @@ export class OneSignal {
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 {string} Pass a json object with key/value pairs like: {key: "value", key2: "value2"}
*/
* 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 {string} 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 {string} Key to remove.
*/
* 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 {string} 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 {Array<string>} Keys to remove.
*/
* Deletes tags that were previously set on a user with `sendTag` or `sendTags`.
*
* @param {Array<string>} 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; }
* 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 { }
/**
* Warning:
@@ -143,15 +183,6 @@ export class OneSignal {
@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 {boolean} 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.
@@ -168,68 +199,7 @@ export class OneSignal {
* @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; }
static postNotification(notificationObj: OneSignalNotification): Promise<any> { return; }
/**
* Prompts the user for location permission to allow geotagging based on the "Location radius" filter on the OneSignal dashboard.
@@ -237,6 +207,13 @@ export class OneSignal {
@Cordova({ sync: true })
static promptLocation(): void { }
/**
*
* @param email {string}
*/
@Cordova({ sync: true })
static syncHashedEmail(email: string): 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
@@ -252,3 +229,66 @@ export class OneSignal {
}): void { }
}
export interface OneSignalNotification {
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;
}

View File

@@ -6,22 +6,55 @@ import { Plugin, Cordova } from './plugin';
*
* @usage
* ```
* import {PayPal} from 'ionic-native';
* import {PayPal, PayPalPayment, PayPalConfiguration} from "ionic-native";
*
* PayPal.init({
* "PayPalEnvironmentProduction": "YOUR_PRODUCTION_CLIENT_ID",
"PayPalEnvironmentSandbox": "YOUR_SANDBOX_CLIENT_ID"
})
* .then(onSuccess)
* .catch(onError);
* "PayPalEnvironmentProduction": "YOUR_PRODUCTION_CLIENT_ID",
* "PayPalEnvironmentSandbox": "YOUR_SANDBOX_CLIENT_ID"
* }).then(() => {
* // Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
* PayPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
* // Only needed if you get an "Internal Service Error" after PayPal login!
* //payPalShippingAddressOption: 2 // PayPalShippingAddressOptionPayPal
* })).then(() => {
* let payment = new PayPalPayment('3.33', 'USD', 'Description', 'sale');
* PayPal.renderSinglePaymentUI(payment).then(() => {
* // Successfully paid
*
* // Example sandbox response
* //
* // {
* // "client": {
* // "environment": "sandbox",
* // "product_name": "PayPal iOS SDK",
* // "paypal_sdk_version": "2.16.0",
* // "platform": "iOS"
* // },
* // "response_type": "payment",
* // "response": {
* // "id": "PAY-1AB23456CD789012EF34GHIJ",
* // "state": "approved",
* // "create_time": "2016-10-03T13:33:33Z",
* // "intent": "sale"
* // }
* // }
* }, () => {
* // Error or render dialog closed without being successful
* });
* }, () => {
* // Error in configuration
* });
* }, () => {
* // Error in initialization, maybe PayPal isn't supported or something else
* });
* ```
* @interfaces
* PayPalEnvironment
* PayPalConfigurationOptions
* @classes
* PayPalPayment
* PayPalItem
* PayPalPaymentDetails
* PayPalConfigurationOptions
* PayPalShippingAddress
*/
@Plugin({
@@ -30,23 +63,33 @@ import { Plugin, Cordova } from './plugin';
repo: 'https://github.com/paypal/PayPal-Cordova-Plugin'
})
export class PayPal {
/**
* Retrieve the version of the PayPal iOS SDK library. Useful when contacting support.
*/
@Cordova()
static version(): Promise<string> {return; }
/**
* You must preconnect to PayPal to prepare the device for processing payments.
* This improves the user experience, by making the presentation of the
* UI faster. The preconnect is valid for a limited time, so
* the recommended time to preconnect is on page load.
*
* @param {String} environment available options are "PayPalEnvironmentNoNetwork", "PayPalEnvironmentProduction" and "PayPalEnvironmentSandbox"
* @param {PayPalConfiguration} configuration For Future Payments merchantName, merchantPrivacyPolicyURL and merchantUserAgreementURL must be set be set
* @param {PayPalEnvironment} clientIdsForEnvironments: set of client ids for environments
*/
@Cordova()
static init(environment: PayPalEnvironment, configuration?: PayPalConfiguration): Promise<any> {return; }
static init(clientIdsForEnvironments: PayPalEnvironment): Promise<any> {return; }
/**
* Retreive the version of PayPal iOS SDK Library.
*/
* You must preconnect to PayPal to prepare the device for processing payments.
* This improves the user experience, by making the presentation of the UI faster.
* The preconnect is valid for a limited time, so the recommended time to preconnect is on page load.
*
* @param {String} environment: available options are "PayPalEnvironmentNoNetwork", "PayPalEnvironmentProduction" and "PayPalEnvironmentSandbox"
* @param {PayPalConfiguration} configuration: PayPalConfiguration object, for Future Payments merchantName, merchantPrivacyPolicyURL and merchantUserAgreementURL must be set be set
**/
@Cordova()
static version(): Promise<string> {return; }
static prepareToRender(environment: string, configuration: PayPalConfiguration): Promise<any> {return; }
/**
* Start PayPal UI to collect payment from the user.
@@ -84,28 +127,25 @@ export class PayPal {
**/
@Cordova()
static renderProfileSharingUI(scopes: string[]): Promise<any> {return; }
}
export interface PayPalEnvironment {
PayPalEnvironmentProduction: string;
PayPalEnvironmentSandbox: string;
}
export declare var PayPalPayment: {
/**
* Convenience constructor.
* Returns a PayPalPayment with the specified amount, currency code, and short description.
* @param {String} amount: The amount of the payment.
* @param {String} currencyCode: The ISO 4217 currency for the payment.
* @param {String} shortDescription: A short description of the payment.
* @param {String} intent: "Sale" for an immediate payment.
*/
new(amount: string, currencyCode: string, shortDescription: string, intent: string): PayPalPayment;
};
/**
* @private
*/
export interface PayPalPayment {
export class PayPalPayment {
constructor(amount: string, currency: string, shortDescription: string, intent: string, details?: PayPalPaymentDetails) {
this.amount = amount;
this.currency = currency;
this.shortDescription = shortDescription;
this.intent = intent;
this.details = details;
}
/**
* The amount of the payment.
*/
@@ -113,7 +153,7 @@ export interface PayPalPayment {
/**
* The ISO 4217 currency for the payment.
*/
currencyCode: string;
currency: string;
/**
* A short description of the payment.
*/
@@ -126,7 +166,7 @@ export interface PayPalPayment {
* Optional Build Notation code ("BN code"), obtained from partnerprogram@paypal.com,
* for your tracking purposes.
*/
bnCode: string;
bnCode: string = 'PhoneGap_SP';
/**
* Optional invoice number, for your tracking purposes. (up to 256 characters)
*/
@@ -151,9 +191,34 @@ export interface PayPalPayment {
* Optional customer shipping address, if your app wishes to provide this to the SDK.
*/
shippingAddress: string;
/**
* Optional PayPalPaymentDetails object
*/
details: PayPalPaymentDetails;
}
export interface PayPalItem {
/**
* @private
*/
export class PayPalItem {
/**
* The PayPalItem class defines an optional itemization for a payment.
* @see https://developer.paypal.com/docs/api/#item-object for more details.
* @param {String} name: Name of the item. 127 characters max
* @param {Number} quantity: Number of units. 10 characters max.
* @param {String} price: Unit price for this item 10 characters max.
* May be negative for "coupon" etc
* @param {String} currency: ISO standard currency code.
* @param {String} sku: The stock keeping unit for this item. 50 characters max (optional)
*/
constructor(name: string, quantity: number, price: string, currency: string, sku: string) {
this.name = name;
this.quantity = quantity;
this.price = price;
this.currency = currency;
this.sku = sku;
}
/**
* Name of the item. 127 characters max
*/
@@ -176,21 +241,21 @@ export interface PayPalItem {
sku: string;
}
export declare var PayPalItem: {
/**
* @private
*/
export class PayPalPaymentDetails {
/**
* The PayPalItem class defines an optional itemization for a payment.
* @see https://developer.paypal.com/docs/api/#item-object for more details.
* @param {String} name: Name of the item. 127 characters max
* @param {Number} quantity: Number of units. 10 characters max.
* @param {String} price: Unit price for this item 10 characters max.
* May be negative for "coupon" etc
* @param {String} currency: ISO standard currency code.
* @param {String} sku: The stock keeping unit for this item. 50 characters max (optional)
* The PayPalPaymentDetails class defines optional amount details.
* @param {String} subtotal: Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
* @param {String} shipping: Amount charged for shipping. 10 characters max with support for 2 decimal places.
* @param {String} tax: Amount charged for tax. 10 characters max with support for 2 decimal places.
*/
new(name: string, quantity: number, price: string, currency: string, sku: string): PayPalItem;
};
export interface PayPalPaymentDetails {
constructor(subtotal: string, shipping: string, tax: string) {
this.subtotal = subtotal;
this.shipping = shipping;
this.tax = tax;
}
/**
* Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
*/
@@ -205,16 +270,6 @@ export interface PayPalPaymentDetails {
tax: string;
}
export declare var PayPalPaymentDetails: {
/**
* The PayPalPaymentDetails class defines optional amount details.
* @param {String} subtotal: Sub-total (amount) of items being paid for. 10 characters max with support for 2 decimal places.
* @param {String} shipping: Amount charged for shipping. 10 characters max with support for 2 decimal places.
* @param {String} tax: Amount charged for tax. 10 characters max with support for 2 decimal places.
*/
new(subtotal: string, shipping: string, tax: string): PayPalPaymentDetails;
};
/**
* @private
*/
@@ -238,11 +293,11 @@ export interface PayPalConfigurationOptions {
/**
* URL of your company's privacy policy, which will be offered to the user when requesting consent via a PayPalFuturePaymentViewController.
*/
merchantPrivacyPolicyUrl?: string;
merchantPrivacyPolicyURL?: string;
/**
* URL of your company's user agreement, which will be offered to the user when requesting consent via a PayPalFuturePaymentViewController.
*/
merchantUserAgreementUrl?: string;
merchantUserAgreementURL?: string;
/**
* If set to NO, the SDK will only support paying with PayPal, not with credit cards.
* This applies only to single payments (via PayPalPaymentViewController).
@@ -316,35 +371,47 @@ export interface PayPalConfigurationOptions {
/**
* @private
*/
export declare var PayPalConfiguration: {
export class PayPalConfiguration implements PayPalConfigurationOptions {
/**
* You use a PayPalConfiguration object to configure many aspects of how the SDK behaves.
* see defaults for options available
*/
new(options: PayPalConfigurationOptions): PayPalConfiguration;
};
constructor(options?: PayPalConfigurationOptions) {
export interface PayPalConfiguration {
defaultUserEmail: string;
defaultUserPhoneCountryCode: string;
defaultUserPhoneNumber: string;
merchantName: string;
merchantPrivacyPolicyUrl: string;
merchantUserAgreementUrl: string;
acceptCreditCards: boolean;
payPalShippingAddressOption: number;
rememberUser: boolean;
languageOrLocale: string;
disableBlurWhenBackgrounding: boolean;
presentingInPopover: boolean;
forceDefaultsInSandbox: boolean;
sandboxUserPassword: string;
sandboxUserPin: string;
let defaults: PayPalConfigurationOptions = {
defaultUserEmail: null,
defaultUserPhoneCountryCode: null,
defaultUserPhoneNumber: null,
merchantName: null,
merchantPrivacyPolicyURL: null,
merchantUserAgreementURL: null,
acceptCreditCards: true,
payPalShippingAddressOption: 0,
rememberUser: true,
languageOrLocale: null,
disableBlurWhenBackgrounding: false,
presentingInPopover: false,
forceDefaultsInSandbox: false,
sandboxUserPassword: null,
sandboxUserPin: null
};
if (options && typeof options === 'object') {
for (var i in options) {
if (defaults.hasOwnProperty(i)) {
defaults[i] = options[i];
}
}
}
return defaults;
}
}
/**
* @private
*/
export declare var PayPalShippingAddress: {
export class PayPalShippingAddress {
/**
* See the documentation of the individual properties for more detail.
* @param {String} recipientName: Name of the recipient at this address. 50 characters max.
@@ -355,10 +422,15 @@ export declare var PayPalShippingAddress: {
* @param {String} postalCode: ZIP code or equivalent is usually required for countries that have them. 20 characters max. Required in certain countries.
* @param {String} countryCode: 2-letter country code. 2 characters max.
*/
new(recipientName: string, line1: string, line2: string, city: string, state: string, postalCode: string, countryCode: string): PayPalShippingAddress;
};
export interface PayPalShippingAddress {
constructor(recipientName: string, line1: string, line2: string, city: string, state: string, postalCode: string, countryCode: string) {
this.recipientName = recipientName;
this.line1 = line1;
this.line2 = line2;
this.city = city;
this.state = state;
this.postalCode = postalCode;
this.countryCode = countryCode;
}
/**
* Name of the recipient at this address. 50 characters max.
*/

View File

@@ -41,6 +41,11 @@ export const cordovaWarn = function(pluginName: string, method: string) {
}
};
function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Function): any {
// ignore resolve and reject in case sync
if (opts.sync) {
return args;
}
// If the plugin method expects myMethod(success, err, options)
if (opts.callbackOrder === 'reverse') {
// Get those arguments in the order [resolve, reject, ...restOfArgs]
@@ -61,7 +66,12 @@ function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Func
args.push(obj);
} else if (typeof opts.successIndex !== 'undefined' || typeof opts.errorIndex !== 'undefined') {
// If we've specified a success/error index
args.splice(opts.successIndex, 0, resolve);
if (opts.successIndex > args.length) {
args[opts.successIndex] = resolve;
} else {
args.splice(opts.successIndex, 0, resolve);
}
// 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) {

View File

@@ -1,22 +1,79 @@
import { Plugin, CordovaInstance } from './plugin';
import { Observable } from 'rxjs/Observable';
import { InAppBrowserEvent } from './inappbrowser';
declare var cordova: any;
export interface ThemeableBrowserButton {
wwwImage?: string;
image?: string;
wwwImagePressed?: string;
imagePressed?: string;
wwwImageDensity?: number;
align?: string;
event?: string;
}
export interface ThemeableBrowserOptions {
statusbar?: { color: string; };
toolbar?: {
height?: number;
color?: string;
};
title?: { color: string; };
backButton?: ThemeableBrowserButton;
forwardButton?: ThemeableBrowserButton;
closeButton?: ThemeableBrowserButton;
customButtons?: ThemeableBrowserButton[];
menu?: {
image?: string;
imagePressed?: string;
title?: string;
cancel?: string;
align?: string;
items?: {
event: string;
label: string;
}[];
};
backButtonCanClose?: boolean;
// inAppBrowser options
location?: string;
hidden?: string;
clearcache?: string;
clearsessioncache?: string;
zoom?: string;
hardwareback?: string;
mediaPlaybackRequiresUserAction?: string;
shouldPauseOnSuspsend?: string;
closebuttoncaption?: string;
disallowoverscroll?: string;
enableViewportScale?: string;
allowInlineMediaPlayback?: string;
keyboardDisplayRequiresUserAction?: string;
suppressesIncrementalRendering?: string;
presentationstyle?: string;
transitionstyle?: string;
toolbarposition?: string;
fullscreen?: string;
}
/**
* @name ThemableBrowser
* @name ThemeableBrowser
* @description
* In-app browser that allows styling.
*
* @usage
* ```
* import { ThemableBrowser } from 'ionic-native';
* import { ThemeableBrowser } from 'ionic-native';
*
* // can add options from the original InAppBrowser in a JavaScript object form (not string)
* // This options object also takes additional parameters introduced by the ThemableBrowser plugin
* // This example only shows the additional parameters for ThemableBrowser
* // This options object also takes additional parameters introduced by the ThemeableBrowser plugin
* // This example only shows the additional parameters for ThemeableBrowser
* // Note that that `image` and `imagePressed` values refer to resources that are stored in your app
* let options = {
* statusbar: {
* statusbar: {
* color: '#ffffffff'
* },
* toolbar: {
@@ -83,11 +140,16 @@ declare var cordova: any;
pluginRef: 'cordova.ThemeableBrowser',
repo: 'https://github.com/initialxy/cordova-plugin-themeablebrowser'
})
export class ThemableBrowser {
export class ThemeableBrowser {
private _objectInstance: any;
constructor(url: string, target: string, styleOptions: ThemeableBrowserOptions) {
this._objectInstance = cordova.ThemableBrowser.open(arguments);
try {
this._objectInstance = cordova.ThemeableBrowser.open(url, target, styleOptions);
} catch (e) {
window.open(url);
console.warn('Native: ThemeableBrowser is not installed or you are running on a browser. Falling back to window.open, all instance methods will NOT work.');
}
}
/**
@@ -125,7 +187,7 @@ export class ThemableBrowser {
/**
* A method that allows you to listen to events happening in the browser.
* Available events are: `ThemableBrowserError`, `ThemableBrowserWarning`, `critical`, `loadfail`, `unexpected`, `undefined`
* Available events are: `ThemeableBrowserError`, `ThemeableBrowserWarning`, `critical`, `loadfail`, `unexpected`, `undefined`
* @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.
*/
@@ -138,57 +200,3 @@ export class ThemableBrowser {
}
export interface ThemeableBrowserOptions {
statusbar?: { color: string; };
toobar?: {
height?: number;
color?: string;
};
title?: { color: string; };
backButton?: ThemableBrowserButton;
forwardButton?: ThemableBrowserButton;
closeButton?: ThemableBrowserButton;
customButtons?: ThemableBrowserButton[];
menu?: {
image?: string;
imagePressed?: string;
title?: string;
cancel?: string;
align?: string;
items?: {
event: string;
label: string;
}[];
};
backButtonCanClose?: boolean;
// inAppBrowser options
location?: string;
hidden?: string;
clearcache?: string;
clearsessioncache?: string;
zoom?: string;
hardwareback?: string;
mediaPlaybackRequiresUserAction?: string;
shouldPauseOnSuspsend?: string;
closebuttoncaption?: string;
disallowoverscroll?: string;
enableViewportScale?: string;
allowInlineMediaPlayback?: string;
keyboardDisplayRequiresUserAction?: string;
suppressesIncrementalRendering?: string;
presentationstyle?: string;
transitionstyle?: string;
toolbarposition?: string;
fullscreen?: string;
}
export interface ThemableBrowserButton {
wwwImage?: string;
image?: string;
wwwImagePressed?: string;
imagePressed?: string;
wwwImageDensity?: number;
align?: string;
event?: string;
}

View File

@@ -36,7 +36,7 @@ describe('plugin', () => {
const spy = spyOn(window.plugins.test, 'syncMethod').and.callThrough();
const result = Test.syncMethod('foo');
expect(result).toEqual('syncResult');
expect(spy).toHaveBeenCalledWith('foo', undefined, undefined);
expect(spy).toHaveBeenCalledWith('foo');
});
@@ -138,4 +138,4 @@ describe('plugin', () => {
});
});
});