Compare commits
1 Commits
master
...
renovate/m
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6320a6a014 |
119
DEVELOPER.md
119
DEVELOPER.md
@ -6,44 +6,50 @@ This is a short guide on creating new plugin wrappers for Ionic Native.
|
||||
|
||||
First, let's start by creating a new plugin wrapper from template.
|
||||
|
||||
// Call this command, and replace PluginName with the name of the plugin you wish to add
|
||||
// Make sure to capitalize the first letter, or use CamelCase if necessary.
|
||||
```
|
||||
// Call this command, and replace PluginName with the name of the plugin you wish to add
|
||||
// Make sure to capitalize the first letter, or use CamelCase if necessary.
|
||||
|
||||
gulp plugin:create -n PluginName
|
||||
gulp plugin:create -n PluginName
|
||||
|
||||
// add -m flag to get a minimal template to start with
|
||||
gulp plugin:create -m -n PluginName
|
||||
// add -m flag to get a minimal template to start with
|
||||
gulp plugin:create -m -n PluginName
|
||||
```
|
||||
|
||||
Running the command above will create a new directory `src/@ionic-native/plugins/plugin-name/` with a single file in there: `index.ts`. This file is where all the plugin definitions should be.
|
||||
|
||||
Let's take a look at the existing plugin wrapper for Geolocation to see what goes into an Ionic Native plugin (comments have been removed for clarity):
|
||||
|
||||
@Plugin({
|
||||
plugin: 'cordova-plugin-geolocation',
|
||||
pluginRef: 'navigator.geolocation'
|
||||
})
|
||||
@Injectable()
|
||||
export class Geolocation {
|
||||
```
|
||||
@Plugin({
|
||||
plugin: 'cordova-plugin-geolocation',
|
||||
pluginRef: 'navigator.geolocation'
|
||||
})
|
||||
@Injectable()
|
||||
export class Geolocation {
|
||||
|
||||
@Cordova()
|
||||
getCurrentPosition(options?: GeolocationOptions): Promise<Geoposition> { return; }
|
||||
@Cordova()
|
||||
getCurrentPosition(options?: GeolocationOptions): Promise<Geoposition> { return; }
|
||||
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
observable: true,
|
||||
clearFunction: 'clearWatch'
|
||||
})
|
||||
watchPosition(options?: GeolocationOptions): Observable<Geoposition> { return; }
|
||||
}
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
observable: true,
|
||||
clearFunction: 'clearWatch'
|
||||
})
|
||||
watchPosition(options?: GeolocationOptions): Observable<Geoposition> { return; }
|
||||
}
|
||||
```
|
||||
|
||||
### The Plugin Class
|
||||
|
||||
First and foremost, we want to create a class representing our plugin, in this case Geolocation.
|
||||
|
||||
@Injectable()
|
||||
class Geolocation {
|
||||
```
|
||||
@Injectable()
|
||||
class Geolocation {
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Class Metadata
|
||||
|
||||
@ -51,14 +57,16 @@ Next, we need to specify some information about this plugin. Ionic Native is wri
|
||||
|
||||
For example, the `@Plugin` decorator adds information about the plugin to our Geolocation class:
|
||||
|
||||
@Plugin({
|
||||
plugin: 'cordova-plugin-geolocation',
|
||||
pluginRef: 'navigator.geolocation'
|
||||
})
|
||||
@Injectable()
|
||||
export class Geolocation {
|
||||
```
|
||||
@Plugin({
|
||||
plugin: 'cordova-plugin-geolocation',
|
||||
pluginRef: 'navigator.geolocation'
|
||||
})
|
||||
@Injectable()
|
||||
export class Geolocation {
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Here, `plugin` is the name of the plugin package on npm and used when calling `cordova plugin add`.
|
||||
|
||||
@ -70,8 +78,10 @@ Now all that's left is to add the plugin methods, in this case `getCurrentPositi
|
||||
|
||||
Let's take a look at `getCurrentPosition` first.
|
||||
|
||||
@Cordova()
|
||||
getCurrentPosition(options?: GeolocationOptions): Promise<Geoposition> { return }
|
||||
```
|
||||
@Cordova()
|
||||
getCurrentPosition(options?: GeolocationOptions): Promise<Geoposition> { return }
|
||||
```
|
||||
|
||||
It's just a stub. The `return` is only there to keep the TypeScript type-checker from complaining since we indicate that `getCurrentPosition` returns a `Promise<Geoposition>`.
|
||||
|
||||
@ -79,12 +89,14 @@ By default, the `@Cordova` decorator wraps the plugin callbacks in a Promise tha
|
||||
|
||||
Next, let's look at the `watchPosition` method.
|
||||
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
observable: true,
|
||||
clearFunction: 'clearWatch'
|
||||
})
|
||||
watchPosition(options?: GeolocationOptions): Observable<Geoposition> { return }
|
||||
```
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
observable: true,
|
||||
clearFunction: 'clearWatch'
|
||||
})
|
||||
watchPosition(options?: GeolocationOptions): Observable<Geoposition> { return }
|
||||
```
|
||||
|
||||
The `@Cordova` decorator has a few more options now.
|
||||
|
||||
@ -117,19 +129,12 @@ We have very precise rules over how our git commit messages can be formatted. Th
|
||||
Must be one of the following:
|
||||
|
||||
- **fix**: A bug fix
|
||||
|
||||
- **feat**: A new feature
|
||||
|
||||
- **docs**: Documentation only changes
|
||||
|
||||
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
|
||||
|
||||
- **refactor**: A code change that neither fixes a bug nor adds a feature
|
||||
|
||||
- **perf**: A code change that improves performance
|
||||
|
||||
- **test**: Adding missing tests
|
||||
|
||||
- **chore**: Changes to the build process or auxiliary tools and libraries such as documentation generation
|
||||
|
||||
#### Scope
|
||||
@ -141,11 +146,8 @@ The scope could be anything specifying place of the commit change. For example,
|
||||
The subject contains succinct description of the change:
|
||||
|
||||
- use the imperative, present tense: "change" not "changed" nor "changes"
|
||||
|
||||
- do not capitalize first letter
|
||||
|
||||
- do not place a period (.) at the end
|
||||
|
||||
- entire length of the commit message must not go over 50 characters
|
||||
|
||||
### Ionic Native Decorators
|
||||
@ -155,15 +157,10 @@ The subject contains succinct description of the change:
|
||||
A decorator to wrap the main plugin class, and any other classes that will use `@Cordova` or `@CordovaProperty` decorators. This decorator accepts the following configuration:
|
||||
|
||||
- _pluginName_: Plugin name, this should match the class name
|
||||
|
||||
- _plugin_: The plugin's NPM package, or Github URL if NPM is not available.
|
||||
|
||||
- _pluginRef_: The plugin object reference. Example: 'cordova.file'.
|
||||
|
||||
- _repo_: The plugin's Github Repository URL
|
||||
|
||||
- _install_: (optional) Install command. This is used in case a plugin has a custom install command (takes variables).
|
||||
|
||||
- _platforms_: An array of strings indicating the supported platforms.
|
||||
|
||||
#### Cordova
|
||||
@ -171,35 +168,20 @@ A decorator to wrap the main plugin class, and any other classes that will use `
|
||||
Checks if the plugin and the method are available before executing. By default, the decorator will wrap the callbacks of the function and return a Promise. This decorator takes the following configuration options:
|
||||
|
||||
- **observable**: set to true to return an Observable
|
||||
|
||||
- **methodName**: an optional name of the cordova plugins method name (if different from wrappers method name)
|
||||
|
||||
- **clearFunction**: an optional name of a method to clear the observable we returned
|
||||
|
||||
- **clearWithArgs**: This can be used if clearFunction is set. Set this to true to call the clearFunction with the same arguments used in the initial function.
|
||||
|
||||
- **sync**: set to true if the method should return the value as-is without wrapping with Observable/Promise
|
||||
|
||||
- **callbackOrder**: set to `reverse` if the success and error callbacks are the first two arguements of the method
|
||||
|
||||
- **callbackStyle**: set to `node` if the plugin has one callback with a node style (e.g: `function(err, result){}`), or set to `object` if the callbacks are part of an object
|
||||
|
||||
- **successName**: Success function property name. This must be set if callbackStyle is set to object.
|
||||
|
||||
- **errorName**: Error function property name. This must be set if callbackStyle is set to object.
|
||||
|
||||
- **successIndex**: Set a custom index for the success callback function. This doesn't work if callbackOrder or callbackStyle are set.
|
||||
|
||||
- **errorIndex**: Set a custom index for the error callback function. This doesn't work if callbackOrder or callbackStyle are set.
|
||||
|
||||
- **eventObservable**: set to true to return an observable that wraps an event listener
|
||||
|
||||
- **event**: Event name, this must be set if eventObservable is set to true
|
||||
|
||||
- **element**: Element to attach the event listener to, this is optional, defaults to `window`
|
||||
|
||||
- **otherPromise**: Set to true if the wrapped method returns a promise
|
||||
|
||||
- **platforms**: array of strings indicating supported platforms. Specify this if the supported platforms doesn't match the plugin's supported platforms.
|
||||
|
||||
Example:
|
||||
@ -228,7 +210,6 @@ someProperty: string;
|
||||
Checks if the plugin exists before performing a custom written method. By default, the method will return a promise that will reject with an error if the plugin is not available. This wrapper accepts two optional configurations:
|
||||
|
||||
- **observable**: set to true to return an empty Observable if the plugin isn't available
|
||||
|
||||
- **sync**: set to true to return nothing if the plugin isn't available
|
||||
|
||||
Example:
|
||||
|
23
README.md
23
README.md
@ -24,7 +24,7 @@ You also need to install the Awesome Cordova Plugins package for each plugin you
|
||||
|
||||
## Documentation
|
||||
|
||||
For the full Awesome Cordova Plugins documentation, please visit <https://ionicframework.com/docs/native/>.
|
||||
For the full Awesome Cordova Plugins documentation, please visit [https://ionicframework.com/docs/native/](https://ionicframework.com/docs/native/).
|
||||
|
||||
### Basic Usage
|
||||
|
||||
@ -144,13 +144,10 @@ document.addEventListener('deviceready', () => {
|
||||
|
||||
Awesome Cordova Plugins generates an AngularJS module in runtime and prepares a service for each plugin. To use the plugins in your AngularJS app:
|
||||
|
||||
1. Download the latest bundle from the [Github releases](https://github.com/danielsogl/awesome-cordova-plugins/releases) page.
|
||||
|
||||
2. Include it in `index.html` before your app's code.
|
||||
|
||||
3. Inject `ionic.native` module in your app.
|
||||
|
||||
4. Inject any plugin you would like to use with a `$cordova` prefix.
|
||||
1. Download the latest bundle from the [Github releases](https://github.com/danielsogl/awesome-cordova-plugins/releases) page.
|
||||
2. Include it in `index.html` before your app's code.
|
||||
3. Inject `ionic.native` module in your app.
|
||||
4. Inject any plugin you would like to use with a `$cordova` prefix.
|
||||
|
||||
```js
|
||||
angular.module('myApp', ['ionic.native']).controller('MyPageController', function ($cordovaCamera) {
|
||||
@ -169,11 +166,9 @@ angular.module('myApp', ['ionic.native']).controller('MyPageController', functio
|
||||
|
||||
To use Awesome Cordova Plugins in any other setup:
|
||||
|
||||
1. Download the latest bundle from the [Github releases](https://github.com/danielsogl/awesome-cordova-plugins/releases) page.
|
||||
|
||||
2. Include it in `index.html` before your app's code.
|
||||
|
||||
3. Access any plugin using the global `IonicNative` variable.
|
||||
1. Download the latest bundle from the [Github releases](https://github.com/danielsogl/awesome-cordova-plugins/releases) page.
|
||||
2. Include it in `index.html` before your app's code.
|
||||
3. Access any plugin using the global `IonicNative` variable.
|
||||
|
||||
```js
|
||||
document.addEventListener('deviceready', function () {
|
||||
@ -261,7 +256,7 @@ Spent way too long diagnosing an issue only to realize a plugin wasn't firing or
|
||||
|
||||
## Plugin Missing?
|
||||
|
||||
Let us know or submit a PR! Take a look at [the Developer Guide](https://github.com/danielsogl/awesome-cordova-plugins/blob/master/DEVELOPER.md) for more on how to contribute. ❤️
|
||||
Let us know or submit a PR! Take a look at [the Developer Guide](https://github.com/danielsogl/awesome-cordova-plugins/blob/master/DEVELOPER.md) for more on how to contribute. :heart:
|
||||
|
||||
# Credits
|
||||
|
||||
|
@ -31,7 +31,7 @@ gulp.task('plugin:create', () => {
|
||||
.pipe(replace('{{ pluginName }}', _.lowerFirst(pluginName)))
|
||||
.pipe(replace('{{ plugin-name }}', kebabCase))
|
||||
.pipe(rename('index.ts'))
|
||||
.pipe(gulp.dest('./src/@awesome-cordova-plugins/shuto/' + kebabCase));
|
||||
.pipe(gulp.dest('./src/@awesome-cordova-plugins/plugins/' + kebabCase));
|
||||
} else {
|
||||
console.log('Usage is: gulp plugin:create -n PluginName');
|
||||
}
|
||||
|
@ -27,10 +27,10 @@
|
||||
"tslib": "2.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular/common": "12.2.16",
|
||||
"@angular/compiler": "12.2.16",
|
||||
"@angular/compiler-cli": "12.2.16",
|
||||
"@angular/core": "12.2.16",
|
||||
"@angular/common": "16.0.0",
|
||||
"@angular/compiler": "16.0.0",
|
||||
"@angular/compiler-cli": "16.0.0",
|
||||
"@angular/core": "16.0.0",
|
||||
"@types/cordova": "11.0.0",
|
||||
"@types/fs-extra": "11.0.1",
|
||||
"@types/jest": "27.5.2",
|
||||
|
@ -18,7 +18,7 @@ export const ROOT = resolve(__dirname, '../../');
|
||||
// tslint:disable-next-line:no-var-requires
|
||||
export const TS_CONFIG = clone(require(resolve(ROOT, 'tsconfig.json')));
|
||||
export const COMPILER_OPTIONS = TS_CONFIG.compilerOptions;
|
||||
export const PLUGINS_ROOT = join(ROOT, 'src/@awesome-cordova-plugins/shuto/');
|
||||
export const PLUGINS_ROOT = join(ROOT, 'src/@awesome-cordova-plugins/plugins/');
|
||||
export const PLUGIN_PATHS = readdirSync(PLUGINS_ROOT).map((d) => join(PLUGINS_ROOT, d, 'index.ts'));
|
||||
|
||||
export function getDecorator(node: Node, index = 0): Decorator {
|
||||
|
@ -24,7 +24,7 @@ export const EMIT_PATH = resolve(ROOT, 'injectable-classes.json');
|
||||
export function extractInjectables() {
|
||||
return (ctx: TransformationContext) => {
|
||||
return (tsSourceFile) => {
|
||||
if (tsSourceFile.fileName.indexOf('src/@awesome-cordova-plugins/shuto') > -1) {
|
||||
if (tsSourceFile.fileName.indexOf('src/@awesome-cordova-plugins/plugins') > -1) {
|
||||
visitEachChild(
|
||||
tsSourceFile,
|
||||
(node) => {
|
||||
|
@ -71,7 +71,7 @@ function transformClasses(file: SourceFile, ctx: TransformationContext, ngcBuild
|
||||
export function pluginClassTransformer(ngcBuild?: boolean): TransformerFactory<SourceFile> {
|
||||
return (ctx: TransformationContext) => {
|
||||
return (tsSourceFile) => {
|
||||
if (tsSourceFile.fileName.indexOf('src/@awesome-cordova-plugins/shuto') > -1) {
|
||||
if (tsSourceFile.fileName.indexOf('src/@awesome-cordova-plugins/plugins') > -1) {
|
||||
return transformClasses(tsSourceFile, ctx, ngcBuild);
|
||||
}
|
||||
return tsSourceFile;
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"v2DocsDir": "docs/native",
|
||||
"pluginDir": "dist/@awesome-cordova-plugins/shuto"
|
||||
"pluginDir": "dist/@awesome-cordova-plugins/plugins"
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ module.exports = (currentVersion) => {
|
||||
readFilesProcessor.basePath = path.resolve(__dirname, '../../..');
|
||||
|
||||
readTypeScriptModules.basePath = path.resolve(__dirname, '../../..');
|
||||
readTypeScriptModules.sourceFiles = ['./src/@awesome-cordova-plugins/shuto/**/*.ts'];
|
||||
readTypeScriptModules.sourceFiles = ['./src/@awesome-cordova-plugins/plugins/**/*.ts'];
|
||||
})
|
||||
|
||||
// Configure file writing
|
||||
|
@ -51,7 +51,7 @@ module.exports = (currentVersion) => {
|
||||
readFilesProcessor.basePath = path.resolve(__dirname, '../../..');
|
||||
|
||||
readTypeScriptModules.basePath = path.resolve(path.resolve(__dirname, '../../..'));
|
||||
readTypeScriptModules.sourceFiles = ['./src/@awesome-cordova-plugins/shuto/**/*.ts'];
|
||||
readTypeScriptModules.sourceFiles = ['./src/@awesome-cordova-plugins/plugins/**/*.ts'];
|
||||
})
|
||||
|
||||
// Configure file writing
|
||||
|
@ -16,7 +16,7 @@ $ <@ if prop.install @><$ prop.install $><@ else @>ionic cordova plugin add <$ p
|
||||
$ npm install @awesome-cordova-plugins/<$ doc.npmId|replace('plugins/','') $>
|
||||
```
|
||||
|
||||
## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/shuto/<$ doc.fileInfo.relativePath|replace('/home/ubuntu/ionic-native/', '')|replace('//','/')|replace('index.ts','')|replace('src/@awesome-cordova-plugins/plugins/','') $>)
|
||||
## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/<$ doc.fileInfo.relativePath|replace('/home/ubuntu/ionic-native/', '')|replace('//','/')|replace('index.ts','')|replace('src/@awesome-cordova-plugins/plugins/','') $>)
|
||||
|
||||
Plugin Repo: [<$ prop.repo $>](<$ prop.repo $>)
|
||||
|
||||
|
@ -40,7 +40,7 @@ const PLUGIN_PEER_DEPENDENCIES = {
|
||||
|
||||
function getPackageJsonContent(name: string, peerDependencies = {}, dependencies = {}) {
|
||||
return merge(PACKAGE_JSON_BASE, {
|
||||
name: (name == 'core' ? '@awesome-cordova-plugins/' : '@shuto/') + name,
|
||||
name: '@awesome-cordova-plugins/' + name,
|
||||
dependencies,
|
||||
peerDependencies,
|
||||
version: VERSION,
|
||||
@ -50,9 +50,7 @@ function getPackageJsonContent(name: string, peerDependencies = {}, dependencies
|
||||
function writePackageJson(data: any, dir: string) {
|
||||
const filePath = resolve(dir, 'package.json');
|
||||
writeJSONSync(filePath, data);
|
||||
if (!data.name.startsWith('@awesome-cordova-plugins/')) {
|
||||
PACKAGES.push(dir);
|
||||
}
|
||||
PACKAGES.push(dir);
|
||||
}
|
||||
function writeNGXPackageJson(data: any, dir: string) {
|
||||
const filePath = resolve(dir, 'package.json');
|
||||
@ -69,7 +67,7 @@ function prepare() {
|
||||
PLUGIN_PATHS.forEach((pluginPath: string) => {
|
||||
const pluginName = pluginPath.split(/[\/\\]+/).slice(-2)[0];
|
||||
const packageJsonContents = getPackageJsonContent(pluginName, PLUGIN_PEER_DEPENDENCIES);
|
||||
const dir = resolve(DIST, 'shuto', pluginName);
|
||||
const dir = resolve(DIST, 'plugins', pluginName);
|
||||
const ngxDir = join(dir, 'ngx');
|
||||
writePackageJson(packageJsonContents, dir);
|
||||
writeNGXPackageJson(packageJsonContents, ngxDir);
|
||||
|
342
src/@awesome-cordova-plugins/plugins/abbyy-rtr/index.ts
Normal file
342
src/@awesome-cordova-plugins/plugins/abbyy-rtr/index.ts
Normal file
@ -0,0 +1,342 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CordovaCheck, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
declare const AbbyyRtrSdk: any;
|
||||
|
||||
/**
|
||||
* JSON object that you can pass as the options argument to change text
|
||||
* capture settings. All keys are optional. Omitting a key means that a
|
||||
* default setting will be used.
|
||||
*/
|
||||
export interface TextCaptureOptions {
|
||||
/**
|
||||
* The name of the license file. This file must be located in the
|
||||
* www/rtr_assets/ directory in your project.
|
||||
*/
|
||||
licenseFileName?: string;
|
||||
|
||||
/**
|
||||
* Recognition languages which can be selected by the user,
|
||||
* for example: ["English", "French", "German"]. Empty array
|
||||
* disables language selection.
|
||||
*/
|
||||
selectableRecognitionLanguages?: string[];
|
||||
|
||||
/**
|
||||
* Recognition language selected by default.
|
||||
*/
|
||||
recognitionLanguages?: string[];
|
||||
|
||||
/**
|
||||
* Width and height of the recognition area, separated by a
|
||||
* whitespace — for example: "0.8 0.3". The area of interest is
|
||||
* centered in the preview frame, its width and height are
|
||||
* relative to the preview frame size and should be in the [0.0, 1.0] range.
|
||||
*/
|
||||
areaOfInterest?: string;
|
||||
|
||||
/**
|
||||
* Whether to stop the plugin as soon as the result status is
|
||||
* "Stable" (see Result status). When enabled (true), the
|
||||
* recognition process can be stopped automatically. When
|
||||
* disabled (false), recognition can be stopped only manually
|
||||
* by user.
|
||||
*/
|
||||
stopWhenStable?: boolean;
|
||||
|
||||
/**
|
||||
* Show (true) or hide (false) the flashlight button in the text
|
||||
* capture dialog.
|
||||
*/
|
||||
isFlashlightVisible?: boolean;
|
||||
|
||||
/**
|
||||
* Show (true) or hide (false) the stop button in the text
|
||||
* capture dialog. When the user taps stop, RTR SDK returns
|
||||
* the latest recognition result.
|
||||
*/
|
||||
isStopButtonVisible?: boolean;
|
||||
|
||||
/**
|
||||
* Specify the orientation, possible values 'landscape' or 'portrait'.
|
||||
*/
|
||||
orientation?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON object that represents text recognition results.
|
||||
* The callback you implement should parse this object and show results to user.
|
||||
*/
|
||||
export interface TextCaptureResult {
|
||||
/**
|
||||
* An array of objects representing recognized lines of text.
|
||||
* These objects have the following keys:
|
||||
* · text (string): the recognized text.
|
||||
* · quadrangle (string): vertex coordinates of the bounding quadrangle,
|
||||
* a string of 8 integers separated with whitespaces ("x1 y1 ... x4 y4"),
|
||||
* goes clockwise starting from the bottom left.
|
||||
* · rect (string): position and size of the bounding rectangle,
|
||||
* a string of 4 integers separated with whitespaces ("x y width height").
|
||||
*/
|
||||
textLines: { text: string; quadrangle: string; rect?: string }[];
|
||||
|
||||
/**
|
||||
* Additional information. This object has the following keys:
|
||||
* · stabilityStatus (string): result stability status.
|
||||
* See Result status for details.
|
||||
* · userAction (string): the user's action which stopped the plugin,
|
||||
* if any. Can be "Manually Stopped" if the stop button has been used,
|
||||
* and "Canceled" if the user canceled processing. If the plugin has
|
||||
* stopped automatically, the userAction key is not present in resultInfo.
|
||||
* · frameSize (string): full size of the preview frame, a string
|
||||
* with 2 integers separated with a whitespace ("720 1280").
|
||||
* · recognitionLanguages (string array): languages used for recognition,
|
||||
* the array contains language identifiers (["English", "French", "German"]).
|
||||
*/
|
||||
resultInfo: {
|
||||
stabilityStatus: string;
|
||||
userAction: string;
|
||||
frameSize: string;
|
||||
recognitionLanguages: string[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Error details. This key is present only if an error occurs.
|
||||
* The value is an object which has a single key:
|
||||
* · description (string): human-readable error description.
|
||||
*/
|
||||
error?: {
|
||||
description: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON object that you can pass as the options argument to change data
|
||||
* capture settings. All keys are optional. Omitting a key means that a default
|
||||
* setting will be used, except the profile and customDataCaptureScenario
|
||||
* keys: you must specify either one of them, but not both at the same time.
|
||||
*/
|
||||
export interface DataCaptureOptions {
|
||||
/**
|
||||
* The predefined data capture profile to use, for example: "MRZ".
|
||||
* Note: For the list of supported documents, see Specifications — Data
|
||||
* Capture Profiles in the ABBYY Real-Time Recognition SDK 1 Developer's Guide.
|
||||
*/
|
||||
profile?: string;
|
||||
|
||||
/**
|
||||
* Custom data capture settings. This object has the following keys:
|
||||
* · name (string): the name of your custom data capture scenario, required.
|
||||
* · description (string): a more detailed description. This key is optional;
|
||||
* if not given, it will be assigned the same value as name.
|
||||
* · recognitionLanguages (string array): recognition languages to use.
|
||||
* Default is ["English"].
|
||||
* · fields (object array): describes data fields to capture. Each object
|
||||
* in this array has a single regEx key; its value is a string containing
|
||||
* the regular expression that should be matched when capturing a field.
|
||||
*/
|
||||
customDataCaptureScenario?: {
|
||||
name: string;
|
||||
description: string;
|
||||
recognitionLanguages: string[];
|
||||
fields: { regEx: string }[];
|
||||
};
|
||||
|
||||
/**
|
||||
* The name of the license file. This file must be located in the
|
||||
* www/rtr_assets/ directory in your project.
|
||||
*/
|
||||
licenseFileName?: string;
|
||||
|
||||
/**
|
||||
* Width and height of the recognition area, separated by a
|
||||
* whitespace — for example: "0.8 0.3". The area of interest is
|
||||
* centered in the preview frame, its width and height are
|
||||
* relative to the preview frame size and should be in the [0.0, 1.0] range.
|
||||
*/
|
||||
areaOfInterest?: string;
|
||||
|
||||
/**
|
||||
* Whether to stop the plugin as soon as the result status is
|
||||
* "Stable" (see Result status). When enabled (true), the
|
||||
* recognition process can be stopped automatically. When
|
||||
* disabled (false), recognition can be stopped only manually
|
||||
* by user.
|
||||
*/
|
||||
stopWhenStable?: boolean;
|
||||
|
||||
/**
|
||||
* Show (true) or hide (false) the flashlight button in the text
|
||||
* capture dialog.
|
||||
*/
|
||||
isFlashlightVisible?: boolean;
|
||||
|
||||
/**
|
||||
* Show (true) or hide (false) the stop button in the text
|
||||
* capture dialog. When the user taps stop, RTR SDK returns
|
||||
* the latest recognition result.
|
||||
*/
|
||||
isStopButtonVisible?: boolean;
|
||||
|
||||
/**
|
||||
* Specify the orientation, possible values 'landscape' or 'portrait'.
|
||||
*/
|
||||
orientation?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON object that represents data recognition results. The callback you
|
||||
* implement should parse this object and show results to user.
|
||||
*/
|
||||
export interface DataCaptureResult {
|
||||
/**
|
||||
* The data scheme which was applied during data capture.
|
||||
* The value is an object which has two keys:
|
||||
* · id (string): the internal scheme identifier.
|
||||
* · name (string): the scheme name.
|
||||
* If you had defined a custom data capture scenario in options, both the
|
||||
* id and name will be the same as the scenario name you specified. If
|
||||
* you selected a predefined profile, the id and name are specified by the
|
||||
* profile. If an error occurs during processing, the dataScheme key is not
|
||||
* present in the result.
|
||||
*/
|
||||
dataScheme?: {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Recognized data fields. Each object in the array represents a separate
|
||||
* data field. The data field objects have the following keys:
|
||||
* · id (string): the internal identifier of the field.
|
||||
* · name (string): the field name.
|
||||
* Similarly to dataScheme, in custom scenarios both id and name are the same
|
||||
* as the scenario name you specified (currently custom scenarios allow
|
||||
* only 1 recognized field).
|
||||
* · text (string): full text of the field.
|
||||
* · quadrangle (string): vertex coordinates of the bounding quadrangle, a
|
||||
* string of 8 integers separated with whitespaces ("x1 y1 ... x4 y4"),
|
||||
* goes clockwise starting from the bottom left.
|
||||
* · components (object array): an array of objects representing field
|
||||
* components, that is, the text fragments found on the image, which
|
||||
* constitute the field.
|
||||
* In the components array each element is an object with the following keys:
|
||||
* · text (string): text of this fragment.
|
||||
* · quadrangle (string): vertex coordinates of the bounding quadrangle of
|
||||
* this fragment, similar to the field's quadrangle.
|
||||
* · rect (string): position and size of the bounding rectangle, a string
|
||||
* of 4 integers separated with whitespaces ("x y width height").
|
||||
*/
|
||||
dataFields: {
|
||||
id: string;
|
||||
name: string;
|
||||
text: string;
|
||||
quadrangle: string;
|
||||
components: {
|
||||
text: string;
|
||||
quadrangle: string;
|
||||
rect: string;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Additional information. This object has the following keys:
|
||||
* · stabilityStatus (string): result stability status.
|
||||
* See Result status for details.
|
||||
* · userAction (string): the user's action which stopped the plugin,
|
||||
* if any. Can be "Manually Stopped" if the stop button has been used,
|
||||
* and "Canceled" if the user canceled processing. If the plugin has
|
||||
* stopped automatically, the userAction key is not present in resultInfo.
|
||||
* · frameSize (string): full size of the preview frame, a string
|
||||
* with 2 integers separated with a whitespace ("720 1280").
|
||||
*/
|
||||
resultInfo: {
|
||||
stabilityStatus: string;
|
||||
userAction: string;
|
||||
frameSize: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Error details. This key is present only if an error occurs.
|
||||
* The value is an object which has a single key:
|
||||
* · description (string): human-readable error description.
|
||||
*/
|
||||
error?: {
|
||||
description: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @name ABBYY Real-Time Recognition
|
||||
* @description
|
||||
* This plugin allows to use the Text Capture and Data Capture features of
|
||||
* ABBYY Real-Time Recognition SDK (RTR SDK) in apps.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AbbyyRTR } from '@awesome-cordova-plugins/abbyy-rtr/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private abbyyRTR: AbbyyRTR) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.abbyyRTR.startTextCapture(options)
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
*
|
||||
* this.abbyyRTR.startDataCapture(options)
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AbbyyRTR',
|
||||
plugin: 'cordova-plugin-abbyy-rtr-sdk',
|
||||
pluginRef: 'AbbyyRtrSdk',
|
||||
repo: 'https://github.com/abbyysdk/RTR-SDK.Cordova',
|
||||
install: 'ionic cordova plugin add cordova-plugin-abbyy-rtr-sdk',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AbbyyRTR extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Opens a modal dialog with controls for the Text Capture scenario.
|
||||
*
|
||||
* @param {TextCaptureOptions} options
|
||||
* @returns {Promise<TextCaptureResult>}
|
||||
*/
|
||||
@CordovaCheck()
|
||||
startTextCapture(options: TextCaptureOptions): Promise<TextCaptureResult> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
AbbyyRtrSdk.startTextCapture((result: DataCaptureResult) => {
|
||||
if (result.error) {
|
||||
reject(result);
|
||||
} else {
|
||||
resolve(result);
|
||||
}
|
||||
}, options);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a modal dialog with controls for the Data Capture scenario.
|
||||
*
|
||||
* @param {DataCaptureOptions} options
|
||||
* @returns {Promise<DataCaptureResult>}
|
||||
*/
|
||||
@CordovaCheck()
|
||||
startDataCapture(options: DataCaptureOptions): Promise<DataCaptureResult> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
AbbyyRtrSdk.startDataCapture((result: DataCaptureResult) => {
|
||||
if (result.error) {
|
||||
reject(result);
|
||||
} else {
|
||||
resolve(result);
|
||||
}
|
||||
}, options);
|
||||
});
|
||||
}
|
||||
}
|
138
src/@awesome-cordova-plugins/plugins/action-sheet/index.ts
Normal file
138
src/@awesome-cordova-plugins/plugins/action-sheet/index.ts
Normal file
@ -0,0 +1,138 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface ActionSheetOptions {
|
||||
/**
|
||||
* The labels for the buttons. Uses the index x
|
||||
*/
|
||||
buttonLabels: string[];
|
||||
|
||||
/**
|
||||
* The title for the actionsheet
|
||||
*/
|
||||
title?: string;
|
||||
|
||||
/**
|
||||
* The subtitle for the actionsheet (IOS only)
|
||||
*/
|
||||
subtitle?: string;
|
||||
|
||||
/**
|
||||
* Theme to be used on Android
|
||||
*/
|
||||
androidTheme?: 1 | 2 | 3 | 4 | 5;
|
||||
|
||||
/**
|
||||
* Enable a cancel on Android
|
||||
*/
|
||||
androidEnableCancelButton?: boolean;
|
||||
|
||||
/**
|
||||
* Enable a cancel on Windows Phone
|
||||
*/
|
||||
winphoneEnableCancelButton?: boolean;
|
||||
|
||||
/**
|
||||
* Add a cancel button with text
|
||||
*/
|
||||
addCancelButtonWithLabel?: string;
|
||||
|
||||
/**
|
||||
* Add a destructive button with text
|
||||
*/
|
||||
addDestructiveButtonWithLabel?: string;
|
||||
|
||||
/**
|
||||
* On an iPad, set the X,Y position
|
||||
*/
|
||||
position?: [number, number];
|
||||
|
||||
/**
|
||||
* Choose if destructive button will be the last
|
||||
*/
|
||||
destructiveButtonLast?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Action Sheet
|
||||
* @description
|
||||
* The ActionSheet plugin shows a native list of options the user can choose from.
|
||||
*
|
||||
* Requires Cordova plugin: `cordova-plugin-actionsheet`. For more info, please see the [ActionSheet plugin docs](https://github.com/EddyVerbruggen/cordova-plugin-actionsheet).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { ActionSheet, ActionSheetOptions } from '@awesome-cordova-plugins/action-sheet/ngx';
|
||||
*
|
||||
* constructor(private actionSheet: ActionSheet) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* let buttonLabels = ['Share via Facebook', 'Share via Twitter'];
|
||||
*
|
||||
* const options: ActionSheetOptions = {
|
||||
* title: 'What do you want with this image?',
|
||||
* subtitle: 'Choose an action',
|
||||
* buttonLabels: buttonLabels,
|
||||
* addCancelButtonWithLabel: 'Cancel',
|
||||
* addDestructiveButtonWithLabel: 'Delete',
|
||||
* androidTheme: this.actionSheet.ANDROID_THEMES.THEME_HOLO_DARK,
|
||||
* destructiveButtonLast: true
|
||||
* }
|
||||
*
|
||||
* this.actionSheet.show(options).then((buttonIndex: number) => {
|
||||
* console.log('Button pressed: ' + buttonIndex);
|
||||
* });
|
||||
* ```
|
||||
* @interfaces
|
||||
* ActionSheetOptions
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'ActionSheet',
|
||||
plugin: 'cordova-plugin-actionsheet',
|
||||
pluginRef: 'plugins.actionsheet',
|
||||
repo: 'https://github.com/EddyVerbruggen/cordova-plugin-actionsheet',
|
||||
platforms: ['Android', 'Browser', 'iOS', 'Windows', 'Windows Phone 8'],
|
||||
})
|
||||
@Injectable()
|
||||
export class ActionSheet extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Convenience property to select an Android theme value
|
||||
*/
|
||||
ANDROID_THEMES: {
|
||||
THEME_TRADITIONAL: number;
|
||||
THEME_HOLO_DARK: number;
|
||||
THEME_HOLO_LIGHT: number;
|
||||
THEME_DEVICE_DEFAULT_DARK: number;
|
||||
THEME_DEVICE_DEFAULT_LIGHT: number;
|
||||
} = {
|
||||
THEME_TRADITIONAL: 1,
|
||||
THEME_HOLO_DARK: 2,
|
||||
THEME_HOLO_LIGHT: 3,
|
||||
THEME_DEVICE_DEFAULT_DARK: 4,
|
||||
THEME_DEVICE_DEFAULT_LIGHT: 5,
|
||||
};
|
||||
|
||||
/**
|
||||
* Show a native ActionSheet component. See below for options.
|
||||
*
|
||||
* @param {ActionSheetOptions} [options] Options See table below
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with the index of the
|
||||
* button pressed (1 based, so 1, 2, 3, etc.)
|
||||
*/
|
||||
@Cordova()
|
||||
show(options?: ActionSheetOptions): Promise<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmatically hide the native ActionSheet
|
||||
*
|
||||
* @param {ActionSheetOptions} [options] Options See table below
|
||||
* @returns {Promise<any>} Returns a Promise that resolves when the actionsheet is closed
|
||||
*/
|
||||
@Cordova()
|
||||
hide(options?: ActionSheetOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
818
src/@awesome-cordova-plugins/plugins/adjust/index.ts
Normal file
818
src/@awesome-cordova-plugins/plugins/adjust/index.ts
Normal file
@ -0,0 +1,818 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export class AdjustEvent {
|
||||
private eventToken: string;
|
||||
private revenue: number;
|
||||
private currency: string;
|
||||
private transactionId: string;
|
||||
private callbackId: string;
|
||||
private callbackParameters: string[] = [];
|
||||
private partnerParameters: string[] = [];
|
||||
|
||||
constructor(eventToken: string) {
|
||||
this.eventToken = eventToken;
|
||||
}
|
||||
|
||||
setRevenue(revenue: number, currency: string): void {
|
||||
this.revenue = revenue;
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
addCallbackParameter(key: string, value: string): void {
|
||||
this.callbackParameters.push(key);
|
||||
this.callbackParameters.push(value);
|
||||
}
|
||||
|
||||
addPartnerParameter(key: string, value: string): void {
|
||||
this.partnerParameters.push(key);
|
||||
this.partnerParameters.push(value);
|
||||
}
|
||||
|
||||
setTransactionId(transactionId: string) {
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
|
||||
setCallbackId(callbackId: string) {
|
||||
this.callbackId = callbackId;
|
||||
}
|
||||
}
|
||||
|
||||
export class AdjustConfig {
|
||||
private appToken: string;
|
||||
private environment: AdjustEnvironment;
|
||||
private sdkPrefix: string;
|
||||
private delayStart = 0.0;
|
||||
private logLevel: AdjustLogLevel = null;
|
||||
private defaultTracker: string = null;
|
||||
private urlStrategy: AdjustUrlStrategy = null;
|
||||
private externalDeviceId: string = null;
|
||||
private sendInBackground: boolean = null;
|
||||
private shouldLaunchDeeplink: boolean = null;
|
||||
private eventBufferingEnabled: boolean = null;
|
||||
private userAgent: string = null;
|
||||
private isDeviceKnown: boolean = null;
|
||||
private needsCost: boolean = null;
|
||||
private secretId: number = null;
|
||||
private info1: number = null;
|
||||
private info2: number = null;
|
||||
private info3: number = null;
|
||||
private info4: number = null;
|
||||
private processName: string = null; // Android only
|
||||
private preinstallTrackingEnabled: boolean = null; // Android only
|
||||
private preinstallFilePath: string = null; // Android only
|
||||
private oaidReadingEnabled: boolean = null; // Android only
|
||||
private allowiAdInfoReading: boolean = null; // iOS only
|
||||
private allowIdfaReading: boolean = null; // iOS only
|
||||
private allowAdServicesInfoReading: boolean = null; // iOS only
|
||||
private coppaCompliantEnabled: boolean = null;
|
||||
private playStoreKidsAppEnabled: boolean = null; // Android only
|
||||
private linkMeEnabled: boolean = null; // iOS only
|
||||
|
||||
private attributionCallback: (attribution: AdjustAttribution) => void = null;
|
||||
private eventTrackingSucceededCallback: (event: AdjustEventSuccess) => void = null;
|
||||
private eventTrackingFailedCallback: (event: AdjustEventFailure) => void = null;
|
||||
private sessionTrackingSucceededCallback: (session: AdjustSessionSuccess) => void = null;
|
||||
private sessionTrackingFailedCallback: (session: AdjustSessionFailure) => void = null;
|
||||
private deferredDeeplinkCallback: (uri: string) => void = null;
|
||||
private conversionValueUpdatedCallback: (conversionValue: number) => void = null;
|
||||
|
||||
constructor(appToken: string, environment: AdjustEnvironment) {
|
||||
this.appToken = appToken;
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
setAppSecret(secretId: number, info1: number, info2: number, info3: number, info4: number): void {
|
||||
this.secretId = secretId;
|
||||
this.info1 = info1;
|
||||
this.info2 = info2;
|
||||
this.info3 = info3;
|
||||
this.info4 = info4;
|
||||
}
|
||||
|
||||
setDelayStart(delayStart: number) {
|
||||
this.delayStart = delayStart;
|
||||
}
|
||||
|
||||
setLogLevel(logLevel: AdjustLogLevel) {
|
||||
this.logLevel = logLevel;
|
||||
}
|
||||
|
||||
setDefaultTracker(defaultTracker: string) {
|
||||
this.defaultTracker = defaultTracker;
|
||||
}
|
||||
|
||||
setExternalDeviceId(externalDeviceId: string) {
|
||||
this.externalDeviceId = externalDeviceId;
|
||||
}
|
||||
|
||||
setUrlStrategy(urlStrategy: AdjustUrlStrategy) {
|
||||
this.urlStrategy = urlStrategy;
|
||||
}
|
||||
|
||||
setSendInBackground(sendInBackground: boolean) {
|
||||
this.sendInBackground = sendInBackground;
|
||||
}
|
||||
|
||||
setShouldLaunchDeeplink(shouldLaunchDeeplink: boolean) {
|
||||
this.shouldLaunchDeeplink = shouldLaunchDeeplink;
|
||||
}
|
||||
|
||||
setEventBufferingEnabled(eventBufferingEnabled: boolean) {
|
||||
this.eventBufferingEnabled = eventBufferingEnabled;
|
||||
}
|
||||
|
||||
setCoppaCompliantEnabled(coppaCompliantEnabled: boolean) {
|
||||
this.coppaCompliantEnabled = coppaCompliantEnabled;
|
||||
}
|
||||
|
||||
setPlayStoreKidsAppEnabled(playStoreKidsAppEnabled: boolean) {
|
||||
this.playStoreKidsAppEnabled = playStoreKidsAppEnabled;
|
||||
}
|
||||
|
||||
setUserAgent(userAgent: string) {
|
||||
this.userAgent = userAgent;
|
||||
}
|
||||
|
||||
setDeviceKnown(isDeviceKnown: boolean) {
|
||||
this.isDeviceKnown = isDeviceKnown;
|
||||
}
|
||||
|
||||
setNeedsCost(needsCost: boolean) {
|
||||
this.needsCost = needsCost;
|
||||
}
|
||||
|
||||
setProcessName(processName: string) {
|
||||
this.processName = processName;
|
||||
}
|
||||
|
||||
setPreinstallTrackingEnabled(preinstallTrackingEnabled: boolean) {
|
||||
this.preinstallTrackingEnabled = preinstallTrackingEnabled;
|
||||
}
|
||||
|
||||
setPreinstallFilePath(preinstallFilePath: string) {
|
||||
this.preinstallFilePath = preinstallFilePath;
|
||||
}
|
||||
|
||||
setOaidReadingEnabled(enableOaidReading: boolean) {
|
||||
this.oaidReadingEnabled = enableOaidReading;
|
||||
}
|
||||
|
||||
setAllowiAdInfoReading(allowiAdInfoReading: boolean) {
|
||||
this.allowiAdInfoReading = allowiAdInfoReading;
|
||||
}
|
||||
|
||||
setAllowIdfaReading(allowIdfaReading: boolean) {
|
||||
this.allowIdfaReading = allowIdfaReading;
|
||||
}
|
||||
|
||||
setAllowAdServicesInfoReading(allowAdServicesInfoReading: boolean) {
|
||||
this.allowAdServicesInfoReading = allowAdServicesInfoReading;
|
||||
}
|
||||
|
||||
setLinkMeEnabled(linkMeEnabled: boolean) {
|
||||
this.linkMeEnabled = linkMeEnabled;
|
||||
}
|
||||
|
||||
setAttributionCallbackListener(attributionCallback: (attribution: AdjustAttribution) => void) {
|
||||
this.attributionCallback = attributionCallback;
|
||||
}
|
||||
|
||||
setEventTrackingSucceededCallbackListener(eventTrackingSucceededCallback: (event: AdjustEventSuccess) => void) {
|
||||
this.eventTrackingSucceededCallback = eventTrackingSucceededCallback;
|
||||
}
|
||||
|
||||
setEventTrackingFailedCallbackListener(eventTrackingFailedCallback: (event: AdjustEventFailure) => void) {
|
||||
this.eventTrackingFailedCallback = eventTrackingFailedCallback;
|
||||
}
|
||||
|
||||
setSessionTrackingSucceededCallbackListener(
|
||||
sessionTrackingSucceededCallback: (session: AdjustSessionSuccess) => void
|
||||
) {
|
||||
this.sessionTrackingSucceededCallback = sessionTrackingSucceededCallback;
|
||||
}
|
||||
|
||||
setSessionTrackingFailedCallbackListener(sessionTrackingFailedCallback: (session: AdjustSessionFailure) => void) {
|
||||
this.sessionTrackingFailedCallback = sessionTrackingFailedCallback;
|
||||
}
|
||||
|
||||
setDeferredDeeplinkCallbackListener(deferredDeeplinkCallback: (uri: string) => void) {
|
||||
this.deferredDeeplinkCallback = deferredDeeplinkCallback;
|
||||
}
|
||||
|
||||
setConversionValueUpdatedCallbackListener(conversionValueUpdatedCallback: (conversionValue: number) => void) {
|
||||
this.conversionValueUpdatedCallback = conversionValueUpdatedCallback;
|
||||
}
|
||||
|
||||
private getAttributionCallback() {
|
||||
return this.attributionCallback;
|
||||
}
|
||||
|
||||
private getEventTrackingSucceededCallback() {
|
||||
return this.eventTrackingSucceededCallback;
|
||||
}
|
||||
|
||||
private getEventTrackingFailedCallback() {
|
||||
return this.eventTrackingFailedCallback;
|
||||
}
|
||||
|
||||
private getSessionTrackingSucceededCallback() {
|
||||
return this.sessionTrackingSucceededCallback;
|
||||
}
|
||||
|
||||
private getSessionTrackingFailedCallback() {
|
||||
return this.sessionTrackingFailedCallback;
|
||||
}
|
||||
|
||||
private getDeferredDeeplinkCallback() {
|
||||
return this.deferredDeeplinkCallback;
|
||||
}
|
||||
|
||||
private getConversionValueUpdatedCallback() {
|
||||
return this.conversionValueUpdatedCallback;
|
||||
}
|
||||
|
||||
private hasAttributionListener() {
|
||||
return this.attributionCallback !== null;
|
||||
}
|
||||
|
||||
private hasEventTrackingSucceededListener() {
|
||||
return this.eventTrackingSucceededCallback !== null;
|
||||
}
|
||||
|
||||
private hasEventTrackingFailedListener() {
|
||||
return this.eventTrackingFailedCallback !== null;
|
||||
}
|
||||
|
||||
private hasSessionTrackingSucceededListener() {
|
||||
return this.sessionTrackingSucceededCallback !== null;
|
||||
}
|
||||
|
||||
private hasSessionTrackingFailedListener() {
|
||||
return this.sessionTrackingFailedCallback !== null;
|
||||
}
|
||||
|
||||
private hasDeferredDeeplinkCallbackListener() {
|
||||
return this.deferredDeeplinkCallback !== null;
|
||||
}
|
||||
|
||||
private hasConversionValueUpdatedCallbackListener() {
|
||||
return this.conversionValueUpdatedCallback !== null;
|
||||
}
|
||||
}
|
||||
|
||||
export class AdjustAppStoreSubscription {
|
||||
private price: string;
|
||||
private currency: string;
|
||||
private transactionId: string;
|
||||
private receipt: string;
|
||||
private transactionDate: string;
|
||||
private salesRegion: string;
|
||||
private callbackParameters: string[] = [];
|
||||
private partnerParameters: string[] = [];
|
||||
|
||||
constructor(price: string, currency: string, transactionId: string, receipt: string) {
|
||||
this.price = price;
|
||||
this.currency = currency;
|
||||
this.transactionId = transactionId;
|
||||
this.receipt = receipt;
|
||||
}
|
||||
|
||||
setTransactionDate(transactionDate: string): void {
|
||||
this.transactionDate = transactionDate;
|
||||
}
|
||||
|
||||
setSalesRegion(salesRegion: string): void {
|
||||
this.salesRegion = salesRegion;
|
||||
}
|
||||
|
||||
addCallbackParameter(key: string, value: string): void {
|
||||
this.callbackParameters.push(key);
|
||||
this.callbackParameters.push(value);
|
||||
}
|
||||
|
||||
addPartnerParameter(key: string, value: string): void {
|
||||
this.partnerParameters.push(key);
|
||||
this.partnerParameters.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
export class AdjustPlayStoreSubscription {
|
||||
private price: string;
|
||||
private currency: string;
|
||||
private sku: string;
|
||||
private orderId: string;
|
||||
private signature: string;
|
||||
private purchaseToken: string;
|
||||
private purchaseTime: string;
|
||||
private callbackParameters: string[] = [];
|
||||
private partnerParameters: string[] = [];
|
||||
|
||||
constructor(price: string, currency: string, sku: string, orderId: string, signature: string, purchaseToken: string) {
|
||||
this.price = price;
|
||||
this.currency = currency;
|
||||
this.sku = sku;
|
||||
this.orderId = orderId;
|
||||
this.signature = signature;
|
||||
this.purchaseToken = purchaseToken;
|
||||
}
|
||||
|
||||
setPurchaseTime(purchaseTime: string): void {
|
||||
this.purchaseTime = purchaseTime;
|
||||
}
|
||||
|
||||
addCallbackParameter(key: string, value: string): void {
|
||||
this.callbackParameters.push(key);
|
||||
this.callbackParameters.push(value);
|
||||
}
|
||||
|
||||
addPartnerParameter(key: string, value: string): void {
|
||||
this.partnerParameters.push(key);
|
||||
this.partnerParameters.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
export class AdjustThirdPartySharing {
|
||||
private isEnabled: boolean;
|
||||
private granularOptions: string[] = [];
|
||||
private partnerSharingSettings: any[] = [];
|
||||
|
||||
constructor(isEnabled: boolean) {
|
||||
this.isEnabled = isEnabled;
|
||||
}
|
||||
|
||||
addGranularOption(partnerName: string, key: string, value: string): void {
|
||||
this.granularOptions.push(partnerName);
|
||||
this.granularOptions.push(key);
|
||||
this.granularOptions.push(value);
|
||||
}
|
||||
|
||||
addPartnerSharingSetting(partnerName: string, key: string, value: boolean): void {
|
||||
this.partnerSharingSettings.push(partnerName);
|
||||
this.partnerSharingSettings.push(key);
|
||||
this.partnerSharingSettings.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
export class AdjustAdRevenue {
|
||||
private source: string;
|
||||
private revenue: number;
|
||||
private currency: string;
|
||||
private adImpressionsCount: number;
|
||||
private adRevenueNetwork: string;
|
||||
private adRevenueUnit: string;
|
||||
private adRevenuePlacement: string;
|
||||
private callbackParameters: string[] = [];
|
||||
private partnerParameters: string[] = [];
|
||||
|
||||
constructor(source: string) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
setRevenue(revenue: number, currency: string): void {
|
||||
this.revenue = revenue;
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
addCallbackParameter(key: string, value: string): void {
|
||||
this.callbackParameters.push(key);
|
||||
this.callbackParameters.push(value);
|
||||
}
|
||||
|
||||
addPartnerParameter(key: string, value: string): void {
|
||||
this.partnerParameters.push(key);
|
||||
this.partnerParameters.push(value);
|
||||
}
|
||||
|
||||
setAdImpressionsCount(adImpressionsCount: number) {
|
||||
this.adImpressionsCount = adImpressionsCount;
|
||||
}
|
||||
|
||||
setAdRevenueNetwork(adRevenueNetwork: string) {
|
||||
this.adRevenueNetwork = adRevenueNetwork;
|
||||
}
|
||||
|
||||
setAdRevenueUnit(adRevenueUnit: string) {
|
||||
this.adRevenueUnit = adRevenueUnit;
|
||||
}
|
||||
|
||||
setAdRevenuePlacement(adRevenuePlacement: string) {
|
||||
this.adRevenuePlacement = adRevenuePlacement;
|
||||
}
|
||||
}
|
||||
|
||||
export interface AdjustAttribution {
|
||||
trackerToken: string;
|
||||
trackerName: string;
|
||||
network: string;
|
||||
campaign: string;
|
||||
adgroup: string;
|
||||
creative: string;
|
||||
clickLabel: string;
|
||||
adid: string;
|
||||
costType: string;
|
||||
costAmount: string;
|
||||
costCurrency: string;
|
||||
fbInstallReferrer: string; // Android only
|
||||
}
|
||||
|
||||
export interface AdjustSessionSuccess {
|
||||
message: string;
|
||||
timestamp: string;
|
||||
adid: string;
|
||||
jsonResponse: string;
|
||||
}
|
||||
|
||||
export interface AdjustSessionFailure {
|
||||
message: string;
|
||||
timestamp: string;
|
||||
adid: string;
|
||||
willRetry: boolean;
|
||||
jsonResponse: string;
|
||||
}
|
||||
|
||||
export interface AdjustEventSuccess {
|
||||
message: string;
|
||||
timestamp: string;
|
||||
adid: string;
|
||||
eventToken: string;
|
||||
callbackId: string;
|
||||
jsonResponse: string;
|
||||
}
|
||||
|
||||
export interface AdjustEventFailure {
|
||||
message: string;
|
||||
timestamp: string;
|
||||
adid: string;
|
||||
eventToken: string;
|
||||
willRetry: boolean;
|
||||
callbackId: string;
|
||||
jsonResponse: string;
|
||||
}
|
||||
|
||||
export enum AdjustEnvironment {
|
||||
Sandbox = 'sandbox',
|
||||
Production = 'production',
|
||||
}
|
||||
|
||||
export enum AdjustLogLevel {
|
||||
Verbose = 'VERBOSE',
|
||||
Debug = 'DEBUG',
|
||||
Info = 'INFO',
|
||||
Warn = 'WARN',
|
||||
Error = 'ERROR',
|
||||
Assert = 'ASSERT',
|
||||
Suppress = 'SUPPRESS',
|
||||
}
|
||||
|
||||
export enum AdjustUrlStrategy {
|
||||
India = 'india',
|
||||
China = 'china',
|
||||
DataResidencyEU = 'data-residency-eu',
|
||||
DataResidencyTR = 'data-residency-tr',
|
||||
DataResidencyUS = 'data-residency-us',
|
||||
}
|
||||
|
||||
export enum AdjustAdRevenueSource {
|
||||
AdRevenueSourceAppLovinMAX = 'applovin_max_sdk',
|
||||
AdRevenueSourceMopub = 'mopub',
|
||||
AdRevenueSourceAdMob = 'admob_sdk',
|
||||
AdRevenueSourceIronSource = 'ironsource_sdk',
|
||||
AdRevenueSourceAdMost = "admost_sdk",
|
||||
AdRevenueSourceUnity = "unity_sdk",
|
||||
AdRevenueSourceHeliumChartboost = "helium_chartboost_sdk",
|
||||
AdRevenueSourcePublisher = "publisher_sdk",
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Adjust
|
||||
* @description
|
||||
* This is the Ionic Cordova SDK of Adjust™. You can read more about Adjust™ at adjust.com.
|
||||
*
|
||||
* Requires Cordova plugin: `com.adjust.sdk`. For more info, please see the [Adjust Cordova SDK](https://github.com/adjust/cordova_sdk)
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Adjust, AdjustConfig, AdjustEnvironment } from '@awesome-cordova-plugins/adjust/ngx';
|
||||
*
|
||||
* constructor(private adjust: Adjust) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* const config = new AdjustConfig('APP-TOKEN-HERE', AdjustEnvironment.Sandbox);
|
||||
* config.logLevel = AdjustLogLevel.Verbose;
|
||||
* // Set other config properties.
|
||||
* adjust.create(config);
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* AdjustAttribution
|
||||
* AdjustSessionSuccess
|
||||
* AdjustSessionFailure
|
||||
* AdjustEventSuccess
|
||||
* AdjustEventFailure
|
||||
* @classes
|
||||
* AdjustEvent
|
||||
* AdjustConfig
|
||||
* AdjustAppStoreSubscription
|
||||
* AdjustPlayStoreSubscription
|
||||
* AdjustThirdPartySharing
|
||||
* AdjustAdReenue
|
||||
* @enums
|
||||
* AdjustEnvironment
|
||||
* AdjustLogLevel
|
||||
* AdjustUrlStrategy
|
||||
* AdjustAdRevenueSource
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Adjust',
|
||||
plugin: 'com.adjust.sdk',
|
||||
pluginRef: 'Adjust',
|
||||
repo: 'https://github.com/adjust/cordova_sdk',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Adjust extends AwesomeCordovaNativePlugin {
|
||||
|
||||
/**
|
||||
* This method initializes Adjust SDK
|
||||
*
|
||||
* @param {AdjustConig} config Adjust config object used as starting options
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
create(config: AdjustConfig): void {}
|
||||
|
||||
/**
|
||||
* This method tracks an event
|
||||
*
|
||||
* @param {AdjustEvent} event Adjust event object to be tracked
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
trackEvent(event: AdjustEvent): void {}
|
||||
|
||||
/**
|
||||
* This method tracks App Store subscription
|
||||
*
|
||||
* @param {AdjustAppStoreSubscription} subscription Adjust App Store subscription object to be tracked
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
trackAppStoreSubscription(subscription: AdjustAppStoreSubscription): void {}
|
||||
|
||||
/**
|
||||
* This method tracks Play Store subscription
|
||||
*
|
||||
* @param {AdjustPlayStoreSubscription} subscription Adjust Play Store subscription object to be tracked
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
trackPlayStoreSubscription(subscription: AdjustPlayStoreSubscription): void {}
|
||||
|
||||
/**
|
||||
* This method tracks third party sharing choice
|
||||
*
|
||||
* @param {AdjustThirdPartySharing} thirdPartySharing Adjust third party sharing object to be tracked
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
trackThirdPartySharing(thirdPartySharing: AdjustThirdPartySharing): void {}
|
||||
|
||||
/**
|
||||
* This method tracks ad revenue data
|
||||
*
|
||||
* @param {AdjustAdRevenueSource} source Ad revenue source
|
||||
* @param {string} payload Ad revenue JSON string payload
|
||||
*/
|
||||
trackAdRevenue(source: AdjustAdRevenueSource, payload: string): void;
|
||||
|
||||
/**
|
||||
* This method tracks ad revenue data
|
||||
*
|
||||
* @param {AdjustAdRevenue} adRevenue Adjust ad revenue object
|
||||
*/
|
||||
trackAdRevenue(adRevenue: AdjustAdRevenue): void;
|
||||
|
||||
// And typescript hides this, so the client will be able call only methods above
|
||||
@Cordova({ sync: true })
|
||||
trackAdRevenue(sourceOrAdRevenue: any, payload?: any): void {}
|
||||
|
||||
/**
|
||||
* This method tracks measurement consent choice
|
||||
*
|
||||
* @param {boolean} measurementConsent set measurement consent to true or false
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
trackMeasurementConsent(measurementConsent: boolean): void {}
|
||||
|
||||
/**
|
||||
* This method sets offline mode on or off
|
||||
*
|
||||
* @param {boolean} enabled set to true for offline mode on
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setOfflineMode(enabled: boolean): void {}
|
||||
|
||||
/**
|
||||
* By making this call, the Adjust SDK will try to find if there is any new attribution info inside of the deep link and if any, it will be sent to the Adjust backend.
|
||||
*
|
||||
* @param {string} url URL of the deeplink
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
appWillOpenUrl(url: string): void {}
|
||||
|
||||
/**
|
||||
* You can disable/enable the Adjust SDK from tracking by invoking this method
|
||||
*
|
||||
* @param {boolean} enabled set to false to disable SDK
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setEnabled(enabled: boolean): void {}
|
||||
|
||||
/**
|
||||
* To send us the push notification token, add the following call to Adjust whenever you get your token in the app or when it gets updated.
|
||||
* Push tokens are used for Audience Builder and client callbacks, and they are required for the upcoming uninstall tracking feature.
|
||||
*
|
||||
* @param {string} pushToken push token value
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setPushToken(pushToken: string): void {}
|
||||
|
||||
/**
|
||||
* Check if the Adjust SDK is currently enabled by calling this function
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
isEnabled(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* In accordance with article 17 of the EU's General Data Protection Regulation (GDPR), you can notify Adjust when a user has exercised their right to be forgotten.
|
||||
* Calling the following method will instruct the Adjust SDK to communicate the user's choice to be forgotten to the Adjust backend
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
gdprForgetMe(): void {}
|
||||
|
||||
/**
|
||||
* You can now notify Adjust when a user has exercised their right to stop sharing their data with partners for marketing purposes, but has allowed it to be shared for statistics purposes.
|
||||
* Calling the following method will instruct the Adjust SDK to communicate the user's choice to disable data sharing to the Adjust backend
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
disableThirdPartySharing(): void {}
|
||||
|
||||
/**
|
||||
* Function used to get Google AdId
|
||||
*
|
||||
* @returns {Promise<string>} Returns a promise with google AdId value
|
||||
*/
|
||||
@Cordova()
|
||||
getGoogleAdId(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you need to obtain the Amazon Advertising ID, you can make a call to this function.
|
||||
*
|
||||
* @returns {Promise<string>} Returns a promise with anazib adv. ID
|
||||
*/
|
||||
@Cordova()
|
||||
getAmazonAdId(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* To obtain the IDFA, call this function
|
||||
*
|
||||
* @returns {Promise<string>} Returns a promise with IDFA string value
|
||||
*/
|
||||
@Cordova()
|
||||
getIdfa(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* For every device with your app installed on it, the Adjust backend generates a unique Adjust device identifier (adid).
|
||||
* In order to obtain this identifier, call this function
|
||||
*
|
||||
* @returns {Promise<string>} Returns a promise with adid value
|
||||
*/
|
||||
@Cordova()
|
||||
getAdid(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instruct to Adjust SDK to check current state of att_status
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
checkForNewAttStatus(): void {}
|
||||
|
||||
/**
|
||||
* If you want to access information about a user's current attribution whenever you need it, you can make a call to this function
|
||||
*
|
||||
* @returns {Promise<AdjustAttribution>} Returns a promise with AdjustAttribution object
|
||||
*/
|
||||
@Cordova()
|
||||
getAttribution(): Promise<AdjustAttribution> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the information about version of the SDK used
|
||||
*
|
||||
* @returns {Promise<string>} Returns a promise with sdk version information
|
||||
*/
|
||||
@Cordova()
|
||||
getSdkVersion(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to add session callback parameters
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
addSessionCallbackParameter(key: string, value: string): void {}
|
||||
|
||||
/**
|
||||
* Remove a specific session callback parameter by passing the desiring key to this method
|
||||
*
|
||||
* @param key key
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
removeSessionCallbackParameter(key: string): void {}
|
||||
|
||||
/**
|
||||
* If all keys and values from the session callback parameters have to be removed, call this method
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
resetSessionCallbackParameters(): void {}
|
||||
|
||||
/**
|
||||
* Method used to add session partner parameters
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
addSessionPartnerParameter(key: string, value: string): void {}
|
||||
|
||||
/**
|
||||
* Remove a specific session partner parameter by passing the desiring key to this method
|
||||
*
|
||||
* @param key key
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
removeSessionPartnerParameter(key: string): void {}
|
||||
|
||||
/**
|
||||
* If all keys and values from the session partner parameters have to be removed, call this method
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
resetSessionPartnerParameters(): void {}
|
||||
|
||||
/**
|
||||
* This method call will make the Adjust SDK send the initial install session and any events created, if they were not sent after delay start was set and it's delay expired.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendFirstPackages(): void {}
|
||||
|
||||
/**
|
||||
* Request Adjust SDK to show pop up dialog for asking user's consent to be tracked.
|
||||
* In order to do this, call this function
|
||||
*
|
||||
* @returns {Promise<number>} Returns a promise with user's consent value
|
||||
*/
|
||||
@Cordova()
|
||||
requestTrackingAuthorizationWithCompletionHandler(): Promise<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* You can update SKAdNetwork conversion value with calling this method
|
||||
*
|
||||
* @param {number} conversionValue conversion value for the user
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
updateConversionValue(conversionValue: number): void {}
|
||||
|
||||
/**
|
||||
* To obtain the app tracking authorization status in iOS, call this function
|
||||
*
|
||||
* @returns {Promise<number>} Returns a promise with app tracking authorization status
|
||||
*/
|
||||
@Cordova()
|
||||
getAppTrackingAuthorizationStatus(): Promise<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* To obtain the last deep link which has opened your iOS app, call this function
|
||||
*
|
||||
* @returns {Promise<string>} Returns a promise with iOS deep link string value
|
||||
*/
|
||||
@Cordova()
|
||||
getLastDeeplink(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
}
|
101
src/@awesome-cordova-plugins/plugins/admob-plus/index.ts
Normal file
101
src/@awesome-cordova-plugins/plugins/admob-plus/index.ts
Normal file
@ -0,0 +1,101 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable, fromEvent } from 'rxjs';
|
||||
|
||||
export type AdUnitIDOption =
|
||||
| string
|
||||
| {
|
||||
android: string;
|
||||
ios: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* @name AdMob Plus
|
||||
* @description
|
||||
* AdMob Plus is the successor of cordova-plugin-admob-free, which provides a cleaner API and build with modern tools.
|
||||
*/
|
||||
@Plugin({
|
||||
plugin: 'cordova-admob-plus',
|
||||
pluginName: 'AdMob',
|
||||
pluginRef: 'admob.banner',
|
||||
repo: 'https://github.com/admob-plus/admob-plus',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
export class Banner {
|
||||
@Cordova({ otherPromise: true })
|
||||
hide(): Promise<any> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@Cordova({ otherPromise: true })
|
||||
show(opts: { id?: AdUnitIDOption }): Promise<any> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
@Plugin({
|
||||
plugin: 'cordova-admob-plus',
|
||||
pluginName: 'AdMob',
|
||||
pluginRef: 'admob.interstitial',
|
||||
})
|
||||
export class Interstitial {
|
||||
@Cordova({ otherPromise: true })
|
||||
load(opts: { id?: AdUnitIDOption }): Promise<any> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@Cordova({ otherPromise: true })
|
||||
show(): Promise<any> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
@Plugin({
|
||||
plugin: 'cordova-admob-plus',
|
||||
pluginName: 'AdMob',
|
||||
pluginRef: 'admob.rewardVideo',
|
||||
})
|
||||
export class RewardVideo {
|
||||
@Cordova({ otherPromise: true })
|
||||
load(opts: { id?: AdUnitIDOption }): Promise<any> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@Cordova({ otherPromise: true })
|
||||
show(): Promise<any> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
@Plugin({
|
||||
platforms: ['Android', 'iOS'],
|
||||
plugin: 'cordova-admob-plus',
|
||||
pluginName: 'AdMob',
|
||||
pluginRef: 'admob',
|
||||
repo: 'https://github.com/admob-plus/admob-plus',
|
||||
})
|
||||
@Injectable()
|
||||
export class AdMob extends AwesomeCordovaNativePlugin {
|
||||
banner = new Banner();
|
||||
interstitial = new Interstitial();
|
||||
rewardVideo = new RewardVideo();
|
||||
|
||||
@Cordova({ otherPromise: true })
|
||||
setAppMuted(value: boolean): Promise<any> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@Cordova({ otherPromise: true })
|
||||
setAppVolume(value: number): Promise<any> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@Cordova({ sync: true })
|
||||
setDevMode(value: boolean): void {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
on(event: string): Observable<any> {
|
||||
return fromEvent(document, event);
|
||||
}
|
||||
}
|
347
src/@awesome-cordova-plugins/plugins/admob-pro/index.ts
Normal file
347
src/@awesome-cordova-plugins/plugins/admob-pro/index.ts
Normal file
@ -0,0 +1,347 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export type AdSize =
|
||||
| 'SMART_BANNER'
|
||||
| 'BANNER'
|
||||
| 'MEDIUM_RECTANGLE'
|
||||
| 'FULL_BANNER'
|
||||
| 'LEADERBOARD'
|
||||
| 'SKYSCRAPER'
|
||||
| 'CUSTOM';
|
||||
|
||||
export interface AdMobOptions {
|
||||
/**
|
||||
* Banner ad ID
|
||||
*/
|
||||
adId?: string;
|
||||
|
||||
/**
|
||||
* Banner Ad Size, defaults to `SMART_BANNER`. IT can be: `SMART_BANNER`, `BANNER`, `MEDIUM_RECTANGLE`, `FULL_BANNER`, `LEADERBOARD`, `SKYSCRAPER`, or `CUSTOM`
|
||||
*/
|
||||
adSize?: AdSize;
|
||||
|
||||
/**
|
||||
* Banner width, valid when `adSize` is set to `CUSTOM`
|
||||
*/
|
||||
width?: number;
|
||||
|
||||
/**
|
||||
* Banner height, valid when `adSize` is set to `CUSTOM`
|
||||
*/
|
||||
height?: number;
|
||||
|
||||
/**
|
||||
* Allow banner to overlap webview, or else it will push webview up or down to avoid overlap. Defaults to false.
|
||||
*/
|
||||
overlap?: boolean;
|
||||
|
||||
/**
|
||||
* Position of banner ad. Defaults to `TOP_CENTER`. You can use the `AdMobPro.AD_POSITION` property to select other values.
|
||||
*/
|
||||
position?: number;
|
||||
|
||||
/**
|
||||
* X in pixels. Valid when `position` is set to `POS_XY`
|
||||
*/
|
||||
x?: number;
|
||||
|
||||
/**
|
||||
* Y in pixels. Valid when `position` is set to `POS_XY`
|
||||
*/
|
||||
y?: number;
|
||||
|
||||
/**
|
||||
* Set to true to receive test ad for testing purposes
|
||||
*/
|
||||
isTesting?: boolean;
|
||||
|
||||
/**
|
||||
* Auto show interstitial ad when loaded. Set to false if hope to control the show timing with prepareInterstitial/showInterstitial
|
||||
*/
|
||||
autoShow?: boolean;
|
||||
|
||||
/**
|
||||
* Re-create the banner on web view orientation change (not screen orientation), or else just move the banner. Default:true.
|
||||
*/
|
||||
orientationRenew?: boolean;
|
||||
|
||||
/**
|
||||
* Set extra color style for Ad
|
||||
*/
|
||||
adExtras?: AdExtras;
|
||||
|
||||
/**
|
||||
* License key for the plugin
|
||||
*/
|
||||
license?: any;
|
||||
|
||||
/**
|
||||
* Set offset
|
||||
*/
|
||||
offsetTopBar?: boolean;
|
||||
}
|
||||
|
||||
export interface AdExtras {
|
||||
color_bg: string;
|
||||
|
||||
color_bg_top: string;
|
||||
|
||||
color_border: string;
|
||||
|
||||
color_link: string;
|
||||
|
||||
color_text: string;
|
||||
|
||||
color_url: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @paid
|
||||
* @name AdMob Pro
|
||||
* @capacitorincompatible true
|
||||
* @description
|
||||
* Plugin for Google Ads, including AdMob / DFP (DoubleClick for publisher) and mediations to other Ad networks.
|
||||
*
|
||||
* IMPORTANT NOTICE: this plugin takes a percentage out of your earnings if you profit more than $1,000. Read more about this on the plugin's repo. For a completely free alternative, see [AdMobPro Free](../admob-free).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AdMobPro } from '@awesome-cordova-plugins/admob-pro/ngx';
|
||||
* import { Platform } from '@ionic/angular';
|
||||
*
|
||||
* constructor(private admob: AdMobPro, private platform: Platform ) { }
|
||||
*
|
||||
* ionViewDidLoad() {
|
||||
* this.admob.onAdDismiss()
|
||||
* .subscribe(() => { console.log('User dismissed ad'); });
|
||||
* }
|
||||
*
|
||||
* onClick() {
|
||||
* let adId;
|
||||
* if(this.platform.is('android')) {
|
||||
* adId = 'YOUR_ADID_ANDROID';
|
||||
* } else if (this.platform.is('ios')) {
|
||||
* adId = 'YOUR_ADID_IOS';
|
||||
* }
|
||||
* this.admob.prepareInterstitial({adId: adId})
|
||||
* .then(() => { this.admob.showInterstitial(); });
|
||||
* }
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* AdMobOptions
|
||||
* AdExtras
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AdMob Pro',
|
||||
plugin: 'cordova-plugin-admobpro',
|
||||
pluginRef: 'AdMob',
|
||||
repo: 'https://github.com/floatinghotpot/cordova-admob-pro',
|
||||
platforms: ['Android', 'iOS', 'Windows Phone 8'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AdMobPro extends AwesomeCordovaNativePlugin {
|
||||
AD_POSITION: {
|
||||
NO_CHANGE: number;
|
||||
TOP_LEFT: number;
|
||||
TOP_CENTER: number;
|
||||
TOP_RIGHT: number;
|
||||
LEFT: number;
|
||||
CENTER: number;
|
||||
RIGHT: number;
|
||||
BOTTOM_LEFT: number;
|
||||
BOTTOM_CENTER: number;
|
||||
BOTTOM_RIGHT: number;
|
||||
POS_XY: number;
|
||||
} = {
|
||||
NO_CHANGE: 0,
|
||||
TOP_LEFT: 1,
|
||||
TOP_CENTER: 2,
|
||||
TOP_RIGHT: 3,
|
||||
LEFT: 4,
|
||||
CENTER: 5,
|
||||
RIGHT: 6,
|
||||
BOTTOM_LEFT: 7,
|
||||
BOTTOM_CENTER: 8,
|
||||
BOTTOM_RIGHT: 9,
|
||||
POS_XY: 10,
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a banner
|
||||
*
|
||||
* @param {string | AdMobOptions} adIdOrOptions Ad ID or Options
|
||||
* @returns {Promise<any>} Returns a Promise that resolves when the banner is created
|
||||
*/
|
||||
@Cordova()
|
||||
createBanner(adIdOrOptions: string | AdMobOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the banner, remove it from screen.
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
removeBanner(): void {}
|
||||
|
||||
/**
|
||||
* Show banner at position
|
||||
*
|
||||
* @param {number} position Position. Use `AdMobPro.AD_POSITION` to set values.
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
showBanner(position: number): void {}
|
||||
|
||||
/**
|
||||
* Show banner at custom position
|
||||
*
|
||||
* @param {number} x Offset from screen left.
|
||||
* @param {number} y Offset from screen top.
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
showBannerAtXY(x: number, y: number): void {}
|
||||
|
||||
/**
|
||||
* Hide the banner, remove it from screen, but can show it later
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
hideBanner(): void {}
|
||||
|
||||
/**
|
||||
* Prepare interstitial banner
|
||||
*
|
||||
* @param {string | AdMobOptions} adIdOrOptions Ad ID or Options
|
||||
* @returns {Promise<any>} Returns a Promise that resolves when interstitial is prepared
|
||||
*/
|
||||
@Cordova()
|
||||
prepareInterstitial(adIdOrOptions: string | AdMobOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show interstitial ad when it's ready
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
showInterstitial(): void {}
|
||||
|
||||
/**
|
||||
* Prepare a reward video ad
|
||||
*
|
||||
* @param {string | AdMobOptions} adIdOrOptions Ad ID or Options
|
||||
* @returns {Promise<any>} Returns a Promise that resolves when the ad is prepared
|
||||
*/
|
||||
@Cordova()
|
||||
prepareRewardVideoAd(adIdOrOptions: string | AdMobOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a reward video ad
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
showRewardVideoAd(): void {}
|
||||
|
||||
/**
|
||||
* Sets the values for configuration and targeting
|
||||
*
|
||||
* @param {AdMobOptions} options Options
|
||||
* @returns {Promise<any>} Returns a Promise that resolves when the options have been set
|
||||
*/
|
||||
@Cordova()
|
||||
setOptions(options: AdMobOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user ad settings
|
||||
*
|
||||
* @returns {Promise<any>} Returns a promise that resolves with the ad settings
|
||||
*/
|
||||
@Cordova()
|
||||
getAdSettings(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered when failed to receive Ad
|
||||
*
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'onAdFailLoad',
|
||||
element: 'document',
|
||||
})
|
||||
onAdFailLoad(): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered when Ad received
|
||||
*
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'onAdLoaded',
|
||||
element: 'document',
|
||||
})
|
||||
onAdLoaded(): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered when Ad will be showed on screen
|
||||
*
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'onAdPresent',
|
||||
element: 'document',
|
||||
})
|
||||
onAdPresent(): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered when user click the Ad, and will jump out of your App
|
||||
*
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'onAdLeaveApp',
|
||||
element: 'document',
|
||||
})
|
||||
onAdLeaveApp(): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered when dismiss the Ad and back to your App
|
||||
*
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'onAdDismiss',
|
||||
element: 'document',
|
||||
})
|
||||
onAdDismiss(): Observable<any> {
|
||||
return;
|
||||
}
|
||||
}
|
588
src/@awesome-cordova-plugins/plugins/admob/index.ts
Normal file
588
src/@awesome-cordova-plugins/plugins/admob/index.ts
Normal file
@ -0,0 +1,588 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, CordovaProperty, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface AdmobBaseOptions {
|
||||
/**
|
||||
* (Optional) Your interstitial id code from your AdMob account. Defaults to bannerAdId
|
||||
*/
|
||||
interstitialAdId?: string;
|
||||
|
||||
/**
|
||||
* (Optional) Indicates whether to put banner ads at top when set to true or at bottom when set to false. Defaults to false
|
||||
*/
|
||||
bannerAtTop?: boolean;
|
||||
|
||||
/**
|
||||
* (Optional) Set to true to receive test ads (do not test with real ads as your account may be banned). Defaults to false
|
||||
*/
|
||||
isTesting?: boolean;
|
||||
|
||||
/**
|
||||
* (Optional) Auto show banner ads when available (onAdLoaded event is called). Defaults to true
|
||||
*/
|
||||
autoShowBanner?: boolean;
|
||||
|
||||
/**
|
||||
* (Optional) Auto show interstitial ads when available (onAdLoaded event is called). Defaults to true
|
||||
*/
|
||||
autoShowInterstitial?: boolean;
|
||||
}
|
||||
export interface AdmobOptions extends AdmobBaseOptions {
|
||||
/**
|
||||
* Your banner id code from your AdMob account (https://support.google.com/admob/answer/7356431?hl=en)
|
||||
*/
|
||||
bannerAdId: string;
|
||||
|
||||
/**
|
||||
* Deprecated. Now is only used in web. It will be used as a bannerAdId only in case it is undefined.
|
||||
*/
|
||||
publisherId?: string;
|
||||
|
||||
/**
|
||||
* (Optional) Your tappx id for iOS apps. If Admob is configured, it is also used to backfill your lost inventory (when there are no Admob ads available)
|
||||
*/
|
||||
tappxIdiOS?: string;
|
||||
|
||||
/**
|
||||
* (Optional) Your tappx id for Android apps. Admob is configured, it is also used to backfill your lost inventory when there are no Admob ads available
|
||||
*/
|
||||
tappxIdAndroid?: string;
|
||||
|
||||
/**
|
||||
* AdMob rewarded id (https://support.google.com/admob/answer/7356431?hl=en)
|
||||
*/
|
||||
rewardedAdId?: string;
|
||||
|
||||
/**
|
||||
* (Optional) Auto show rewarded ads when available (onAdLoaded event is called). Defaults to true
|
||||
*/
|
||||
autoShowRewarded?: boolean;
|
||||
|
||||
/**
|
||||
* (Optional) If any of tappxId is present, it tells the percentage of traffic diverted to tappx. Defaults to 0.5 (50% of the traffic will be requested to Tappx)
|
||||
*/
|
||||
tappxShare?: number;
|
||||
|
||||
/**
|
||||
* (Optional) Indicates the size of banner ads
|
||||
*/
|
||||
adSize?: string;
|
||||
|
||||
/**
|
||||
* (Optional) Allow banner overlap webview. Default false
|
||||
*/
|
||||
overlap?: boolean;
|
||||
|
||||
/**
|
||||
* (Optional) Set to true to avoid ios7 status bar overlap. Default false
|
||||
*/
|
||||
offsetStatusBar?: boolean;
|
||||
|
||||
/**
|
||||
* (Options) A JSON object with additional {key: value} pairs
|
||||
*/
|
||||
adExtras?: any;
|
||||
}
|
||||
|
||||
export interface AdmobWebOptions extends AdmobBaseOptions {
|
||||
/**
|
||||
* (Required) AdSense Publisher ID (https://support.google.com/adsense/answer/105516)
|
||||
*/
|
||||
publisherId: string;
|
||||
|
||||
/**
|
||||
* (Required) Your ad slot code from your AdSense account. Only for browser platform https://support.google.com/adsense/answer/105516
|
||||
*/
|
||||
adSlot: string;
|
||||
|
||||
/**
|
||||
* (Optional) Indicates if show a close button on interstitial browser ads. Only for browser platform
|
||||
*/
|
||||
interstitialShowCloseButton?: boolean;
|
||||
|
||||
/**
|
||||
* (Optional) Indicates the number of seconds that the interstitial ad waits before show the close button. Only for browser platform
|
||||
*/
|
||||
secondsToShowCloseButton?: number;
|
||||
|
||||
/**
|
||||
* (Optional) Indicates the number of seconds that the interstitial ad waits before close the ad. Only for browser platform
|
||||
*/
|
||||
secondsToCloseInterstitial?: number;
|
||||
}
|
||||
|
||||
export interface AdMobEvent {
|
||||
/**
|
||||
* (Optional) AdMob supported type as seen in AD_TYPE
|
||||
*/
|
||||
adType?: string;
|
||||
|
||||
/**
|
||||
* (Optional) AdMob error code
|
||||
*/
|
||||
error?: number;
|
||||
|
||||
/**
|
||||
* (Optional) AdMob error reason
|
||||
*/
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name AdMob
|
||||
* @description
|
||||
* Most complete Admob plugin with support for [Tappx](http://www.tappx.com/?h=dec334d63287772de859bdb4e977fce6) ads.
|
||||
* Monetize your apps and games with AdMob ads, using latest Google AdMob SDK. With this plugin you can show AdMob ads easily!
|
||||
*
|
||||
* Supports:**
|
||||
* - Banner ads (top and bottom)
|
||||
* - Interstitial ads
|
||||
* - Rewarded ads
|
||||
* - [Tappx](http://www.tappx.com/?h=dec334d63287772de859bdb4e977fce6) ads
|
||||
* @usage
|
||||
* Note:** No ads will be served on apps with package name `io.ionic.starter`. This is the default package name for new `ionic` apps. Make sure to rename the package name so ads can be displayed.
|
||||
* ```typescript
|
||||
* import { Admob, AdmobOptions } from '@awesome-cordova-plugins/admob';
|
||||
*
|
||||
*
|
||||
* constructor(private admob: Admob) {
|
||||
* // Admob options config
|
||||
* const admobOptions: AdmobOptions = {
|
||||
* bannerAdId: 'XXX-XXXX-XXXX',
|
||||
* interstitialAdId: 'XXX-XXXX-XXXX',
|
||||
* rewardedAdId: 'XXX-XXXX-XXXX',
|
||||
* isTesting: true,
|
||||
* autoShowBanner: false,
|
||||
* autoShowInterstitial: false,
|
||||
* autoShowRewarded: false,
|
||||
* adSize: this.admob.AD_SIZE.BANNER
|
||||
* };
|
||||
*
|
||||
* // Set admob options
|
||||
* this.admob.setOptions(admobOptions)
|
||||
* .then(() => console.log('Admob options have been successfully set'))
|
||||
* .catch(err => console.error('Error setting admob options:', err));
|
||||
* }
|
||||
*
|
||||
*
|
||||
*
|
||||
* // (Optionally) Load banner ad, in order to have it ready to show
|
||||
* this.admob.createBannerView()
|
||||
* .then(() => console.log('Banner ad loaded'))
|
||||
* .catch(err => console.error('Error loading banner ad:', err));
|
||||
*
|
||||
*
|
||||
* // Show banner ad (createBannerView must be called before and onAdLoaded() event raised)
|
||||
* this.admob.onAdLoaded().subscribe((ad) => {
|
||||
* if (ad.adType === this.admob.AD_TYPE.BANNER) {
|
||||
* this.admob.showBannerAd()
|
||||
* .then(() => console.log('Banner ad shown'))
|
||||
* .catch(err => console.error('Error showing banner ad:', err));
|
||||
* }
|
||||
* });
|
||||
*
|
||||
*
|
||||
* // Hide banner ad, but do not destroy it, so it can be shown later on
|
||||
* // See destroyBannerView in order to hide and destroy banner ad
|
||||
* this.admob.showBannerAd(false)
|
||||
* .then(() => console.log('Banner ad hidden'))
|
||||
* .catch(err => console.error('Error hiding banner ad:', err));
|
||||
*
|
||||
*
|
||||
*
|
||||
* // Request an interstitial ad, in order to be shown later on
|
||||
* // It is possible to autoshow it via options parameter, see docs
|
||||
* this.admob.requestInterstitialAd()
|
||||
* .then(() => console.log('Interstitial ad loaded'))
|
||||
* .catch(err => console.error('Error loading interstitial ad:', err));
|
||||
*
|
||||
*
|
||||
* // Show an interstitial ad (requestInterstitialAd must be called before)
|
||||
* this.admob.onAdLoaded().subscribe((ad) => {
|
||||
* if (ad.adType === this.admob.AD_TYPE.INTERSTITIAL) {
|
||||
* this.admob.showInterstitialAd()
|
||||
* .then(() => console.log('Interstitial ad shown'))
|
||||
* .catch(err => console.error('Error showing interstitial ad:', err));
|
||||
* }
|
||||
* });
|
||||
*
|
||||
*
|
||||
* // Request a rewarded ad
|
||||
* this.admob.requestRewardedAd()
|
||||
* .then(() => console.log('Rewarded ad loaded'))
|
||||
* .catch(err => console.error('Error loading rewarded ad:', err));
|
||||
*
|
||||
*
|
||||
* // Show rewarded ad (requestRewardedAd must be called before)
|
||||
* this.admob.onAdLoaded().subscribe((ad) => {
|
||||
* if (ad.adType === this.admob.AD_TYPE.REWARDED) {
|
||||
* this.admob.showRewardedAd()
|
||||
* .then(() => console.log('Rewarded ad shown'))
|
||||
* .catch(err => console.error('Error showing rewarded ad:', err));
|
||||
* }
|
||||
* });
|
||||
*
|
||||
*
|
||||
* // Hide and destroy banner or interstitial ad
|
||||
* this.admob.destroyBannerView()
|
||||
* .then(() => console.log('Banner or interstitial ad destroyed'))
|
||||
* .catch(err => console.error('Error destroying banner or interstitial ad:', err));
|
||||
*
|
||||
*
|
||||
*
|
||||
* // On Ad loaded event
|
||||
* this.admob.onAdLoaded().subscribe((ad) => {
|
||||
* if (ad.adType === this.admob.AD_TYPE.BANNER) {
|
||||
* console.log('Banner ad is loaded');
|
||||
* this.admob.showBannerAd();
|
||||
* } else if (ad.adType === this.admob.AD_TYPE.INTERSTITIAL) {
|
||||
* console.log('Interstitial ad is loaded');
|
||||
* this.admob.showInterstitialAd();
|
||||
* } else if (ad.adType === this.admob.AD_TYPE.REWARDED) {
|
||||
* console.log('Rewarded ad is loaded');
|
||||
* this.admob.showRewardedAd();
|
||||
* }
|
||||
* });
|
||||
*
|
||||
*
|
||||
*
|
||||
* // On ad failed to load
|
||||
* this.admob.onAdFailedToLoad().subscribe(err => console.log('Error loading ad:', err));
|
||||
*
|
||||
*
|
||||
*
|
||||
* // On interstitial ad opened
|
||||
* this.admob.onAdOpened().subscribe(() => console.log('Interstitial ad opened'));
|
||||
*
|
||||
*
|
||||
*
|
||||
* // On interstitial ad closed
|
||||
* this.admob.onAdClosed().subscribe(() => console.log('Interstitial ad closed'));
|
||||
*
|
||||
*
|
||||
*
|
||||
* // On ad clicked and left application
|
||||
* this.admob.onAdLeftApplication().subscribe(() => console.log('Ad lefted application'));
|
||||
*
|
||||
*
|
||||
*
|
||||
* // On user ad rewarded
|
||||
* this.admob.onRewardedAd().subscribe(() => console.log('The user has been rewarded'));
|
||||
*
|
||||
*
|
||||
*
|
||||
* // On rewarded ad video started
|
||||
* this.admob.onRewardedAdVideoStarted().subscribe(() => console.log('Rewarded ad vieo started'));
|
||||
*
|
||||
*
|
||||
*
|
||||
* // On rewarded ad video completed
|
||||
* this.admob.onRewardedAdVideoCompleted().subscribe(() => console.log('Rewarded ad video completed'));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AdMob',
|
||||
plugin: 'cordova-admob',
|
||||
pluginRef: 'admob',
|
||||
repo: 'https://github.com/appfeel/admob-google-cordova',
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Admob extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* This enum represents AdMob's supported ad sizes.
|
||||
* Use one of these constants as adSize option when calling createBannerView
|
||||
*
|
||||
* @readonly
|
||||
*/
|
||||
@CordovaProperty()
|
||||
readonly AD_SIZE: {
|
||||
BANNER: string;
|
||||
IAB_MRECT: string;
|
||||
IAB_BANNER: string;
|
||||
IAB_LEADERBOARD: string;
|
||||
SMART_BANNER: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* This enum represents AdMob's supported ad types
|
||||
*
|
||||
* @readonly
|
||||
*/
|
||||
@CordovaProperty()
|
||||
readonly AD_TYPE: {
|
||||
BANNER: string;
|
||||
INTERSTITIAL: string;
|
||||
REWARDED: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the options to start displaying ads.
|
||||
* Although it is not required to call this method, as options can be specified in other methods, it is highly recommended
|
||||
*
|
||||
* @param options {AdmobOptions} Some param to configure something
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the options are set
|
||||
*/
|
||||
@Cordova()
|
||||
setOptions(options: AdmobOptions | AdmobWebOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new banner ad view. Call this method in order to be able to start showing banners
|
||||
*
|
||||
* @param options {AdmobOptions} (Optional) Setup options
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the banner view is created
|
||||
*/
|
||||
@Cordova()
|
||||
createBannerView(options?: AdmobOptions | AdmobWebOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show banner ads. You must call createBannerView first, otherwise it will result in failure callback and no ads will be shown
|
||||
*
|
||||
* @param show {boolean} (Optional) Indicates whether to show or hide banner ads. Defaults to `true`
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the banner shown or hidden
|
||||
*/
|
||||
@Cordova()
|
||||
showBannerAd(show?: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide and destroy banner view. Call this method when you want to destroy banner view.
|
||||
* It is not necessary to call this method when the app closed, as it will be automatically called by the plugin
|
||||
*/
|
||||
@Cordova()
|
||||
destroyBannerView() {}
|
||||
|
||||
/**
|
||||
* Request an interstitial ad
|
||||
* If `options.autoShowInterstitial` is set to `true` (default), the ad will automatically be displayed.
|
||||
* Otherwise you need to subscribe to `onAdLoaded()` event and call `showInterstitialAd()` after it will be raised specifying that an interstitial ad is available.
|
||||
* If you already called `requestInterstitialAd()` but the interstitial has never been shown, the successive calls to `requestInterstitialAd()` will result in the ad being inmediately available (the one that was obtained on the first call)
|
||||
*
|
||||
* @param options {AdmobOptions} (Optional) Setup options
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the interstitial ad is loaded
|
||||
*/
|
||||
@Cordova()
|
||||
requestInterstitialAd(options?: AdmobOptions | AdmobWebOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show an interstitial ad. Call it after `requestInterstitialAd()` and `onAdLoaded()` event raised.
|
||||
*
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the interstitial ad is shown
|
||||
*/
|
||||
@Cordova()
|
||||
showInterstitialAd(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request an rewarded ad
|
||||
* If `options.autoShowRewarded` is set to `true` (default), the ad will automatically be displayed.
|
||||
* Otherwise you need to subscribe to `onAdLoaded()` enent and call `showRewardedAd()` after it will be raised specifying that a rewarded ad is available.
|
||||
* If you already called `requestRewardedAd()` but the rewarded has never been shown, the successive calls to `requestRewardedAd()` will result in the ad being inmediately available (the one that was obtained on the first call)
|
||||
*
|
||||
* @param options {AdmobOptions} (Optional) Setup options
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the rewarded ad is loaded
|
||||
*/
|
||||
@Cordova()
|
||||
requestRewardedAd(options?: AdmobOptions | AdmobWebOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a rewarded ad
|
||||
*
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the rewarded ad is shown
|
||||
*/
|
||||
@Cordova()
|
||||
showRewardedAd(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an ad is received.
|
||||
*
|
||||
* WARNING*: only **ionic^4**. Older versions of ionic, use:
|
||||
*
|
||||
* ```js
|
||||
* document.addEventListener(window.admob.events.onAdLoaded, () => { });
|
||||
* ```
|
||||
*
|
||||
* Please refer to the documentation on https://admob-ionic.com/Events.
|
||||
*
|
||||
* @returns {Observable<AdMobEvent>} Returns an observable when an ad is received
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'appfeel.cordova.admob.onAdLoaded',
|
||||
element: document,
|
||||
})
|
||||
onAdLoaded(): Observable<AdMobEvent> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an ad request failed.
|
||||
*
|
||||
* WARNING*: only **ionic^4**. Older versions of ionic, use:
|
||||
*
|
||||
* ```js
|
||||
* document.addEventListener(window.admob.events.onAdFailedToLoad, () => { });
|
||||
* ```
|
||||
*
|
||||
* Please refer to the documentation on https://admob-ionic.com/Events.
|
||||
*
|
||||
* @returns {Observable<AdMobEvent>} Returns an observable when an ad request is failed
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'appfeel.cordova.admob.onAdFailedToLoad',
|
||||
element: document,
|
||||
})
|
||||
onAdFailedToLoad(): Observable<AdMobEvent> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an ad opens an overlay that covers the screen.
|
||||
* Please note that onPause cordova event is raised when an interstitial is shown.
|
||||
*
|
||||
* WARNING*: only **ionic^4**. Older versions of ionic, use:
|
||||
*
|
||||
* ```js
|
||||
* document.addEventListener(window.admob.events.onAdOpened, () => { });
|
||||
* ```
|
||||
*
|
||||
* Please refer to the documentation on https://admob-ionic.com/Events.
|
||||
*
|
||||
* @returns {Observable<AdMobEvent>} Returns an observable when an ad is opened
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'appfeel.cordova.admob.onAdOpened',
|
||||
element: document,
|
||||
})
|
||||
onAdOpened(): Observable<AdMobEvent> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user is about to return to the application after clicking on an ad.
|
||||
* Please note that onResume cordova event is raised when an interstitial is closed.
|
||||
*
|
||||
* WARNING*: only **ionic^4**. Older versions of ionic, use:
|
||||
*
|
||||
* ```js
|
||||
* document.addEventListener(window.admob.events.onAdClosed, () => { });
|
||||
* ```
|
||||
*
|
||||
* Please refer to the documentation on https://admob-ionic.com/Events.
|
||||
*
|
||||
* @returns {Observable<AdMobEvent>} Returns an observable when an ad is closed
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'appfeel.cordova.admob.onAdClosed',
|
||||
element: document,
|
||||
})
|
||||
onAdClosed(): Observable<AdMobEvent> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user leaves the application after clicking an ad (e.g., to go to the browser)
|
||||
*
|
||||
* @returns {Observable<AdMobEvent>} Returns an observable when an ad leaves the application.
|
||||
*
|
||||
* WARNING*: only **ionic^4**. Older versions of ionic, use:
|
||||
*
|
||||
* ```js
|
||||
* document.addEventListener(window.admob.events.onAdLeftApplication, () => { });
|
||||
* ```
|
||||
*
|
||||
* Please refer to the documentation on https://admob-ionic.com/Events.
|
||||
* @returns {Observable<AdMobEvent>} Returns an observable when application is left due to an ad click
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'appfeel.cordova.admob.onAdLeftApplication',
|
||||
element: document,
|
||||
})
|
||||
onAdLeftApplication(): Observable<AdMobEvent> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user has been rewarded by an ad.
|
||||
*
|
||||
* WARNING*: only **ionic^4**. Older versions of ionic, use:
|
||||
*
|
||||
* ```js
|
||||
* document.addEventListener(window.admob.events.onRewardedAd, () => { });
|
||||
* ```
|
||||
*
|
||||
* Please refer to the documentation on https://admob-ionic.com/Events.
|
||||
*
|
||||
* @returns {Observable<AdMobEvent>} Returns an observable when the user rewards an ad
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'appfeel.cordova.admob.onRewardedAd',
|
||||
element: document,
|
||||
})
|
||||
onRewardedAd(): Observable<AdMobEvent> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the video of a rewarded ad started.
|
||||
*
|
||||
* WARNING*: only **ionic^4**. Older versions of ionic, use:
|
||||
*
|
||||
* ```js
|
||||
* document.addEventListener(window.admob.events.onRewardedAdVideoStarted, () => { });
|
||||
* ```
|
||||
*
|
||||
* Please refer to the documentation on https://admob-ionic.com/Events.
|
||||
*
|
||||
* @returns {Observable<AdMobEvent>} Returns an observable when the video is started
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'appfeel.cordova.admob.onRewardedAdVideoStarted',
|
||||
element: document,
|
||||
})
|
||||
onRewardedAdVideoStarted(): Observable<AdMobEvent> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the video of a rewarded ad has completed.
|
||||
*
|
||||
* WARNING*: only **ionic^4**. Older versions of ionic, use:
|
||||
*
|
||||
* ```js
|
||||
* document.addEventListener(window.admob.events.onRewardedAdVideoCompleted, () => { });
|
||||
* ```
|
||||
*
|
||||
* Please refer to the documentation on https://admob-ionic.com/Events.
|
||||
*
|
||||
* @returns {Observable<AdMobEvent>} Returns an observable when the video is completed
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'appfeel.cordova.admob.onRewardedAdVideoCompleted',
|
||||
element: document,
|
||||
})
|
||||
onRewardedAdVideoCompleted(): Observable<AdMobEvent> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
interface PresentOptions {
|
||||
/**
|
||||
* Which Media Types are allowed to be selected
|
||||
* default: "IMAGE"
|
||||
*/
|
||||
mediaType?: 'IMAGE' | 'VIDEO' | 'ALL';
|
||||
/**
|
||||
* Show possibility to take via Camera
|
||||
* default: true
|
||||
*/
|
||||
showCameraTile?: boolean;
|
||||
/**
|
||||
* On which Screen the Picker should be started (iOS only)
|
||||
* default: "LIBRARY"
|
||||
*/
|
||||
startOnScreen?: 'LIBRARY' | 'IMAGE' | 'VIDEO';
|
||||
/**
|
||||
* Date format of the Scroll Indicator (Android only)
|
||||
* default: "YYYY.MM"
|
||||
*/
|
||||
scrollIndicatorDateFormat?: string;
|
||||
/**
|
||||
* Show Title (Android only)
|
||||
* default: true
|
||||
*/
|
||||
showTitle?: boolean;
|
||||
/**
|
||||
* Customize the Title (Android only)
|
||||
* default: "Select Image"
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* Show the zoomIndicator at the Images (Android only)
|
||||
* default: true
|
||||
*/
|
||||
zoomIndicator?: boolean;
|
||||
/**
|
||||
* Min Count of files to be selected
|
||||
* default: 0 (android), 1 (iOS)
|
||||
*/
|
||||
min?: number;
|
||||
/**
|
||||
* Message to be shown if min Count not reached (Android only)
|
||||
* default: "You need to select a minimum of ... pictures")"
|
||||
*/
|
||||
minCountMessage?: string;
|
||||
/**
|
||||
* Max Count of files can selected
|
||||
* default: 0 (android), 1 (iOS)
|
||||
*/
|
||||
max?: number;
|
||||
/**
|
||||
* Message to be shown if max Count is reached
|
||||
* default: "You can select a maximum of ... pictures"
|
||||
*/
|
||||
maxCountMessage?: string;
|
||||
/**
|
||||
* Change Done Button Text
|
||||
*/
|
||||
buttonText?: string;
|
||||
/**
|
||||
* Show Library as Dropdown (Android only)
|
||||
* default: false
|
||||
*/
|
||||
asDropdown?: boolean;
|
||||
/**
|
||||
* Return the Result as base64
|
||||
* default: false
|
||||
*/
|
||||
asBase64?: boolean;
|
||||
/**
|
||||
* Return the Image as JPEG
|
||||
* default: false
|
||||
*/
|
||||
asJpeg?: boolean;
|
||||
/**
|
||||
* Video Compression Option (iOS only)
|
||||
* available options: https://github.com/Yummypets/YPImagePicker/blob/23158e138bd649b40762bf2e4aa4beb0d463a121/Source/Configuration/YPImagePickerConfiguration.swift#L226-L240
|
||||
* default: AVAssetExportPresetHighestQuality
|
||||
*/
|
||||
videoCompression?: string;
|
||||
}
|
||||
|
||||
interface Result {
|
||||
type: 'image' | 'video';
|
||||
isBase64: boolean;
|
||||
src: string;
|
||||
}
|
||||
|
||||
export enum ErrorCodes {
|
||||
UnsupportedAction = 1,
|
||||
WrongJsonObject = 2,
|
||||
PickerCanceled = 3,
|
||||
UnknownError = 10,
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for every Plugin Error Callback
|
||||
*/
|
||||
interface AdvancedImagePickerError {
|
||||
/**
|
||||
* One of the AdvancedImagePickerErrorCodes
|
||||
*/
|
||||
code: ErrorCodes;
|
||||
|
||||
/**
|
||||
* If available some more info (mostly exception message)
|
||||
*/
|
||||
message: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name AdvancedImagePicker
|
||||
* @description
|
||||
* This Cordova Plugin is for a better (multiple) ImagePicker with more options.
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AdvancedImagePicker } from '@awesome-cordova-plugins/advanced-image-picker/npx';
|
||||
*
|
||||
*
|
||||
* constructor(private advancedImagePicker: AdvancedImagePicker) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.advancedImagePicker.present{
|
||||
* // config here
|
||||
* })
|
||||
* .then((res: Result[]) => console.log(res))
|
||||
* .catch((error: AdvancedImagePickerError) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AdvancedImagePicker',
|
||||
plugin: 'cordova-plugin-advanced-imagepicker',
|
||||
pluginRef: 'AdvancedImagePicker',
|
||||
repo: 'https://github.com/EinfachHans/cordova-plugin-advanced-imagepicker',
|
||||
install: 'ionic cordova plugin add cordova-plugin-advanced-imagepicker',
|
||||
installVariables: ['ANDROID_IMAGE_PICKER_VERSION'],
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AdvancedImagePicker extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Present the ImagePicker
|
||||
* @param options {PresentOptions} https://github.com/EinfachHans/cordova-plugin-advanced-imagepicker/tree/master#parameters
|
||||
* @return {Promise<Result[]>}
|
||||
*/
|
||||
@Cordova()
|
||||
present(options: PresentOptions): Promise<Result[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans all temp stored Files that was created by this Plugin (iOS only)
|
||||
*/
|
||||
@Cordova({ platforms: ['iOS'] })
|
||||
cleanup(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
107
src/@awesome-cordova-plugins/plugins/aes-256/index.ts
Normal file
107
src/@awesome-cordova-plugins/plugins/aes-256/index.ts
Normal file
@ -0,0 +1,107 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name AES256
|
||||
* @description
|
||||
* This cordova ionic plugin allows you to perform AES 256 encryption and decryption on the plain text.
|
||||
* It's a cross-platform plugin which supports both Android and iOS.
|
||||
* The encryption and decryption are performed on the device native layer so that the performance is much faster.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AES256 } from '@awesome-cordova-plugins/aes-256/ngx';
|
||||
*
|
||||
* private secureKey: string;
|
||||
* private secureIV: string;
|
||||
*
|
||||
* constructor(private aes256: AES256) {
|
||||
* this.generateSecureKeyAndIV(); // To generate the random secureKey and secureIV
|
||||
* }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* async generateSecureKeyAndIV() {
|
||||
* this.secureKey = await this.aes256.generateSecureKey('random password 12345'); // Returns a 32 bytes string
|
||||
* this.secureIV = await this.aes256.generateSecureIV('random password 12345'); // Returns a 16 bytes string
|
||||
* }
|
||||
*
|
||||
* this.aes256.encrypt(this.secureKey, this.secureIV, 'testdata')
|
||||
* .then(res => console.log('Encrypted Data: ',res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* this.aes256.decrypt(this.secureKey, this.secureIV, 'encryptedData')
|
||||
* .then(res => console.log('Decrypted Data : ',res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
*
|
||||
* this.aes256.generateSecureKey('random password 12345')
|
||||
* .then(res => console.log('Secure Key : ',res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
*
|
||||
* this.aes256.generateSecureIV('random password 12345')
|
||||
* .then(res => console.log('Secure IV : ',res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AES256',
|
||||
plugin: 'cordova-plugin-aes256-encryption',
|
||||
pluginRef: 'cordova.plugins.AES256',
|
||||
repo: 'https://github.com/Ideas2IT/cordova-aes256',
|
||||
platforms: ['Android', 'iOS'],
|
||||
install: 'ionic cordova plugin add cordova-plugin-aes256-encryption',
|
||||
})
|
||||
@Injectable()
|
||||
export class AES256 extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* This function used to perform the aes256 encryption
|
||||
*
|
||||
* @param {string} secureKey A 32 bytes string, which will used as input key for AES256 encryption.
|
||||
* @param {string} secureIV A 16 bytes string, which will used as initial vector for AES256 encryption.
|
||||
* @param {string} data A string which will be encrypted
|
||||
* @returns {Promise<string>} Returns a promise that resolves when encryption happens. The success response will returns encrypted data.
|
||||
*/
|
||||
@Cordova()
|
||||
encrypt(secureKey: string, secureIV: string, data: string): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function used to perform the aes256 decryption
|
||||
*
|
||||
* @param {string} secureKey A 32 bytes string, which will used as input key for AES256 decryption.
|
||||
* @param {string} secureIV A 16 bytes string, which will used as initial vector for AES256 decryption.
|
||||
* @param {string} data An AES256 encrypted data which will be decrypted.
|
||||
* @returns {Promise<string>} Returns a promise that resolves when decryption happens. The success response will returns decrypted data.
|
||||
*/
|
||||
@Cordova()
|
||||
decrypt(secureKey: string, secureIV: string, data: string): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function used to generate a secure key based on an password. Perfect if you want to delegate the key generation for encryption to the plugin.
|
||||
* Make sure to save the return value of this function somewhere so your encrypted data can be decrypted in the future.
|
||||
*
|
||||
* @param {string} password A random string, which will be used as input for a PBKDF2 function
|
||||
* @returns {Promise<string>} Returns a promise that resolves when key is generated.
|
||||
*/
|
||||
@Cordova()
|
||||
generateSecureKey(password: string): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function used to generate a secure IV based on an password. Perfect if you want to delegate the IV generation for encryption to the plugin.
|
||||
* Make sure to save the return value of this function somewhere so your encrypted data can be decrypted in the future.
|
||||
*
|
||||
* @param {string} password A random string, which will be used as input for a PBKDF2 function
|
||||
* @returns {Promise<string>} Returns a promise that resolves when IV is generated.
|
||||
*/
|
||||
@Cordova()
|
||||
generateSecureIV(password: string): Promise<string> {
|
||||
return;
|
||||
}
|
||||
}
|
94
src/@awesome-cordova-plugins/plugins/all-in-one-sdk/index.ts
Normal file
94
src/@awesome-cordova-plugins/plugins/all-in-one-sdk/index.ts
Normal file
@ -0,0 +1,94 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
Plugin,
|
||||
Cordova,
|
||||
CordovaProperty,
|
||||
CordovaInstance,
|
||||
InstanceProperty,
|
||||
AwesomeCordovaNativePlugin,
|
||||
} from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/**
|
||||
* @name AllInOneSDK
|
||||
* @description
|
||||
* Paytm All-in-One SDK plugin for Cordova/Ionic Applications
|
||||
* Paytm All-in-One SDK provides a swift, secure and seamless payment experience to your users by invoking the Paytm app (if installed on your user’s smartphone) to complete payment for your order.
|
||||
* Paytm All-in-One SDK enables payment acceptance via Paytm wallet, Paytm Payments Bank, saved Debit/Credit cards, Net Banking, BHIM UPI and EMI as available in your customer’s Paytm account. If Paytm app is not installed on a customer's device, the transaction will be processed via web view within the All-in-One SDK.
|
||||
* For more information about Paytm All-in-One SDK, please visit https://developer.paytm.com/docs/all-in-one-sdk/hybrid-apps/cordova/
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AllInOneSDK } from '@awesome-cordova-plugins/all-in-one-sdk/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private allInOneSDK: AllInOneSDK) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* For below parameters see [documentation](https://developer.paytm.com/docs/all-in-one-sdk/hybrid-apps/cordova/)
|
||||
* let paymentIntent = { mid : merchantID, orderId: orderId, txnToken: transactionToken, amount: amount, isStaging: isStaging, callbackUrl:callBackURL, restrictAppInvoke:restrictAppInvoke }
|
||||
*
|
||||
* this.allInOneSDK.startTransaction(paymentIntent)
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* For iOS:
|
||||
* After adding the plugin, open the iOS project, you can find the same at <projectName>/platforms/ios.
|
||||
* In case merchant don’t have callback URL, Add an entry into Info.plist LSApplicationQueriesSchemes(Array) Item 0 (String)-> paytm
|
||||
* Add a URL Scheme “paytm”+”MID”
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AllInOneSDK',
|
||||
plugin: 'cordova-paytm-allinonesdk',
|
||||
pluginRef: 'AllInOneSDK',
|
||||
repo: 'https://github.com/paytm/paytm-allinonesdk-ionic-cordova.git',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
export class AllInOneSDK extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* This function checks if Paytm Application is available on the device.
|
||||
* If Paytm exists then it invokes Paytm Application with the parameters sent and creates an order.
|
||||
* If the Paytm Application is not available the transaction is continued on a webView within All-in-One SDK.
|
||||
*
|
||||
* @param options {PaymentIntentModel} These parameters are required and will be used to create an order.
|
||||
* @returns {Promise<PaytmResponse>} Returns a promise that resolves when a transaction completes(both failed and successful).
|
||||
*/
|
||||
@Cordova()
|
||||
startTransaction(options: PaymentIntentModel | PaymentAssistIntentModel): Promise<PaytmResponse> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The response that will be recieved when any transaction is completed
|
||||
*/
|
||||
export interface PaytmResponse {
|
||||
message: string;
|
||||
response: string; // A stringified response of a hashmap returned from All-in-One SDK
|
||||
}
|
||||
|
||||
/**
|
||||
* For below parameters see [documentation](https://developer.paytm.com/docs/all-in-one-sdk/hybrid-apps/cordova/)
|
||||
*/
|
||||
export interface PaymentIntentModel {
|
||||
mid: string; // Merchant ID
|
||||
orderId: string; // Order ID
|
||||
txnToken: string; // Transaction Token
|
||||
amount: string; // Amount
|
||||
isStaging: boolean; // Environment
|
||||
callbackUrl: string; // Callback URL
|
||||
restrictAppInvoke: boolean; // To enable or disable the paytm app invocation
|
||||
}
|
||||
|
||||
export interface PaymentAssistIntentModel {
|
||||
mid: string; // Merchant ID
|
||||
orderId: string; // Order ID
|
||||
txnToken: string; // Transaction Token
|
||||
amount: string; // Amount
|
||||
isStaging: boolean; // Environment
|
||||
callbackUrl: string; // Callback URL
|
||||
restrictAppInvoke: boolean; // To enable or disable the paytm app invocation
|
||||
enableAssist: boolean; // To enable or disable the Assist (Otp auto read)
|
||||
}
|
259
src/@awesome-cordova-plugins/plugins/analytics-firebase/index.ts
Normal file
259
src/@awesome-cordova-plugins/plugins/analytics-firebase/index.ts
Normal file
@ -0,0 +1,259 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, CordovaProperty, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name Analytics Firebase
|
||||
* @description
|
||||
* Google Analytics Firebase plugin for Ionic Native apps.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AnalyticsFirebase } from '@awesome-cordova-plugins/analytics-firebase';
|
||||
*
|
||||
*
|
||||
* constructor(private analyticsFirebase: AnalyticsFirebase) { }
|
||||
*
|
||||
* // Track an event with default events and params
|
||||
* const eventParams = {};
|
||||
* eventParams[this.analyticsFirebase.DEFAULT_PARAMS.LEVEL] = 29;
|
||||
* this.analyticsFirebase.logEvent(this.analyticsFirebase.DEFAULT_EVENTS.LEVEL_UP, eventParams)
|
||||
* .then(() => console.log('Event successfully tracked'))
|
||||
* .catch(err => console.log('Error tracking event:', err));
|
||||
*
|
||||
* // Track an event with custom events and params
|
||||
* const eventParams = {};
|
||||
* eventParams['my-prop'] = 29;
|
||||
* this.analyticsFirebase.logEvent('my-event', eventParams)
|
||||
* .then(() => console.log('Event successfully tracked'))
|
||||
* .catch(err => console.log('Error tracking event:', err));
|
||||
*
|
||||
*
|
||||
* // Reset analytics data
|
||||
* this.analyticsFirebase.resetAnalyticsData()
|
||||
* .then(() => console.log('Analytics data have been reset'))
|
||||
* .catch(err => console.log('Error resetting analytics data:', err));
|
||||
*
|
||||
*
|
||||
* // Track a screen view
|
||||
* this.analyticsFirebase.setCurrentScreen('Home')
|
||||
* .then(() => console.log('View successfully tracked'))
|
||||
* .catch(err => console.log('Error tracking view:', err));
|
||||
*
|
||||
*
|
||||
* // Set user id
|
||||
* this.analyticsFirebase.setUserId('USER-ID')
|
||||
* .then(() => console.log('User id successfully set'))
|
||||
* .catch(err => console.log('Error setting user id:', err));
|
||||
*
|
||||
*
|
||||
* // Set user property from default properties
|
||||
* this.analyticsFirebase.setUserProperty('KEY', 'VALUE')
|
||||
* .then(() => console.log('User property successfully set'))
|
||||
* .catch(err => console.log('Error setting user property:', err));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AnalyticsFirebase',
|
||||
plugin: 'cordova-plugin-analytics',
|
||||
pluginRef: 'analytics',
|
||||
repo: 'https://github.com/appfeel/analytics-google',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AnalyticsFirebase extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* This enum represents AnalyticsFirebase default events.
|
||||
* Use one of these default events or a custom event
|
||||
*
|
||||
* @readonly
|
||||
*/
|
||||
@CordovaProperty()
|
||||
readonly DEFAULT_EVENTS: {
|
||||
ADD_PAYMENT_INFO: string;
|
||||
ADD_TO_CART: string;
|
||||
ADD_TO_WISHLIST: string;
|
||||
APP_OPEN: string;
|
||||
BEGIN_CHECKOUT: string;
|
||||
CAMPAIGN_DETAILS: string;
|
||||
CHECKOUT_PROGRESS: string;
|
||||
EARN_VIRTUAL_CURRENCY: string;
|
||||
ECOMMERCE_PURCHASE: string;
|
||||
GENERATE_LEAD: string;
|
||||
JOIN_GROUP: string;
|
||||
LEVEL_END: string;
|
||||
LEVEL_START: string;
|
||||
LEVEL_UP: string;
|
||||
LOGIN: string;
|
||||
POST_SCORE: string;
|
||||
PRESENT_OFFER: string;
|
||||
PURCHASE_REFUND: string;
|
||||
REMOVE_FROM_CART: string;
|
||||
SEARCH: string;
|
||||
SELECT_CONTENT: string;
|
||||
SET_CHECKOUT_OPTION: string;
|
||||
SHARE: string;
|
||||
SIGN_UP: string;
|
||||
SPEND_VIRTUAL_CURRENCY: string;
|
||||
TUTORIAL_BEGIN: string;
|
||||
TUTORIAL_COMPLETE: string;
|
||||
UNLOCK_ACHIEVEMENT: string;
|
||||
VIEW_ITEM: string;
|
||||
VIEW_ITEM_LIST: string;
|
||||
VIEW_SEARCH_RESULTS: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* This enum represents AnalyticsFirebase default params.
|
||||
* Use one of these default params or a custom param
|
||||
*
|
||||
* @readonly
|
||||
*/
|
||||
@CordovaProperty()
|
||||
readonly DEFAULT_PARAMS: {
|
||||
ACHIEVEMENT_ID: string;
|
||||
ACLID: string;
|
||||
AFFILIATION: string;
|
||||
CAMPAIGN: string;
|
||||
CHARACTER: string;
|
||||
CHECKOUT_OPTION: string;
|
||||
CHECKOUT_STEP: string;
|
||||
CONTENT: string;
|
||||
CONTENT_TYPE: string;
|
||||
COUPON: string;
|
||||
CP1: string;
|
||||
CREATIVE_NAME: string;
|
||||
CREATIVE_SLOT: string;
|
||||
CURRENCY: string;
|
||||
DESTINATION: string;
|
||||
END_DATE: string;
|
||||
FLIGHT_NUMBER: string;
|
||||
GROUP_ID: string;
|
||||
INDEX: string;
|
||||
ITEM_BRAND: string;
|
||||
ITEM_CATEGORY: string;
|
||||
ITEM_ID: string;
|
||||
ITEM_LIST: string;
|
||||
ITEM_LOCATION_ID: string;
|
||||
ITEM_NAME: string;
|
||||
ITEM_VARIANT: string;
|
||||
LEVEL: string;
|
||||
LEVEL_NAME: string;
|
||||
LOCATION: string;
|
||||
MEDIUM: string;
|
||||
METHOD: string;
|
||||
NUMBER_OF_NIGHTS: string;
|
||||
NUMBER_OF_PASSENGERS: string;
|
||||
NUMBER_OF_ROOMS: string;
|
||||
ORIGIN: string;
|
||||
PRICE: string;
|
||||
QUANTITY: string;
|
||||
SCORE: string;
|
||||
SEARCH_TERM: string;
|
||||
SHIPPING: string;
|
||||
SOURCE: string;
|
||||
START_DATE: string;
|
||||
SUCCESS: string;
|
||||
TAX: string;
|
||||
TERM: string;
|
||||
TRANSACTION_ID: string;
|
||||
TRAVEL_CLASS: string;
|
||||
VALUE: string;
|
||||
VIRTUAL_CURRENCY_NAME: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Logs an app event. The event can have up to 25 parameters.
|
||||
* Events with the same name must have the same parameters.
|
||||
* Up to 500 event names are supported.
|
||||
* Using predefined [FirebaseAnalytics.Event](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html) and/or [FirebaseAnalytics.Param](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Param.html) is recommended for optimal reporting.
|
||||
*
|
||||
* @param eventName {string} The event name
|
||||
* @param eventParams {object} (Optional) The event params
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the event is logged
|
||||
*/
|
||||
@Cordova()
|
||||
logEvent(eventName: string, eventParams?: object): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all analytics data for this app from the device and resets the app instance id
|
||||
*
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the analytics data is cleared
|
||||
*/
|
||||
@Cordova()
|
||||
resetAnalyticsData(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether analytics collection is enabled for this app on this device. This setting is persisted across app sessions. By default it is enabled
|
||||
*
|
||||
* @param screenName {boolean} The value of the collection
|
||||
* @param enabled
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the collection is enabled/disabled
|
||||
*/
|
||||
@Cordova()
|
||||
setAnalyticsCollectionEnabled(enabled: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current screen name, which specifies the current visual context in your app.
|
||||
* This helps identify the areas in your app where users spend their time and how they interact with your app
|
||||
*
|
||||
* @param screenName {string} The screen name
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the current screen is setted
|
||||
*/
|
||||
@Cordova()
|
||||
setCurrentScreen(screenName: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum engagement time required before starting a session. The default value is 10000 (10 seconds)
|
||||
*
|
||||
* @param screenName {number} The duration in milliseconds
|
||||
* @param milliseconds
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the minimum session duration is set
|
||||
*/
|
||||
@Cordova()
|
||||
setMinimumSessionDuration(milliseconds: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the duration of inactivity that terminates the current session. The default value is 1800000 (30 minutes)
|
||||
*
|
||||
* @param screenName {number} The duration in milliseconds
|
||||
* @param milliseconds
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the session timeout duration is set
|
||||
*/
|
||||
@Cordova()
|
||||
setSessionTimeoutDuration(milliseconds: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user ID property. This feature must be used in accordance with Google's Privacy Policy
|
||||
*
|
||||
* @param userId {string} The user id
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the user id is setted
|
||||
*/
|
||||
@Cordova()
|
||||
setUserId(userId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a user property to a given value. Up to 25 user property names are supported. Once set, user property values persist throughout the app lifecycle and across sessions
|
||||
*
|
||||
* @param userPropertyName {string} The user property name
|
||||
* @param userPropertyValue {string} The user property value
|
||||
* @returns {Promise<any>} Returns a promise that resolves when the user property setted
|
||||
*/
|
||||
@Cordova()
|
||||
setUserProperty(userPropertyName: string, userPropertyValue: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
304
src/@awesome-cordova-plugins/plugins/android-exoplayer/index.ts
Normal file
304
src/@awesome-cordova-plugins/plugins/android-exoplayer/index.ts
Normal file
@ -0,0 +1,304 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export type AndroidExoPlayerAspectRatio = 'FILL_SCREEN' | 'FIT_SCREEN';
|
||||
|
||||
export interface AndroidExoPlayerParams {
|
||||
/**
|
||||
* Url of the video to play.
|
||||
*/
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* Set the user agent. Default is `ExoPlayerPlugin`
|
||||
*/
|
||||
userAgent?: string;
|
||||
|
||||
/**
|
||||
* Set the player aspect ratio.
|
||||
*/
|
||||
aspectRatio?: AndroidExoPlayerAspectRatio;
|
||||
|
||||
/**
|
||||
* Hide controls after this many milliseconds, default is `5000`.
|
||||
*/
|
||||
hideTimeout?: number;
|
||||
|
||||
/**
|
||||
* When set to false stream will not automatically start.
|
||||
*/
|
||||
autoPlay?: boolean;
|
||||
|
||||
/**
|
||||
* Start playback at this many milliseconds into video, default is `0`.
|
||||
*/
|
||||
seekTo?: number;
|
||||
|
||||
/**
|
||||
* Amount of time in milliseconds to use when skipping forward, default is `1000`.
|
||||
*/
|
||||
forwardTime?: number;
|
||||
|
||||
/**
|
||||
* Amount of time in milliseconds to use when skipping backward, default is `1000`.
|
||||
*/
|
||||
rewindTime?: number;
|
||||
|
||||
/**
|
||||
* Only play audio in the backgroud, default is `false`.
|
||||
* If you pass in `audioOnly: true`, make sure to manually close the player on some event (like escape button) since the plugin won't be detecting keypresses when playing audio in the background.
|
||||
*/
|
||||
audioOnly?: true;
|
||||
|
||||
/**
|
||||
* Optional subtitle url to display over the video.
|
||||
* We currently support .srt and .vtt subtitle formats. Subtitles are not supported on all stream types, as ExoPlayer has requirement that both video and subtitle "must have the same number of periods, and must not have any dynamic windows", which means for simple mp4s it should work, but on more complex HLS/Dash setups it might not.
|
||||
*/
|
||||
subtitleUrl?: string;
|
||||
|
||||
/**
|
||||
* okhttp connect timeout in milliseconds (default is `0`)
|
||||
*/
|
||||
connectTimeout?: number;
|
||||
|
||||
/**
|
||||
* okhttp read timeout in milliseconds (default is `0`)
|
||||
*/
|
||||
readTimeout?: number;
|
||||
|
||||
/**
|
||||
* okhttp write timeout in milliseconds (default is `0`)
|
||||
*/
|
||||
writeTimeout?: number;
|
||||
|
||||
/**
|
||||
* okhttp socket ping interval in milliseconds (default is `0` or disabled)
|
||||
*/
|
||||
pingInterval?: number;
|
||||
|
||||
/**
|
||||
* Number of times datasource will retry the stream before giving up (default is `3`)
|
||||
*/
|
||||
retryCount?: number;
|
||||
|
||||
/**
|
||||
* If this object is not present controller will not be visible.
|
||||
*/
|
||||
controller?: AndroidExoPlayerControllerConfig;
|
||||
}
|
||||
|
||||
export interface AndroidExoplayerState {
|
||||
[s: string]: string;
|
||||
}
|
||||
|
||||
export interface AndroidExoPlayerControllerConfig {
|
||||
/**
|
||||
* Image in the controller.
|
||||
*/
|
||||
streamImage: string;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
streamTitle: string;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
streamDescription: string;
|
||||
|
||||
/**
|
||||
* Hide entire progress bar.
|
||||
*/
|
||||
hideProgress?: true;
|
||||
|
||||
/**
|
||||
* If progress bar is visible hide current position from it
|
||||
*/
|
||||
hidePosition: false;
|
||||
|
||||
/**
|
||||
* If progress bar is visible Hide stream duration from it
|
||||
*/
|
||||
hideDuration: false;
|
||||
|
||||
/**
|
||||
* Override the player control button icons.
|
||||
*/
|
||||
controlIcons?: {
|
||||
/**
|
||||
* Rewind button icon.
|
||||
*/
|
||||
exo_rew: string;
|
||||
|
||||
/**
|
||||
* Play button icon.
|
||||
*/
|
||||
exo_play: string;
|
||||
|
||||
/**
|
||||
* Pause button icon.
|
||||
*/
|
||||
exo_pause: string;
|
||||
|
||||
/**
|
||||
* Fast forward button icon.
|
||||
*/
|
||||
exo_ffwd: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Android ExoPlayer
|
||||
* @description
|
||||
* Cordova media player plugin using Google's ExoPlayer framework.
|
||||
*
|
||||
* https://github.com/google/ExoPlayer
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AndroidExoPlayer } from '@awesome-cordova-plugins/android-exoplayer/ngx';
|
||||
*
|
||||
* constructor(private androidExoPlayer: AndroidExoPlayer) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.androidExoPlayer.show({url: 'http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube'});
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* AndroidExoPlayerParams
|
||||
* AndroidExoplayerState
|
||||
* AndroidExoPlayerControllerConfig
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AndroidExoPlayer',
|
||||
plugin: 'cordova-plugin-exoplayer',
|
||||
pluginRef: 'ExoPlayer',
|
||||
repo: 'https://github.com/frontyard/cordova-plugin-exoplayer',
|
||||
platforms: ['Android'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AndroidExoplayer extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Show the player.
|
||||
*
|
||||
* @param {AndroidExoPlayerParams} parameters Parameters
|
||||
* @returns {Observable<AndroidExoplayerState>}
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
clearFunction: 'close',
|
||||
clearWithArgs: false,
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
show(parameters: AndroidExoPlayerParams): Observable<AndroidExoplayerState> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch stream without disposing of the player.
|
||||
*
|
||||
* @param {string} url The url of the new stream.
|
||||
* @param {AndroidExoPlayerControllerConfig} controller Configuration of the controller.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
setStream(url: string, controller: AndroidExoPlayerControllerConfig): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Will pause if playing and play if paused
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
playPause(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop playing.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
stop(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Jump to a particular position.
|
||||
*
|
||||
* @param {number} milliseconds Position in stream in milliseconds
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
seekTo(milliseconds: number): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Jump to a particular time relative to the current position.
|
||||
*
|
||||
* @param {number} milliseconds Time in milliseconds
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
seekBy(milliseconds: number): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current player state.
|
||||
*
|
||||
* @returns {Promise<AndroidExoplayerState>}
|
||||
*/
|
||||
@Cordova()
|
||||
getState(): Promise<AndroidExoplayerState> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the controller.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
showController(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the controller.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
hideController(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the controller configuration.
|
||||
*
|
||||
* @param {AndroidExoPlayerControllerConfig} controller Configuration of the controller.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
setController(controller: AndroidExoPlayerControllerConfig): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close and dispose of player, call before destroy.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
close(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* Bit flag values for setSystemUiVisibility()
|
||||
*
|
||||
* @see https://developer.android.com/reference/android/view/View.html#setSystemUiVisibility(int)
|
||||
*/
|
||||
export enum AndroidSystemUiFlags {
|
||||
/** View has requested the system UI (status bar) to be visible (the default). SYSTEM_UI_FLAG_VISIBLE */
|
||||
Visible = 0,
|
||||
/** View has requested the system UI to enter an unobtrusive "low profile" mode. SYSTEM_UI_FLAG_LOW_PROFILE */
|
||||
LowProfile = 1,
|
||||
/** View has requested that the system navigation be temporarily hidden. SYSTEM_UI_FLAG_HIDE_NAVIGATION */
|
||||
HideNavigation = 2,
|
||||
/** View has requested to go into the normal fullscreen mode so that its content can take over the screen while still allowing the user to interact with the application. SYSTEM_UI_FLAG_FULLSCREEN */
|
||||
Fullscreen = 4,
|
||||
/** When using other layout flags, we would like a stable view of the content insets given to fitSystemWindows(Rect). SYSTEM_UI_FLAG_LAYOUT_STABLE */
|
||||
LayoutStable = 256,
|
||||
/** View would like its window to be laid out as if it has requested SYSTEM_UI_FLAG_HIDE_NAVIGATION, even if it currently hasn't. SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION */
|
||||
LayoutHideNavigation = 512,
|
||||
/** View would like its window to be laid out as if it has requested SYSTEM_UI_FLAG_FULLSCREEN, even if it currently hasn't. SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN */
|
||||
LayoutFullscreen = 1024,
|
||||
/** View would like to remain interactive when hiding the navigation bar with SYSTEM_UI_FLAG_HIDE_NAVIGATION. SYSTEM_UI_FLAG_IMMERSIVE */
|
||||
Immersive = 2048,
|
||||
/** View would like to remain interactive when hiding the status bar with SYSTEM_UI_FLAG_FULLSCREEN and/or hiding the navigation bar with SYSTEM_UI_FLAG_HIDE_NAVIGATION. SYSTEM_UI_FLAG_IMMERSIVE_STICKY */
|
||||
ImmersiveSticky = 4096,
|
||||
/** Requests the status bar to draw in a mode that is compatible with light status bar backgrounds. SYSTEM_UI_FLAG_LIGHT_STATUS_BAR */
|
||||
LightStatusBar = 8192,
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Android Full Screen
|
||||
* @description
|
||||
* This plugin enables developers to offer users a true full screen experience in their Cordova and PhoneGap apps for Android.
|
||||
* Using Android 4.0+, you can use true full screen in "lean mode", the way you see in apps like YouTube, expanding the app right to the edges of the screen, hiding the status and navigation bars until the user next interacts. This is ideally suited to video or cut-scene content.
|
||||
* In Android 4.4+, however, you can now enter true full screen, fully interactive immersive mode. In this mode, your app will remain in true full screen until you choose otherwise; users can swipe down from the top of the screen to temporarily display the system UI.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AndroidFullScreen } from '@awesome-cordova-plugins/android-full-screen/ngx';
|
||||
*
|
||||
* constructor(private androidFullScreen: AndroidFullScreen) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.androidFullScreen.isImmersiveModeSupported()
|
||||
* .then(() => console.log('Immersive mode supported'))
|
||||
* .catch(err => console.log(err));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AndroidFullScreen',
|
||||
plugin: 'cordova-plugin-fullscreen',
|
||||
pluginRef: 'AndroidFullScreen',
|
||||
repo: 'https://github.com/mesmotronic/cordova-plugin-fullscreen',
|
||||
platforms: ['Android'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AndroidFullScreen extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Is this plugin supported?
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
isSupported(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is immersive mode supported?
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
isImmersiveModeSupported(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The width of the screen in immersive mode.
|
||||
*
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
@Cordova()
|
||||
immersiveWidth(): Promise<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The height of the screen in immersive mode.
|
||||
*
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
@Cordova()
|
||||
immersiveHeight(): Promise<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide system UI until user interacts.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
leanMode(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show system UI.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
showSystemUI(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend your app underneath the status bar (Android 4.4+ only).
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
showUnderStatusBar(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend your app underneath the system UI (Android 4.4+ only).
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
showUnderSystemUI(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide system UI and keep it hidden (Android 4.4+ only).
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
immersiveMode(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually set the the system UI to a custom mode. This mirrors the Android method of the same name. (Android 4.4+ only).
|
||||
*
|
||||
* @see https://developer.android.com/reference/android/view/View.html#setSystemUiVisibility(int)
|
||||
* @param {AndroidSystemUiFlags} visibility Bitwise-OR of flags in AndroidSystemUiFlags
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
setSystemUiVisibility(visibility: AndroidSystemUiFlags): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
100
src/@awesome-cordova-plugins/plugins/android-notch/index.ts
Normal file
100
src/@awesome-cordova-plugins/plugins/android-notch/index.ts
Normal file
@ -0,0 +1,100 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name Android Notch
|
||||
* @description
|
||||
* This plugin enables developers to get the cutout and android devices inset sizes
|
||||
* It is based on the cordova plugin developed by @tobspr: https://github.com/tobspr/cordova-plugin-android-notch
|
||||
* This plugin works on all android versions, but we can only detect notches starting from Android 9.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AndroidNotch } from '@awesome-cordova-plugins/android-notch/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private androidNotch: AndroidNotch) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.androidNotch.hasCutout()
|
||||
* .then((px: number) => console.log('Inset size: '), px)
|
||||
* .catch((error: any) => console.log('Error: ', error))
|
||||
*
|
||||
* this.androidNotch.getInsetTop()
|
||||
* .then((px: number) => console.log('Inset size: '), px)
|
||||
* .catch((error: any) => console.log('Error: ', error))
|
||||
*
|
||||
* this.androidNotch.getInsetRight()
|
||||
* .then((px: number) => console.log('Inset size: '), px)
|
||||
* .catch((error: any) => console.log('Error: ', error))
|
||||
*
|
||||
* this.androidNotch.getInsetBottom()
|
||||
* .then((px: number) => console.log('Inset size: '), px)
|
||||
* .catch((error: any) => console.log('Error: ', error))
|
||||
*
|
||||
* this.androidNotch.getInsetLeft()
|
||||
* .then((px: number) => console.log('Inset size: '), px)
|
||||
* .catch((error: any) => console.log('Error: ', error))
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AndroidNotch',
|
||||
plugin: 'cordova-plugin-android-notch',
|
||||
pluginRef: 'AndroidNotch',
|
||||
repo: 'https://github.com/tobspr/cordova-plugin-android-notch.git',
|
||||
platforms: ['Android'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AndroidNotch extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Returns true if the android device has cutout
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
hasCutout(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the heigth of the top inset
|
||||
*
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
@Cordova()
|
||||
getInsetTop(): Promise<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the heigth of the right inset
|
||||
*
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
@Cordova()
|
||||
getInsetRight(): Promise<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the heigth of the bottom inset
|
||||
*
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
@Cordova()
|
||||
getInsetBottom(): Promise<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the heigth of the left inset
|
||||
*
|
||||
* @returns {Promise<number>}
|
||||
*/
|
||||
@Cordova()
|
||||
getInsetLeft(): Promise<number> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,249 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name Android Permissions
|
||||
* @premier android-permissions
|
||||
* @description
|
||||
* This plugin is designed to support Android new permissions checking mechanism.
|
||||
*
|
||||
* You can find all permissions here: https://developer.android.com/reference/android/Manifest.permission.html
|
||||
* @usage
|
||||
* ```
|
||||
* import { AndroidPermissions } from '@awesome-cordova-plugins/android-permissions/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private androidPermissions: AndroidPermissions) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.CAMERA).then(
|
||||
* result => console.log('Has permission?',result.hasPermission),
|
||||
* err => this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.CAMERA)
|
||||
* );
|
||||
*
|
||||
* this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.CAMERA, this.androidPermissions.PERMISSION.GET_ACCOUNTS]);
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* Android 26 and above: due to Android 26's changes to permissions handling (permissions are requested at time of use rather than at runtime,) if your app does not include any functions (eg. other Ionic Native plugins) that utilize a particular permission, then `requestPermission()` and `requestPermissions()` will resolve immediately with no prompt shown to the user. Thus, you must include a function utilizing the feature you would like to use before requesting permission for it.
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AndroidPermissions',
|
||||
plugin: 'cordova-plugin-android-permissions',
|
||||
pluginRef: 'cordova.plugins.permissions',
|
||||
repo: 'https://github.com/NeoLSN/cordova-plugin-android-permissions',
|
||||
platforms: ['Android'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AndroidPermissions extends AwesomeCordovaNativePlugin {
|
||||
PERMISSION: any = {
|
||||
ACCESS_CHECKIN_PROPERTIES: 'android.permission.ACCESS_CHECKIN_PROPERTIES',
|
||||
ACCESS_COARSE_LOCATION: 'android.permission.ACCESS_COARSE_LOCATION',
|
||||
ACCESS_FINE_LOCATION: 'android.permission.ACCESS_FINE_LOCATION',
|
||||
ACCESS_LOCATION_EXTRA_COMMANDS: 'android.permission.ACCESS_LOCATION_EXTRA_COMMANDS',
|
||||
ACCESS_MOCK_LOCATION: 'android.permission.ACCESS_MOCK_LOCATION',
|
||||
ACCESS_NETWORK_STATE: 'android.permission.ACCESS_NETWORK_STATE',
|
||||
ACCESS_SURFACE_FLINGER: 'android.permission.ACCESS_SURFACE_FLINGER',
|
||||
ACCESS_WIFI_STATE: 'android.permission.ACCESS_WIFI_STATE',
|
||||
ACCOUNT_MANAGER: 'android.permission.ACCOUNT_MANAGER',
|
||||
ADD_VOICEMAIL: 'com.android.voicemail.permission.ADD_VOICEMAIL',
|
||||
AUTHENTICATE_ACCOUNTS: 'android.permission.AUTHENTICATE_ACCOUNTS',
|
||||
BATTERY_STATS: 'android.permission.BATTERY_STATS',
|
||||
BIND_ACCESSIBILITY_SERVICE: 'android.permission.BIND_ACCESSIBILITY_SERVICE',
|
||||
BIND_APPWIDGET: 'android.permission.BIND_APPWIDGET',
|
||||
BIND_CARRIER_MESSAGING_SERVICE: 'android.permission.BIND_CARRIER_MESSAGING_SERVICE',
|
||||
BIND_DEVICE_ADMIN: 'android.permission.BIND_DEVICE_ADMIN',
|
||||
BIND_DREAM_SERVICE: 'android.permission.BIND_DREAM_SERVICE',
|
||||
BIND_INPUT_METHOD: 'android.permission.BIND_INPUT_METHOD',
|
||||
BIND_NFC_SERVICE: 'android.permission.BIND_NFC_SERVICE',
|
||||
BIND_NOTIFICATION_LISTENER_SERVICE: 'android.permission.BIND_NOTIFICATION_LISTENER_SERVICE',
|
||||
BIND_PRINT_SERVICE: 'android.permission.BIND_PRINT_SERVICE',
|
||||
BIND_REMOTEVIEWS: 'android.permission.BIND_REMOTEVIEWS',
|
||||
BIND_TEXT_SERVICE: 'android.permission.BIND_TEXT_SERVICE',
|
||||
BIND_TV_INPUT: 'android.permission.BIND_TV_INPUT',
|
||||
BIND_VOICE_INTERACTION: 'android.permission.BIND_VOICE_INTERACTION',
|
||||
BIND_VPN_SERVICE: 'android.permission.BIND_VPN_SERVICE',
|
||||
BIND_WALLPAPER: 'android.permission.BIND_WALLPAPER',
|
||||
BLUETOOTH: 'android.permission.BLUETOOTH',
|
||||
BLUETOOTH_ADMIN: 'android.permission.BLUETOOTH_ADMIN',
|
||||
BLUETOOTH_ADVERTISE: 'android.permission.BLUETOOTH_ADVERTISE',
|
||||
BLUETOOTH_CONNECT: 'android.permission.BLUETOOTH_CONNECT',
|
||||
BLUETOOTH_PRIVILEGED: 'android.permission.BLUETOOTH_PRIVILEGED',
|
||||
BLUETOOTH_SCAN: 'android.permission.BLUETOOTH_SCAN',
|
||||
BODY_SENSORS: 'android.permission.BODY_SENSORS',
|
||||
BRICK: 'android.permission.BRICK',
|
||||
BROADCAST_PACKAGE_REMOVED: 'android.permission.BROADCAST_PACKAGE_REMOVED',
|
||||
BROADCAST_SMS: 'android.permission.BROADCAST_SMS',
|
||||
BROADCAST_STICKY: 'android.permission.BROADCAST_STICKY',
|
||||
BROADCAST_WAP_PUSH: 'android.permission.BROADCAST_WAP_PUSH',
|
||||
CALL_PHONE: 'android.permission.CALL_PHONE',
|
||||
CALL_PRIVILEGED: 'android.permission.CALL_PRIVILEGED',
|
||||
CAMERA: 'android.permission.CAMERA',
|
||||
CAPTURE_AUDIO_OUTPUT: 'android.permission.CAPTURE_AUDIO_OUTPUT',
|
||||
CAPTURE_SECURE_VIDEO_OUTPUT: 'android.permission.CAPTURE_SECURE_VIDEO_OUTPUT',
|
||||
CAPTURE_VIDEO_OUTPUT: 'android.permission.CAPTURE_VIDEO_OUTPUT',
|
||||
CHANGE_COMPONENT_ENABLED_STATE: 'android.permission.CHANGE_COMPONENT_ENABLED_STATE',
|
||||
CHANGE_CONFIGURATION: 'android.permission.CHANGE_CONFIGURATION',
|
||||
CHANGE_NETWORK_STATE: 'android.permission.CHANGE_NETWORK_STATE',
|
||||
CHANGE_WIFI_MULTICAST_STATE: 'android.permission.CHANGE_WIFI_MULTICAST_STATE',
|
||||
CHANGE_WIFI_STATE: 'android.permission.CHANGE_WIFI_STATE',
|
||||
CLEAR_APP_CACHE: 'android.permission.CLEAR_APP_CACHE',
|
||||
CLEAR_APP_USER_DATA: 'android.permission.CLEAR_APP_USER_DATA',
|
||||
CONTROL_LOCATION_UPDATES: 'android.permission.CONTROL_LOCATION_UPDATES',
|
||||
DELETE_CACHE_FILES: 'android.permission.DELETE_CACHE_FILES',
|
||||
DELETE_PACKAGES: 'android.permission.DELETE_PACKAGES',
|
||||
DEVICE_POWER: 'android.permission.DEVICE_POWER',
|
||||
DIAGNOSTIC: 'android.permission.DIAGNOSTIC',
|
||||
DISABLE_KEYGUARD: 'android.permission.DISABLE_KEYGUARD',
|
||||
DUMP: 'android.permission.DUMP',
|
||||
EXPAND_STATUS_BAR: 'android.permission.EXPAND_STATUS_BAR',
|
||||
FACTORY_TEST: 'android.permission.FACTORY_TEST',
|
||||
FLASHLIGHT: 'android.permission.FLASHLIGHT',
|
||||
FORCE_BACK: 'android.permission.FORCE_BACK',
|
||||
GET_ACCOUNTS: 'android.permission.GET_ACCOUNTS',
|
||||
GET_PACKAGE_SIZE: 'android.permission.GET_PACKAGE_SIZE',
|
||||
GET_TASKS: 'android.permission.GET_TASKS',
|
||||
GET_TOP_ACTIVITY_INFO: 'android.permission.GET_TOP_ACTIVITY_INFO',
|
||||
GLOBAL_SEARCH: 'android.permission.GLOBAL_SEARCH',
|
||||
HARDWARE_TEST: 'android.permission.HARDWARE_TEST',
|
||||
INJECT_EVENTS: 'android.permission.INJECT_EVENTS',
|
||||
INSTALL_LOCATION_PROVIDER: 'android.permission.INSTALL_LOCATION_PROVIDER',
|
||||
INSTALL_PACKAGES: 'android.permission.INSTALL_PACKAGES',
|
||||
INSTALL_SHORTCUT: 'com.android.launcher.permission.INSTALL_SHORTCUT',
|
||||
INTERNAL_SYSTEM_WINDOW: 'android.permission.INTERNAL_SYSTEM_WINDOW',
|
||||
INTERNET: 'android.permission.INTERNET',
|
||||
KILL_BACKGROUND_PROCESSES: 'android.permission.KILL_BACKGROUND_PROCESSES',
|
||||
LOCATION_HARDWARE: 'android.permission.LOCATION_HARDWARE',
|
||||
MANAGE_ACCOUNTS: 'android.permission.MANAGE_ACCOUNTS',
|
||||
MANAGE_APP_TOKENS: 'android.permission.MANAGE_APP_TOKENS',
|
||||
MANAGE_DOCUMENTS: 'android.permission.MANAGE_DOCUMENTS',
|
||||
MASTER_CLEAR: 'android.permission.MASTER_CLEAR',
|
||||
MEDIA_CONTENT_CONTROL: 'android.permission.MEDIA_CONTENT_CONTROL',
|
||||
MODIFY_AUDIO_SETTINGS: 'android.permission.MODIFY_AUDIO_SETTINGS',
|
||||
MODIFY_PHONE_STATE: 'android.permission.MODIFY_PHONE_STATE',
|
||||
MOUNT_FORMAT_FILESYSTEMS: 'android.permission.MOUNT_FORMAT_FILESYSTEMS',
|
||||
MOUNT_UNMOUNT_FILESYSTEMS: 'android.permission.MOUNT_UNMOUNT_FILESYSTEMS',
|
||||
NFC: 'android.permission.NFC',
|
||||
PERSISTENT_ACTIVITY: 'android.permission.PERSISTENT_ACTIVITY',
|
||||
POST_NOTIFICATIONS: 'android.permission.POST_NOTIFICATIONS',
|
||||
PROCESS_OUTGOING_CALLS: 'android.permission.PROCESS_OUTGOING_CALLS',
|
||||
READ_CALENDAR: 'android.permission.READ_CALENDAR',
|
||||
READ_CALL_LOG: 'android.permission.READ_CALL_LOG',
|
||||
READ_CONTACTS: 'android.permission.READ_CONTACTS',
|
||||
READ_EXTERNAL_STORAGE: 'android.permission.READ_EXTERNAL_STORAGE',
|
||||
READ_FRAME_BUFFER: 'android.permission.READ_FRAME_BUFFER',
|
||||
READ_HISTORY_BOOKMARKS: 'com.android.browser.permission.READ_HISTORY_BOOKMARKS',
|
||||
READ_INPUT_STATE: 'android.permission.READ_INPUT_STATE',
|
||||
READ_LOGS: 'android.permission.READ_LOGS',
|
||||
READ_MEDIA_AUDIO: 'android.permission.READ_MEDIA_AUDIO',
|
||||
READ_MEDIA_IMAGES: 'android.permission.READ_MEDIA_IMAGES',
|
||||
READ_MEDIA_VIDEO: 'android.permission.READ_MEDIA_VIDEO',
|
||||
READ_PHONE_STATE: 'android.permission.READ_PHONE_STATE',
|
||||
READ_PROFILE: 'android.permission.READ_PROFILE',
|
||||
READ_SMS: 'android.permission.READ_SMS',
|
||||
READ_SOCIAL_STREAM: 'android.permission.READ_SOCIAL_STREAM',
|
||||
READ_SYNC_SETTINGS: 'android.permission.READ_SYNC_SETTINGS',
|
||||
READ_SYNC_STATS: 'android.permission.READ_SYNC_STATS',
|
||||
READ_USER_DICTIONARY: 'android.permission.READ_USER_DICTIONARY',
|
||||
READ_VOICEMAIL: 'com.android.voicemail.permission.READ_VOICEMAIL',
|
||||
REBOOT: 'android.permission.REBOOT',
|
||||
RECEIVE_BOOT_COMPLETED: 'android.permission.RECEIVE_BOOT_COMPLETED',
|
||||
RECEIVE_MMS: 'android.permission.RECEIVE_MMS',
|
||||
RECEIVE_SMS: 'android.permission.RECEIVE_SMS',
|
||||
RECEIVE_WAP_PUSH: 'android.permission.RECEIVE_WAP_PUSH',
|
||||
RECORD_AUDIO: 'android.permission.RECORD_AUDIO',
|
||||
REORDER_TASKS: 'android.permission.REORDER_TASKS',
|
||||
RESTART_PACKAGES: 'android.permission.RESTART_PACKAGES',
|
||||
SEND_RESPOND_VIA_MESSAGE: 'android.permission.SEND_RESPOND_VIA_MESSAGE',
|
||||
SEND_SMS: 'android.permission.SEND_SMS',
|
||||
SET_ACTIVITY_WATCHER: 'android.permission.SET_ACTIVITY_WATCHER',
|
||||
SET_ALARM: 'com.android.alarm.permission.SET_ALARM',
|
||||
SET_ALWAYS_FINISH: 'android.permission.SET_ALWAYS_FINISH',
|
||||
SET_ANIMATION_SCALE: 'android.permission.SET_ANIMATION_SCALE',
|
||||
SET_DEBUG_APP: 'android.permission.SET_DEBUG_APP',
|
||||
SET_ORIENTATION: 'android.permission.SET_ORIENTATION',
|
||||
SET_POINTER_SPEED: 'android.permission.SET_POINTER_SPEED',
|
||||
SET_PREFERRED_APPLICATIONS: 'android.permission.SET_PREFERRED_APPLICATIONS',
|
||||
SET_PROCESS_LIMIT: 'android.permission.SET_PROCESS_LIMIT',
|
||||
SET_TIME: 'android.permission.SET_TIME',
|
||||
SET_TIME_ZONE: 'android.permission.SET_TIME_ZONE',
|
||||
SET_WALLPAPER: 'android.permission.SET_WALLPAPER',
|
||||
SET_WALLPAPER_HINTS: 'android.permission.SET_WALLPAPER_HINTS',
|
||||
SIGNAL_PERSISTENT_PROCESSES: 'android.permission.SIGNAL_PERSISTENT_PROCESSES',
|
||||
STATUS_BAR: 'android.permission.STATUS_BAR',
|
||||
SUBSCRIBED_FEEDS_READ: 'android.permission.SUBSCRIBED_FEEDS_READ',
|
||||
SUBSCRIBED_FEEDS_WRITE: 'android.permission.SUBSCRIBED_FEEDS_WRITE',
|
||||
SYSTEM_ALERT_WINDOW: 'android.permission.SYSTEM_ALERT_WINDOW',
|
||||
TRANSMIT_IR: 'android.permission.TRANSMIT_IR',
|
||||
UNINSTALL_SHORTCUT: 'com.android.launcher.permission.UNINSTALL_SHORTCUT',
|
||||
UPDATE_DEVICE_STATS: 'android.permission.UPDATE_DEVICE_STATS',
|
||||
USE_CREDENTIALS: 'android.permission.USE_CREDENTIALS',
|
||||
USE_SIP: 'android.permission.USE_SIP',
|
||||
VIBRATE: 'android.permission.VIBRATE',
|
||||
WAKE_LOCK: 'android.permission.WAKE_LOCK',
|
||||
WRITE_APN_SETTINGS: 'android.permission.WRITE_APN_SETTINGS',
|
||||
WRITE_CALENDAR: 'android.permission.WRITE_CALENDAR',
|
||||
WRITE_CALL_LOG: 'android.permission.WRITE_CALL_LOG',
|
||||
WRITE_CONTACTS: 'android.permission.WRITE_CONTACTS',
|
||||
WRITE_EXTERNAL_STORAGE: 'android.permission.WRITE_EXTERNAL_STORAGE',
|
||||
WRITE_GSERVICES: 'android.permission.WRITE_GSERVICES',
|
||||
WRITE_HISTORY_BOOKMARKS: 'com.android.browser.permission.WRITE_HISTORY_BOOKMARKS',
|
||||
WRITE_PROFILE: 'android.permission.WRITE_PROFILE',
|
||||
WRITE_SECURE_SETTINGS: 'android.permission.WRITE_SECURE_SETTINGS',
|
||||
WRITE_SETTINGS: 'android.permission.WRITE_SETTINGS',
|
||||
WRITE_SMS: 'android.permission.WRITE_SMS',
|
||||
WRITE_SOCIAL_STREAM: 'android.permission.WRITE_SOCIAL_STREAM',
|
||||
WRITE_SYNC_SETTINGS: 'android.permission.WRITE_SYNC_SETTINGS',
|
||||
WRITE_USER_DICTIONARY: 'android.permission.WRITE_USER_DICTIONARY',
|
||||
WRITE_VOICEMAIL: 'com.android.voicemail.permission.WRITE_VOICEMAIL',
|
||||
};
|
||||
|
||||
/**
|
||||
* Check permission
|
||||
*
|
||||
* @param {string} permission The name of the permission
|
||||
* @returns {Promise<AndroidPermissionResponse>} Returns a promise
|
||||
*/
|
||||
@Cordova()
|
||||
checkPermission(permission: string): Promise<AndroidPermissionResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request permission
|
||||
*
|
||||
* @param {string} permission The name of the permission to request
|
||||
* @returns {Promise<AndroidPermissionResponse>}
|
||||
*/
|
||||
@Cordova()
|
||||
requestPermission(permission: string): Promise<AndroidPermissionResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request permissions
|
||||
*
|
||||
* @param {string[]} permissions An array with permissions
|
||||
* @returns {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova()
|
||||
requestPermissions(permissions: string[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function still works now, will not support in the future.
|
||||
*
|
||||
* @param {string} permission The name of the permission
|
||||
* @returns {Promise<AndroidPermissionResponse>} Returns a promise
|
||||
*/
|
||||
@Cordova()
|
||||
hasPermission(permission: string): Promise<AndroidPermissionResponse> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
export interface AndroidPermissionResponse {
|
||||
hasPermission: boolean;
|
||||
}
|
51
src/@awesome-cordova-plugins/plugins/anyline/index.ts
Normal file
51
src/@awesome-cordova-plugins/plugins/anyline/index.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface AnylineOptions {
|
||||
// Valid License Key
|
||||
licenseKey: string;
|
||||
|
||||
// Scanning options
|
||||
config: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Anyline
|
||||
* @description
|
||||
* Anyline provides an easy-to-use SDK for applications to enable Optical Character Recognition (OCR) on mobile devices.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Anyline } from '@awesome-cordova-plugins/anyline/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private anyline: Anyline) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.anyline.scan(options)
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Anyline',
|
||||
plugin: 'io-anyline-cordova',
|
||||
pluginRef: 'Anyline',
|
||||
repo: 'https://github.com/Anyline/anyline-ocr-cordova-module',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Anyline extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Scan
|
||||
*
|
||||
* @param options {AnylineOptions} Scanning options
|
||||
* @returns {Promise<any>} Returns a promise that resolves when Code is captured
|
||||
*/
|
||||
@Cordova()
|
||||
scan(options: AnylineOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name App Availability
|
||||
* @description
|
||||
* This plugin allows you to check if an app is installed on the user's device. It requires an URI Scheme (e.g. twitter://) on iOS or a Package Name (e.g com.twitter.android) on Android.
|
||||
*
|
||||
* Requires Cordova plugin: cordova-plugin-appavailability. For more info, please see the [AppAvailability plugin docs](https://github.com/ohh2ahh/AppAvailability).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AppAvailability } from '@awesome-cordova-plugins/app-availability/ngx';
|
||||
* import { Platform } from 'ionic-angular';
|
||||
*
|
||||
* constructor(private appAvailability: AppAvailability, private platform: Platform) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* let app;
|
||||
*
|
||||
* if (this.platform.is('ios')) {
|
||||
* app = 'twitter://';
|
||||
* } else if (this.platform.is('android')) {
|
||||
* app = 'com.twitter.android';
|
||||
* }
|
||||
*
|
||||
* this.appAvailability.check(app)
|
||||
* .then(
|
||||
* (yes: boolean) => console.log(app + ' is available'),
|
||||
* (no: boolean) => console.log(app + ' is NOT available')
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AppAvailability',
|
||||
plugin: 'cordova-plugin-appavailability',
|
||||
pluginRef: 'appAvailability',
|
||||
repo: 'https://github.com/ohh2ahh/AppAvailability',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AppAvailability extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Checks if an app is available on device
|
||||
*
|
||||
* @param {string} app Package name on android, or URI scheme on iOS
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
check(app: string): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface StringMap {
|
||||
[s: string]: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name App Center Analytics
|
||||
* @description
|
||||
* App Center Analytics helps you understand user behavior and customer engagement to improve your app.
|
||||
* The SDK automatically captures session count and device properties like model, OS version, etc.
|
||||
* You can define your own custom events to measure things that matter to you.
|
||||
* All the information captured is available in the App Center portal for you to analyze the data.
|
||||
*
|
||||
* For more info, please see https://docs.microsoft.com/en-us/appcenter/sdk/analytics/cordova
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AppCenterAnalytics } from '@awesome-cordova-plugins/app-center-analytics/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private appCenterAnalytics: AppCenterAnalytics) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.appCenterAnalytics.setEnabled(true).then(() => {
|
||||
* this.appCenterAnalytics.trackEvent('My Event', { TEST: 'HELLO_WORLD' }).then(() => {
|
||||
* console.log('Custom event tracked');
|
||||
* });
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* StringMap
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AppCenterAnalytics',
|
||||
plugin: 'cordova-plugin-appcenter-analytics',
|
||||
pluginRef: 'AppCenter.Analytics',
|
||||
repo: 'https://github.com/Microsoft/appcenter-sdk-cordova/tree/master/cordova-plugin-appcenter-analytics',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AppCenterAnalytics extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Tracks an custom event.
|
||||
* You can send up to 200 distinct event names. Also, there is a maximum limit of 256 characters per event name
|
||||
* and 64 characters per event property name and event property value.
|
||||
*
|
||||
* @param {string} eventName Event name
|
||||
* @param {StringMap} properties Event properties
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
trackEvent(eventName: string, properties: StringMap): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if App Center Analytics is enabled
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
isEnabled(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable App Center Analytics at runtime
|
||||
*
|
||||
* @param {boolean} shouldEnable Set value
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
setEnabled(shouldEnable: boolean): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
118
src/@awesome-cordova-plugins/plugins/app-center-crashes/index.ts
Normal file
118
src/@awesome-cordova-plugins/plugins/app-center-crashes/index.ts
Normal file
@ -0,0 +1,118 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface AppCenterCrashReport {
|
||||
id: string;
|
||||
device: AppCenterCrashReportDevice;
|
||||
appStartTime: number;
|
||||
appErrorTime: number;
|
||||
signal: string;
|
||||
appProcessIdentifier: number;
|
||||
}
|
||||
|
||||
export interface AppCenterCrashReportDevice {
|
||||
oem_name: string;
|
||||
os_name: string;
|
||||
app_version: string;
|
||||
time_zone_offset: number;
|
||||
carrier_name: string;
|
||||
screen_size: string;
|
||||
locale: string;
|
||||
sdk_version: string;
|
||||
carrier_country: string;
|
||||
os_build: string;
|
||||
app_namespace: string;
|
||||
os_version: string;
|
||||
sdk_name: string;
|
||||
model: string;
|
||||
app_build: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name App Center Crashes
|
||||
* @description
|
||||
* App Center Analytics helps you understand user behavior and customer engagement to improve your app.
|
||||
* The SDK automatically captures session count and device properties like model, OS version, etc.
|
||||
* You can define your own custom events to measure things that matter to you.
|
||||
* All the information captured is available in the App Center portal for you to analyze the data.
|
||||
*
|
||||
* For more info, please see https://docs.microsoft.com/en-us/appcenter/sdk/crashes/cordova
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AppCenterCrashes } from '@awesome-cordova-plugins/app-center-crashes/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private AppCenterCrashes: AppCenterCrashes) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.AppCenterCrashes.setEnabled(true).then(() => {
|
||||
* this.AppCenterCrashes.lastSessionCrashReport().then(report => {
|
||||
* console.log('Crash report', report);
|
||||
* });
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* AppCenterCrashReport
|
||||
* AppCenterCrashReportDevice
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AppCenterCrashes',
|
||||
plugin: 'cordova-plugin-appcenter-crashes',
|
||||
pluginRef: 'AppCenter.Crashes',
|
||||
repo: 'https://github.com/Microsoft/appcenter-sdk-cordova/tree/master/cordova-plugin-appcenter-crashes',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AppCenterCrashes extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* App Center Crashes provides you with an API to generate a test crash for easy testing of the SDK.
|
||||
* This API can only be used in test/beta apps and won't do anything in production apps.
|
||||
*
|
||||
* @returns void
|
||||
*/
|
||||
@Cordova()
|
||||
generateTestCrash(): void {}
|
||||
|
||||
/**
|
||||
* At any time after starting the SDK, you can check if the app crashed in the previous launch
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
hasCrashedInLastSession(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Details about the last crash
|
||||
*
|
||||
* @returns {Promise<AppCenterCrashReport>}
|
||||
*/
|
||||
@Cordova()
|
||||
lastSessionCrashReport(): Promise<AppCenterCrashReport> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if App Center Crashes is enabled
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
isEnabled(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable App Center Crashes at runtime
|
||||
*
|
||||
* @param {boolean} shouldEnable Set value
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
setEnabled(shouldEnable: boolean): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name App Center Low Memory
|
||||
* @description
|
||||
* Generates a low memory warning.
|
||||
* For more info, please see: https://github.com/Microsoft/appcenter-sdk-cordova/tree/master/cordova-plugin-appcenter-generate-low-memory
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { LowMemory } from '@awesome-cordova-plugins/app-center-low-memory/ngx';
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* constructor(private lowMemory: LowMemory) { }
|
||||
*
|
||||
* async warning() {
|
||||
* await this.lowMemory.generateLowMemory();
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'LowMemory',
|
||||
plugin: 'https://github.com/Microsoft/appcenter-sdk-cordova/tree/master/cordova-plugin-appcenter-generate-low-memory',
|
||||
pluginRef: 'LowMemory',
|
||||
repo: 'https://github.com/Microsoft/appcenter-sdk-cordova/tree/master/cordova-plugin-appcenter-generate-low-memory',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class LowMemory extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Generates a low memory warning.
|
||||
* For more info, please see: https://github.com/Microsoft/appcenter-sdk-cordova/tree/master/cordova-plugin-appcenter-generate-low-memory
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
generateLowMemory(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/**
|
||||
* @name App Center Push
|
||||
* @description
|
||||
*
|
||||
* For more info, please see https://docs.microsoft.com/en-us/appcenter/sdk/push/cordova
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AppCenterPush } from '@awesome-cordova-plugins/app-center-push/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private appCenterPush: AppCenterPush) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.appCenterPush.setEnabled(true).then(() => {
|
||||
* this.appCenterPush.addEventListener('My Event').subscribe(pushNotification => {
|
||||
* console.log('Recived push notification', pushNotification);
|
||||
* });
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AppCenterPush',
|
||||
plugin: 'cordova-plugin-appcenter-push',
|
||||
pluginRef: 'AppCenter.Push',
|
||||
repo: 'https://github.com/Microsoft/appcenter-sdk-cordova/tree/master/cordova-plugin-appcenter-push',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AppCenterPush extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Subscribe to an event
|
||||
*
|
||||
* @param {string} eventName Event name
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
clearFunction: 'removeEventListener',
|
||||
})
|
||||
addEventListener(eventName: string): Observable<any> {
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Check if App Center Push is enabled
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
isEnabled(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable App Center Push at runtime
|
||||
*
|
||||
* @param {boolean} shouldEnable Set value
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
setEnabled(shouldEnable: boolean): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name App Center Shared
|
||||
* @capacitorincompatible true
|
||||
* @description
|
||||
* Exposes additional shared APIs for App Center.
|
||||
*
|
||||
* For more info, please see https://docs.microsoft.com/en-us/appcenter/sdk/other-apis/cordova
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AppCenter } from '@awesome-cordova-plugins/app-center-shared/ngx';
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* constructor(private appCenterShared: AppCenter) { }
|
||||
*
|
||||
* async getInstallId() {
|
||||
* const id = await this.appCenter.getInstallId();
|
||||
* }
|
||||
*
|
||||
* async setUserId() {
|
||||
* try{
|
||||
* await this.appCenter.setUserId('i-am-john');
|
||||
* } catch (e){
|
||||
* console.log(e);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AppCenter',
|
||||
plugin: 'cordova-plugin-appcenter-shared',
|
||||
pluginRef: 'AppCenter',
|
||||
repo: 'https://github.com/Microsoft/appcenter-sdk-cordova/tree/master/cordova-plugin-appcenter-shared',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AppCenter extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Returns AppCenter UUID.
|
||||
* For more info, please see: https://docs.microsoft.com/en-us/appcenter/sdk/other-apis/cordova#identify-installations
|
||||
*
|
||||
* @returns {Promise<string>} Install ID
|
||||
*/
|
||||
@Cordova()
|
||||
getInstallId(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a user ID that's used to augment crash reports.
|
||||
* For more info, please see: https://docs.microsoft.com/en-us/appcenter/sdk/other-apis/cordova#identify-users
|
||||
*
|
||||
* @param {string} userId Ex. "your-user-id"
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
setUserId(userId: string): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
159
src/@awesome-cordova-plugins/plugins/app-preferences/index.ts
Normal file
159
src/@awesome-cordova-plugins/plugins/app-preferences/index.ts
Normal file
@ -0,0 +1,159 @@
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
/**
|
||||
* @name App Preferences
|
||||
* @description
|
||||
* This plugin allows you to read and write app preferences
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AppPreferences } from '@awesome-cordova-plugins/app-preferences/ngx';
|
||||
*
|
||||
* constructor(private appPreferences: AppPreferences) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.appPreferences.fetch('key').then((res) => { console.log(res); });
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AppPreferences',
|
||||
plugin: 'cordova-plugin-app-preferences',
|
||||
pluginRef: 'plugins.appPreferences',
|
||||
repo: 'https://github.com/apla/me.apla.cordova.app-preferences',
|
||||
platforms: ['Android', 'BlackBerry 10', 'Browser', 'iOS', 'macOS', 'Windows 8', 'Windows Phone'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AppPreferences extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Get a preference value
|
||||
*
|
||||
* @param {string} dict Dictionary for key (OPTIONAL)
|
||||
* @param {string} key Key
|
||||
* @returns {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
fetch(dict: string, key?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a preference value
|
||||
*
|
||||
* @param {string} dict Dictionary for key (OPTIONAL)
|
||||
* @param {string} key Key
|
||||
* @param {any} value Value
|
||||
* @returns {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
store(dict: string, key: string, value?: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove value from preferences
|
||||
*
|
||||
* @param {string} dict Dictionary for key (OPTIONAL)
|
||||
* @param {string} key Key
|
||||
* @returns {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
remove(dict: string, key?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear preferences
|
||||
*
|
||||
* @returns {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
clearAll(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show native preferences interface
|
||||
*
|
||||
* @returns {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
show(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show native preferences interface
|
||||
*
|
||||
* @param {boolean} subscribe true value to subscribe, false - unsubscribe
|
||||
* @returns {Observable<any>} Returns an observable
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
})
|
||||
watch(subscribe: boolean): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return named configuration context
|
||||
* In iOS you'll get a suite configuration, on Android — named file
|
||||
* Supports: Android, iOS
|
||||
*
|
||||
* @param {string} suiteName suite name
|
||||
* @returns {Object} Custom object, bound to that suite
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
suite(suiteName: string): any {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
sync: true,
|
||||
})
|
||||
iosSuite(suiteName: string): any {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cloud synchronized configuration context
|
||||
* Currently supports Windows and iOS/macOS
|
||||
*
|
||||
* @returns {Object} Custom object, bound to that suite
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS', 'Windows', 'Windows Phone 8'],
|
||||
})
|
||||
cloudSync(): Object {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return default configuration context
|
||||
* Currently supports Windows and iOS/macOS
|
||||
*
|
||||
* @returns {Object} Custom Object, bound to that suite
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS', 'Windows', 'Windows Phone 8'],
|
||||
})
|
||||
defaults(): Object {
|
||||
return;
|
||||
}
|
||||
}
|
295
src/@awesome-cordova-plugins/plugins/app-rate/index.ts
Normal file
295
src/@awesome-cordova-plugins/plugins/app-rate/index.ts
Normal file
@ -0,0 +1,295 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, CordovaProperty, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export enum AppRateReviewTypeIos {
|
||||
/**
|
||||
* Write review directly in your application (iOS 10.3+), limited to 3 prompts per year.
|
||||
* Will fallback to 'AppStoreReview' for other iOS versions
|
||||
*/
|
||||
InAppReview = 'InAppReview',
|
||||
/**
|
||||
* Open the store within the app. Use this option as an alternative to inAppReview to avoid the rate action from doing nothing
|
||||
*/
|
||||
AppStoreReview = 'AppStoreReview',
|
||||
/**
|
||||
* Open the store using the openUrl preference (defaults to InAppBrowser). Be advised that WKWebView might not open the app store links
|
||||
*/
|
||||
InAppBrowser = 'InAppBrowser',
|
||||
}
|
||||
|
||||
export enum AppRateReviewTypeAndroid {
|
||||
/**
|
||||
* Write review directly in your application. Will fallback to InAppBrowser if not available
|
||||
*/
|
||||
InAppReview = 'InAppReview',
|
||||
/**
|
||||
* Open the store using the openUrl preference (defaults to InAppBrowser)
|
||||
*/
|
||||
InAppBrowser = 'InAppBrowser',
|
||||
}
|
||||
|
||||
export enum AppRatePromptType {
|
||||
/**
|
||||
* Prompt asking to rate the app.
|
||||
*/
|
||||
AppRatingPrompt = 'AppRatingPrompt',
|
||||
|
||||
/**
|
||||
* Prompt asking to rate the app within the store.
|
||||
*/
|
||||
StoreRatingPrompt = 'StoreRatingPrompt',
|
||||
|
||||
/**
|
||||
* Prompt asking to give feedback.
|
||||
*/
|
||||
FeedbackPrompt = 'FeedbackPrompt',
|
||||
}
|
||||
|
||||
export interface AppRatePreferences {
|
||||
/**
|
||||
* Custom BCP 47 language tag
|
||||
*/
|
||||
useLanguage?: string;
|
||||
|
||||
/**
|
||||
* Custom application title
|
||||
*/
|
||||
displayAppName?: string;
|
||||
|
||||
/**
|
||||
* Show dialog again when application version will be updated. Defaults to `true`
|
||||
*/
|
||||
promptAgainForEachNewVersion?: boolean;
|
||||
|
||||
/**
|
||||
* count of runs of application before dialog will be displayed. Defaults to `3`
|
||||
*/
|
||||
usesUntilPrompt?: number;
|
||||
|
||||
reviewType?: {
|
||||
/**
|
||||
* the type of review display to show the user on iOS
|
||||
* Default: AppStoreReview
|
||||
*/
|
||||
ios?: AppRateReviewTypeIos;
|
||||
/**
|
||||
* the type of review display to show the user on Android
|
||||
* Default: InAppBrowser
|
||||
*/
|
||||
android?: AppRateReviewTypeAndroid;
|
||||
};
|
||||
|
||||
/**
|
||||
* Simple Mode to display the rate dialog directly and bypass negative feedback filtering flow
|
||||
*/
|
||||
simpleMode?: boolean;
|
||||
|
||||
/**
|
||||
* Disabling would skip displaying a rate dialog if in app review is set and available. Defaults to `true`
|
||||
*/
|
||||
showPromptForInAppReview?: boolean;
|
||||
|
||||
/**
|
||||
* Custom locale object
|
||||
*/
|
||||
customLocale?: AppRateCustomLocale;
|
||||
|
||||
/**
|
||||
* Callbacks for events
|
||||
*/
|
||||
callbacks?: AppRateCallbacks;
|
||||
|
||||
/**
|
||||
* App Store URLS
|
||||
*/
|
||||
storeAppURL?: AppUrls;
|
||||
|
||||
/**
|
||||
* Open URL function
|
||||
*/
|
||||
openUrl?: (url: string) => void;
|
||||
}
|
||||
|
||||
export interface AppRateCustomLocale {
|
||||
/** Title */
|
||||
title?: string;
|
||||
|
||||
/** Message */
|
||||
message?: string;
|
||||
|
||||
/** Cancel button label */
|
||||
cancelButtonLabel?: string;
|
||||
|
||||
/** Later button label */
|
||||
laterButtonLabel?: string;
|
||||
|
||||
/** Rate button label */
|
||||
rateButtonLabel?: string;
|
||||
|
||||
/** Yes button label */
|
||||
yesButtonLabel?: string;
|
||||
|
||||
/** No button label */
|
||||
noButtonLabel?: string;
|
||||
|
||||
/** App rate prompt title */
|
||||
appRatePromptTitle?: string;
|
||||
|
||||
/** Feedback prompt title */
|
||||
feedbackPromptTitle?: string;
|
||||
|
||||
/** Feedback prompt message */
|
||||
appRatePromptMessage?: string;
|
||||
|
||||
/** Feedback prompt message */
|
||||
feedbackPromptMessage?: string;
|
||||
}
|
||||
|
||||
export interface AppRateLocales {
|
||||
addLocale(localeObject: AppRateCustomLocale): AppRateCustomLocale;
|
||||
|
||||
getLocale(language: string, applicationTitle?: string, customLocale?: AppRateCustomLocale): AppRateCustomLocale;
|
||||
|
||||
getLocalesNames(): { [prop: string]: AppRateCustomLocale };
|
||||
}
|
||||
|
||||
export interface AppRateCallbacks {
|
||||
/**
|
||||
* call back function. called when user clicked on rate-dialog buttons
|
||||
*/
|
||||
onButtonClicked?: (buttonIndex: number, buttonLabel: string, promptType: AppRatePromptType) => void;
|
||||
|
||||
/**
|
||||
* call back function. called when rate-dialog showing
|
||||
*/
|
||||
onRateDialogShow?: (rateCallback: (buttonIndex: number) => void) => void;
|
||||
/**
|
||||
* call back function. called when user clicked on negative feedback
|
||||
*/
|
||||
handleNegativeFeedback?: () => void;
|
||||
|
||||
done?: () => void;
|
||||
}
|
||||
|
||||
export interface AppUrls {
|
||||
/**
|
||||
* application id in AppStore
|
||||
*/
|
||||
ios?: string;
|
||||
|
||||
/**
|
||||
* application URL in GooglePlay
|
||||
*/
|
||||
android?: string;
|
||||
|
||||
/**
|
||||
* application URL in Windows Store
|
||||
*/
|
||||
windows?: string;
|
||||
|
||||
/**
|
||||
* application URL in AppWorld
|
||||
*/
|
||||
blackberry?: string;
|
||||
|
||||
/**
|
||||
* application URL in WindowsStore
|
||||
*/
|
||||
windows8?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name App Rate
|
||||
* @premier app-rate
|
||||
* @description
|
||||
* The AppRate plugin makes it easy to prompt the user to rate your app, either now, later, or never.
|
||||
*
|
||||
* Requires Cordova plugin: cordova-plugin-apprate. For more info, please see the [AppRate plugin docs](https://github.com/pushandplay/cordova-plugin-apprate).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AppRate } from '@awesome-cordova-plugins/app-rate/ngx';
|
||||
*
|
||||
* constructor(private appRate: AppRate) { }
|
||||
*
|
||||
* ...
|
||||
* // set certain preferences
|
||||
* this.appRate.setPreferences({
|
||||
* storeAppURL: {
|
||||
* ios: '<app_id>',
|
||||
* android: 'market://details?id=<package_name>',
|
||||
* windows: 'ms-windows-store://review/?ProductId=<store_id>'
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* this.appRate.promptForRating(true);
|
||||
*
|
||||
* // or, override the whole preferences object
|
||||
* this.appRate.setPreferences({
|
||||
* usesUntilPrompt: 3,
|
||||
* storeAppURL: {
|
||||
* ios: '<app_id>',
|
||||
* android: 'market://details?id=<package_name>',
|
||||
* windows: 'ms-windows-store://review/?ProductId=<store_id>'
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* this.appRate.promptForRating(false);
|
||||
* ```
|
||||
* @interfaces
|
||||
* AppRatePreferences
|
||||
* AppUrls
|
||||
* AppRateCallbacks
|
||||
* AppRateCustomLocal
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AppRate',
|
||||
plugin: 'cordova-plugin-apprate',
|
||||
pluginRef: 'AppRate',
|
||||
repo: 'https://github.com/pushandplay/cordova-plugin-apprate',
|
||||
platforms: ['Android', 'BlackBerry 10', 'iOS', 'Windows'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AppRate extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Manager custom locales
|
||||
*/
|
||||
@CordovaProperty()
|
||||
locales: AppRateLocales;
|
||||
|
||||
/**
|
||||
* Set preferences
|
||||
*
|
||||
* @param pref
|
||||
* @returns void
|
||||
*/
|
||||
@Cordova()
|
||||
setPreferences(pref: AppRatePreferences): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get preferences
|
||||
*
|
||||
* @returns AppRatePreferences
|
||||
*/
|
||||
@Cordova()
|
||||
getPreferences(): AppRatePreferences {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts the user for rating
|
||||
*
|
||||
* @param {boolean} immediately Show the rating prompt immediately.
|
||||
*/
|
||||
@Cordova()
|
||||
promptForRating(immediately?: boolean): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately send the user to the app store rating page
|
||||
*/
|
||||
@Cordova()
|
||||
navigateToAppStore(): void {}
|
||||
}
|
55
src/@awesome-cordova-plugins/plugins/app-review/index.ts
Normal file
55
src/@awesome-cordova-plugins/plugins/app-review/index.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name App Review
|
||||
* @description
|
||||
* Cordova plugin to review app
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AppReview } from '@awesome-cordova-plugins/app-review/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private appReview: AppReview) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.appReview.requestReview()
|
||||
* .then(() => console.log('Success'))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AppReview',
|
||||
plugin: 'cordova-plugin-app-review',
|
||||
pluginRef: 'cordova.plugins.AppReview',
|
||||
repo: 'https://github.com/chemerisuk/cordova-plugin-app-review',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AppReview extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Launches in-app review dialog.
|
||||
*
|
||||
* @returns {Promise<void>} Callback when operation is completed
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
requestReview(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches App/Play store page with a review form. By default current app screen
|
||||
* is displayed but you can pass a package name string to show another app details.
|
||||
*
|
||||
* @param {string} [packageName] Package name to show instead of the current app.
|
||||
* @returns {Promise<void>} Callback when operation is completed
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
openStoreScreen(packageName?: string): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
77
src/@awesome-cordova-plugins/plugins/app-version/index.ts
Normal file
77
src/@awesome-cordova-plugins/plugins/app-version/index.ts
Normal file
@ -0,0 +1,77 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name App Version
|
||||
* @premier app-version
|
||||
* @description
|
||||
* Reads the version of your app from the target build settings.
|
||||
*
|
||||
* Requires Cordova plugin: `cordova-plugin-app-version`. For more info, please see the [Cordova App Version docs](https://github.com/whiteoctober/cordova-plugin-app-version).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AppVersion } from '@awesome-cordova-plugins/app-version/ngx';
|
||||
*
|
||||
* constructor(private appVersion: AppVersion) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.appVersion.getAppName();
|
||||
* this.appVersion.getPackageName();
|
||||
* this.appVersion.getVersionCode();
|
||||
* this.appVersion.getVersionNumber();
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AppVersion',
|
||||
plugin: 'cordova-plugin-app-version',
|
||||
pluginRef: 'cordova.getAppVersion',
|
||||
repo: 'https://github.com/whiteoctober/cordova-plugin-app-version',
|
||||
platforms: ['Android', 'iOS', 'Windows'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AppVersion extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Returns the name of the app, e.g.: "My Awesome App"
|
||||
*
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
@Cordova()
|
||||
getAppName(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the package name of the app, e.g.: "com.example.myawesomeapp"
|
||||
*
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
@Cordova()
|
||||
getPackageName(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the build identifier of the app.
|
||||
* In iOS a string with the build version like "1.6095"
|
||||
* In Android a number generated from the version string, like 10203 for version "1.2.3"
|
||||
*
|
||||
* @returns {Promise<string | number>}
|
||||
*/
|
||||
@Cordova()
|
||||
getVersionCode(): Promise<string | number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the app, e.g.: "1.2.3"
|
||||
*
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
@Cordova()
|
||||
getVersionNumber(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
}
|
230
src/@awesome-cordova-plugins/plugins/apple-wallet/index.ts
Normal file
230
src/@awesome-cordova-plugins/plugins/apple-wallet/index.ts
Normal file
@ -0,0 +1,230 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface EncryptedCardData {
|
||||
activationData: string;
|
||||
encryptedPassData: string;
|
||||
wrappedKey: string;
|
||||
}
|
||||
|
||||
export interface SignatureCertificatesData {
|
||||
certificateSubCA: string;
|
||||
certificateLeaf: string;
|
||||
nonce: string;
|
||||
nonceSignature: string;
|
||||
}
|
||||
|
||||
export interface CardData {
|
||||
cardholderName: string;
|
||||
primaryAccountNumberSuffix: string;
|
||||
localizedDescription?: string;
|
||||
paymentNetwork?: string;
|
||||
}
|
||||
|
||||
export interface PairedDevicesFlags {
|
||||
isInWallet: boolean;
|
||||
isInWatch: boolean;
|
||||
FPANID: string;
|
||||
}
|
||||
|
||||
export interface WatchExistData {
|
||||
isWatchPaired: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Apple Wallet
|
||||
* @description
|
||||
* A Cordova plugin that enables users from Add Payment Cards to their Apple Wallet.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AppleWallet } from '@awesome-cordova-plugins/apple-wallet/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private appleWallet: AppleWallet) { }
|
||||
*
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* // Simple call to determine if the current device supports Apple Pay and has a supported card installed.
|
||||
* this.appleWallet.isAvailable()
|
||||
* .then((res: boolean) => {
|
||||
* // Expect res to be boolean
|
||||
* })
|
||||
* .catch((err) => {
|
||||
* // Catch {{err}} here
|
||||
* });
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* // Simple call to check Card Eligibility
|
||||
* this.appleWallet.checkCardEligibility(primaryAccountIdentifier: string)
|
||||
* .then((res: boolean) => {
|
||||
* // Expect res to be boolean
|
||||
* })
|
||||
* .catch((err) => {
|
||||
* // Catch {{err}} here
|
||||
* });
|
||||
*
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* // Simple call to checkCardEligibilityBySuffix
|
||||
* this.appleWallet.checkCardEligibilityBySuffix(cardSuffix: string)
|
||||
* .then((res: boolean) => {
|
||||
* // Expect res to be boolean
|
||||
* })
|
||||
* .catch((err) => {
|
||||
* // Catch {{err}} here
|
||||
* });
|
||||
*
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Simple call to check out if there is any paired Watches so that you can toggle visibility of 'Add to Watch' button
|
||||
* this.appleWallet.checkPairedDevices()
|
||||
* .then((res: WatchExistData) => {
|
||||
* // object contains boolean flags showing paired devices
|
||||
* })
|
||||
* .catch((err) => {
|
||||
* // Catch {{err}} here
|
||||
* });
|
||||
*
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
*
|
||||
* // Simple call to check paired devices with a card by its suffix
|
||||
* this.appleWallet.checkPairedDevicesBySuffix(cardSuffix: string)
|
||||
* .then((res: PairedDevicesFlags) => {
|
||||
* // object contains boolean values that ensure that card is already exists in wallet or paired-watch
|
||||
* })
|
||||
* .catch((err) => {
|
||||
* // Catch {{err}} here
|
||||
* });
|
||||
*
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* // Simple call with the configuration data needed to instantiate a new PKAddPaymentPassViewController object.
|
||||
* // This method provides the data needed to create a request to add your payment pass (credit/debit card). After a successful callback, pass the certificate chain to your issuer server-side using our callback delegate method `AppleWallet.completeAddPaymentPass`. The issuer server-side should returns an encrypted JSON payload containing the encrypted card data, which is required to be get the final response
|
||||
*
|
||||
* this.appleWallet.startAddPaymentPass(data: cardData)
|
||||
* .then((res: SignatureCertificatesData) => {
|
||||
* // User proceed and successfully asked to add card to his wallet
|
||||
* // Use the callback response JSON payload to complete addition process
|
||||
* })
|
||||
* .catch((err) => {
|
||||
* // Catch {{err}} here
|
||||
* });
|
||||
*
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.appleWallet.completeAddPaymentPass(data: encryptedCardData)
|
||||
* .then((res: string) => {
|
||||
* // Expect res to be string either 'success' or 'error'
|
||||
* })
|
||||
* .catch((err) => {
|
||||
* // Catch {{err}} here
|
||||
* // Error and can not add the card, or something wrong happend
|
||||
* // PKAddPaymentPassViewController will be dismissed
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
* @Interfaces
|
||||
* EncryptedCardData
|
||||
* SignatureCertificatesData
|
||||
* CardData
|
||||
* PairedDevicesFlags
|
||||
* WatchExistData
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AppleWallet',
|
||||
plugin: 'cordova-apple-wallet',
|
||||
pluginRef: 'AppleWallet',
|
||||
repo: 'https://github.com/tomavic/cordova-apple-wallet',
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class AppleWallet extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Simple call to determine if the current device supports Apple Pay and has a supported card installed.
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
isAvailable(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple call to check Card Eligibility
|
||||
*
|
||||
* @param {string} primaryAccountIdentifier
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
checkCardEligibility(primaryAccountIdentifier: string): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple call to checkCardEligibilityBySuffix
|
||||
*
|
||||
* @param {string} cardSuffix
|
||||
* @returns {Promise<PairedDevicesFlags>}
|
||||
*/
|
||||
@Cordova()
|
||||
checkCardEligibilityBySuffix(cardSuffix: string): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple call to check out if there is any paired Watches so that you can toggle visibility of 'Add to Watch' button
|
||||
*
|
||||
* @returns {Promise<WatchExistData>}
|
||||
*/
|
||||
@Cordova()
|
||||
checkPairedDevices(): Promise<WatchExistData> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple call to check paired devices with a card by its suffix
|
||||
*
|
||||
* @param {string} cardSuffix
|
||||
* @returns {Promise<PairedDevicesFlags>}
|
||||
*/
|
||||
@Cordova()
|
||||
checkPairedDevicesBySuffix(cardSuffix: string): Promise<PairedDevicesFlags> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple call with the configuration data needed to instantiate a new PKAddPaymentPassViewController object.
|
||||
*
|
||||
* @param {cardData} data
|
||||
* @returns {Promise<SignatureCertificatesData>}
|
||||
*/
|
||||
@Cordova()
|
||||
startAddPaymentPass(data: CardData): Promise<SignatureCertificatesData> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple completion handler that takes encrypted card data returned from your server side, in order to get the final response from Apple to know if the card is added succesfully or not.
|
||||
*
|
||||
* @param {encryptedCardData} data
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
@Cordova()
|
||||
completeAddPaymentPass(data: EncryptedCardData): Promise<string> {
|
||||
return;
|
||||
}
|
||||
}
|
340
src/@awesome-cordova-plugins/plugins/applovin/index.ts
Normal file
340
src/@awesome-cordova-plugins/plugins/applovin/index.ts
Normal file
@ -0,0 +1,340 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AwesomeCordovaNativePlugin, Cordova, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface InitializeConfig {
|
||||
hasUserConsentValue: boolean;
|
||||
isAgeRestrictedUserValue: boolean;
|
||||
isDoNotSellValue: boolean;
|
||||
isTabletValue: boolean;
|
||||
}
|
||||
|
||||
export interface AdInfo {
|
||||
adUnitId: string;
|
||||
creativeId: string;
|
||||
networkName: string;
|
||||
placement: string;
|
||||
revenue: number;
|
||||
}
|
||||
|
||||
export enum AdViewPosition {
|
||||
TOP_CENTER = 'top_center',
|
||||
TOP_RIGHT = 'top_right',
|
||||
CENTERED = 'centered',
|
||||
CENTER_LEFT = 'center_left',
|
||||
CENTER_RIGHT = 'center_right',
|
||||
BOTTOM_LEFT = 'bottom_left',
|
||||
BOTTOM_CENTER = 'bottom_center',
|
||||
BOTTOM_RIGHT = 'bottom_right',
|
||||
}
|
||||
|
||||
export enum ConsentDialogState {
|
||||
UNKNOWN = 0,
|
||||
APPLIES = 1,
|
||||
DOES_NOT_APPLY = 2,
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Applovin
|
||||
* @description
|
||||
* This plugin allows you to easily configure, integrate and interact with Applovin ads.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Applovin } from '@awesome-cordova-plugins/applovin';
|
||||
*
|
||||
*
|
||||
* constructor(private applovin: Applovin) { }
|
||||
*
|
||||
*
|
||||
* this.applovin.initialize(sdkKey)
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
*
|
||||
* this.applovin.loadInterstitial(adUnitId)
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
*
|
||||
* this.applovin.showInterstitial(adUnitId, placement)
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Applovin',
|
||||
plugin: 'cordova-plugin-applovin-max',
|
||||
pluginRef: 'applovin',
|
||||
repo: 'https://github.com/AppLovin/AppLovin-MAX-Cordova',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Applovin extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Initialize the AppLovin SDK.
|
||||
*
|
||||
* @param {string} sdkKey The SDK key generated for your AppLovin account.
|
||||
*/
|
||||
@Cordova()
|
||||
initialize(sdkKey: string): Promise<InitializeConfig> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
showMediationDebugger(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
getConsentDialogState(): Promise<ConsentDialogState> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setHasUserConsent(hasUserConsent: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
hasUserConsent(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setIsAgeRestrictedUser(isAgeRestrictedUser: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
isAgeRestrictedUser(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setDoNotSell(isDoNotSell: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
isDoNotSell(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
isTablet(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setUserId(userId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setMuted(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setVerboseLogging(verboseLoggingEnabled: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setTestDeviceAdvertisingIds(advertisingIds: string[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
trackEvent(event: string, parameters?: object): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/** BANNERS */
|
||||
|
||||
@Cordova()
|
||||
createBanner(adUnitId: string, position: AdViewPosition): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setBannerBackgroundColor(adUnitId: string, hexColorCode: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setBannerPlacement(adUnitId: string, placement: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setBannerExtraParameter(adUnitId: string, key: string, value: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
showBanner(adUnitId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
hideBanner(adUnitId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
destroyBanner(adUnitId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/** MRECS */
|
||||
|
||||
@Cordova()
|
||||
createMRec(adUnitId: string, position: AdViewPosition): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setMRecBackgroundColor(adUnitId: string, hexColorCode: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setMRecPlacement(adUnitId: string, placement: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setMRecExtraParameter(adUnitId: string, key: string, value: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
showMRec(adUnitId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
hideMRec(adUnitId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
destroyMRec(adUnitId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/** INTERSTITIALS */
|
||||
|
||||
@Cordova()
|
||||
loadInterstitial(adUnitId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
showInterstitial(adUnitId: string, placement?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setInterstitialExtraParameter(adUnitId: string, key: string, value: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'OnInterstitialLoadedEvent',
|
||||
})
|
||||
onInterstitialLoaded(): Observable<AdInfo> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'OnInterstitialLoadFailedEvent',
|
||||
})
|
||||
onInterstitialLoadFailed(): Observable<AdInfo> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'OnInterstitialDisplayedEvent',
|
||||
})
|
||||
onInterstitialDisplayed(): Observable<AdInfo> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'OnInterstitialHiddenEvent',
|
||||
})
|
||||
onInterstitialHidden(): Observable<AdInfo> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'OnInterstitialAdFailedToDisplayEvent',
|
||||
})
|
||||
onInterstitialAdFailedToDisplay(): Observable<AdInfo> {
|
||||
return;
|
||||
}
|
||||
|
||||
/** REWARDED ADS */
|
||||
|
||||
@Cordova()
|
||||
loadRewardedAd(adUnitId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
showRewardedAd(adUnitId: string, placement?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
setRewardedAdExtraParameter(adUnitId: string, key: string, value: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'OnRewardedAdLoadedEvent',
|
||||
})
|
||||
onRewardedAdLoaded(): Observable<AdInfo> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'OnRewardedAdLoadFailedEvent',
|
||||
})
|
||||
onRewardedAdLoadFailed(): Observable<AdInfo> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'OnRewardedAdDisplayedEvent',
|
||||
})
|
||||
onRewardedAdDisplayed(): Observable<AdInfo> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'OnRewardedAdHiddenEvent',
|
||||
})
|
||||
onRewardedAdHidden(): Observable<AdInfo> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'OnRewardedAdAdFailedToDisplayEvent',
|
||||
})
|
||||
onRewardedAdAdFailedToDisplay(): Observable<AdInfo> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,773 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, CordovaProperty, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface HTTPResponse {
|
||||
/**
|
||||
* The HTTP status number of the response or a negative internal error code.
|
||||
*/
|
||||
status: number;
|
||||
/**
|
||||
* The headers of the response.
|
||||
*/
|
||||
headers: { [key: string]: string };
|
||||
/**
|
||||
* The URL of the response. This property will be the final URL obtained after any redirects.
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* The data that is in the response. This property usually exists when a promise returned by a request method resolves.
|
||||
*/
|
||||
data?: any;
|
||||
/**
|
||||
* Error response from the server. This property usually exists when a promise returned by a request method rejects.
|
||||
*/
|
||||
error?: string;
|
||||
}
|
||||
|
||||
interface AbortedResponse {
|
||||
aborted: boolean;
|
||||
}
|
||||
|
||||
export interface ApproovLoggableToken {
|
||||
/**
|
||||
* Expiry
|
||||
* The only mandatory claim for Approov tokens. It specifies the expiry time for the token as a Unix timestamp.
|
||||
*/
|
||||
exp: number;
|
||||
|
||||
/**
|
||||
* Device ID
|
||||
* This claim identifies the device for which the token was issued. This is a base64 encoded string representing a 128-bit device identifier.
|
||||
* Note that this is not, strictly speaking, a device identifier as it is also influenced by the app identifier
|
||||
* and may change if the same app is uninstalled and then reinstalled on the same device.
|
||||
*/
|
||||
did?: string;
|
||||
|
||||
/**
|
||||
* Attestation Response Code
|
||||
* This is an optional claim that encodes information about a subset of the device property flags and also whether the attestation was a pass or fail.
|
||||
* The claim is encoded in base32 and is typically 10 characters long (although it may be longer in some circumstances).
|
||||
* This claim is not included by tokens from the failover.
|
||||
*/
|
||||
arc?: string;
|
||||
|
||||
/**
|
||||
* IP Address
|
||||
* This holds the IP address of the device as seen by the Approov cloud service. It is provided in a human readable IP address format (in either IPv4 or IPv6 format).
|
||||
* In practice this value can often change between the time a token is issued and the time it is sent to your backend, so you should never block if it differs, but you may include it as a signal that tokens have somehow been stolen and are being replayed.
|
||||
* This claim is not included by tokens from the failover or if the IP Tracking Policy for the account has been set to none.
|
||||
*/
|
||||
ip?: string;
|
||||
|
||||
/**
|
||||
* Issuer
|
||||
* An optional claim that is added if the issuer inclusion option is enabled. This provides the Approov account ID that was used to issue the token (suffixed with approov.io).
|
||||
* It can be used as an additional layer of backend verification if signing keys are shared between multiple accounts.
|
||||
* It indicates that tokens were issued from the expected Approov account. This claim may also be set to an explicit value for long lived Approov tokens.
|
||||
* This flexibility is designed for use with server-to-server communication (which may only be signed with the account specific secret keys).
|
||||
*/
|
||||
iss?: string;
|
||||
|
||||
/**
|
||||
* Annotation
|
||||
* This is an embedded JSON array of strings showing the list of flags that are set and are in the annotation set for the security policy that is selected.
|
||||
* This allows additional information to be collected about the state of a particular device without necessarily causing an attestation failure.
|
||||
* Note that if there are no possible annotations then this claim is not present at all. This claim is not included by tokens from the failover.
|
||||
*/
|
||||
anno?: string[];
|
||||
|
||||
/**
|
||||
* Payload Hash
|
||||
* An optional claim that is added if the protected app passes a token binding argument to the setDataHashInToken method.
|
||||
* The claim value is set to the base64 encoded SHA256 hash of the provided payload string.
|
||||
* This is typically used to bind an Approov token to some other data used by your app to enhance security (like a user auth token).
|
||||
*/
|
||||
pay?: string;
|
||||
|
||||
/**
|
||||
* Audience
|
||||
* An optional claim that is added if the audience inclusion option is enabled. This provides the domain for which the token was issued.
|
||||
* It can be used as an additional layer of backend verification to ensure that tokens intended for one domain cannot be used on to access a different one.
|
||||
*/
|
||||
aud?: string;
|
||||
|
||||
/**
|
||||
* Message Siging Key ID
|
||||
* This is an optional claim that encodes the ID of a key being used for Message Signing.
|
||||
* This is only present in Approov tokens for which message signing is active. This claim is not included by tokens from the failover.
|
||||
*/
|
||||
mskid?: string;
|
||||
|
||||
/**
|
||||
* Measurement Proof Key
|
||||
* An optional claim to provide the measurement proof key if a measurement has been requested by the SDK on the domain for which the token is issued.
|
||||
* This is a base64 encoded 128-bit proof key value. Note that if measurement is being used, then JWE tokens will be used to keep this claim secret.
|
||||
*/
|
||||
mpk?: string;
|
||||
|
||||
/**
|
||||
* Integrity Measurement Hash
|
||||
* An optional claim to provide the integrity measurement hash if a measurement has been requested by the SDK on the domain for which the token is issued.
|
||||
* This is a base64 encoded 256-bit SHA256 measurement value. Note that if measurement is being used, then JWE tokens will be used to keep this claim secret.
|
||||
*/
|
||||
imh?: string;
|
||||
|
||||
/**
|
||||
* Device Measurement Hash
|
||||
* An optional claim to provide the device measurement hash if a measurement has been requested by the SDK on the domain for which the token is issued.
|
||||
* This is a base64 encoded 256-bit SHA256 measurement value. Note that if measurement is being used, then JWE tokens will be used to keep this claim secret
|
||||
*/
|
||||
dmh?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name HTTP
|
||||
* @description
|
||||
* Cordova / Phonegap plugin for communicating with HTTP servers. Supports iOS and Android.
|
||||
*
|
||||
* Advantages over Javascript requests:
|
||||
* - SSL / TLS Pinning
|
||||
* - CORS restrictions do not apply
|
||||
* - Handling of HTTP code 401 - read more at [Issue CB-2415](https://issues.apache.org/jira/browse/CB-2415)
|
||||
*
|
||||
* Note: This plugin extends the pre-existing [cordova-advanced-http-plugin](https://github.com/silkimen/cordova-plugin-advanced-http),
|
||||
* we have only added approov functionality on top of it. All credit goes to the actual plugin developer.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { ApproovHttp } from '@awesome-cordova-plugins/http/ngx';
|
||||
*
|
||||
* constructor(private http: ApproovHttp) {}
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.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({
|
||||
pluginName: 'ApproovHttp',
|
||||
plugin: 'cordova-approov-advanced-http',
|
||||
pluginRef: 'cordova.plugin.ApproovHttp',
|
||||
repo: 'https://github.com/approov/quickstart-ionic-advancedhttp',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class ApproovHttp extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* This enum represents the internal error codes which can be returned in a HTTPResponse object.
|
||||
*
|
||||
* @readonly
|
||||
*/
|
||||
@CordovaProperty()
|
||||
readonly ErrorCode: {
|
||||
GENERIC: number;
|
||||
SSL_EXCEPTION: number;
|
||||
SERVER_NOT_FOUND: number;
|
||||
TIMEOUT: number;
|
||||
UNSUPPORTED_URL: number;
|
||||
NOT_CONNECTED: number;
|
||||
POST_PROCESSING_FAILED: number;
|
||||
ABORTED: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* This returns an object representing a basic HTTP Authorization header of the form.
|
||||
*
|
||||
* @param username {string} Username
|
||||
* @param password {string} Password
|
||||
* @returns {Object} an object representing a basic HTTP Authorization header of the form {'Authorization': 'Basic base64EncodedUsernameAndPassword'}
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
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 })
|
||||
useBasicAuth(username: string, password: string): void {}
|
||||
|
||||
/**
|
||||
* Get all headers defined for a given hostname.
|
||||
*
|
||||
* @param host {string} The hostname
|
||||
* @returns {string} return all headers defined for the hostname
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
getHeaders(host: string): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a header for all future requests. Takes a hostname, a header and a value.
|
||||
*
|
||||
* @param host {string} The hostname to be used for scoping this header
|
||||
* @param header {string} The name of the header
|
||||
* @param value {string} The value of the header
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setHeader(host: string, header: string, value: string): void {}
|
||||
|
||||
/**
|
||||
* Get the name of the data serializer which will be used for all future POST and PUT requests.
|
||||
*
|
||||
* @returns {string} returns the name of the configured data serializer
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
getDataSerializer(): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the data serializer which will be used for all future POST, PUT and PATCH requests. Takes a string representing the name of the serializer.
|
||||
*
|
||||
* @param serializer {string} The name of the serializer.
|
||||
* @see https://github.com/silkimen/cordova-plugin-advanced-http#setdataserializer
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setDataSerializer(serializer: 'urlencoded' | 'json' | 'utf8' | 'multipart' | 'raw'): void {}
|
||||
|
||||
/**
|
||||
* Add a custom cookie.
|
||||
*
|
||||
* @param url {string} Scope of the cookie
|
||||
* @param cookie {string} RFC compliant cookie string
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setCookie(url: string, cookie: string): void {}
|
||||
|
||||
/**
|
||||
* Clear all cookies.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
clearCookies(): void {}
|
||||
|
||||
/**
|
||||
* Remove cookies for given URL.
|
||||
*
|
||||
* @param url {string}
|
||||
* @param cb
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
removeCookies(url: string, cb: () => void): void {}
|
||||
|
||||
/**
|
||||
* Resolve cookie string for given URL.
|
||||
*
|
||||
* @param url {string}
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
getCookieString(url: string): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get global request timeout value in seconds.
|
||||
*
|
||||
* @returns {number} returns the global request timeout value
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
getRequestTimeout(): number {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set global request timeout value in seconds.
|
||||
*
|
||||
* @param timeout {number} The timeout in seconds. Default 60
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setRequestTimeout(timeout: number): void {}
|
||||
|
||||
/**
|
||||
* Resolve if it should follow redirects automatically.
|
||||
*
|
||||
* @returns {boolean} returns true if it is configured to follow redirects automatically
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
getFollowRedirect(): boolean {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure if it should follow redirects automatically.
|
||||
*
|
||||
* @param follow {boolean} Set to false to disable following redirects automatically
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setFollowRedirect(follow: boolean): void {}
|
||||
|
||||
/**
|
||||
* Set server trust mode, being one of the following values:
|
||||
* default: default SSL trustship and hostname verification handling using system's CA certs;
|
||||
* legacy: use legacy default behavior (< 2.0.3), excluding user installed CA certs (only for Android);
|
||||
* nocheck: disable SSL certificate checking and hostname verification, trusting all certs (meant to be used only for testing purposes);
|
||||
* pinned: trust only provided certificates;
|
||||
*
|
||||
* @see https://github.com/silkimen/cordova-plugin-advanced-http#setservertrustmode
|
||||
* @param {string} mode server trust mode
|
||||
*/
|
||||
@Cordova()
|
||||
setServerTrustMode(mode: 'default' | 'legacy' | 'nocheck' | 'pinned'): 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
|
||||
* @returns {Promise<HTTPResponse>} returns a promise that will resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
post(url: string, body: any, headers: any): Promise<HTTPResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a sync 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
|
||||
* @param success {function} A callback that is called when the request succeed
|
||||
* @param failure {function} A callback that is called when the request failed
|
||||
* @returns {string} returns a string that represents the requestId
|
||||
*/
|
||||
@Cordova({
|
||||
methodName: 'post',
|
||||
sync: true,
|
||||
})
|
||||
postSync(
|
||||
url: string,
|
||||
body: any,
|
||||
headers: any,
|
||||
success: (result: HTTPResponse) => void,
|
||||
failure: (error: any) => void
|
||||
): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a GET request
|
||||
*
|
||||
* @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
|
||||
* @returns {Promise<HTTPResponse>} returns a promise that will resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
get(url: string, parameters: any, headers: any): Promise<HTTPResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a sync GET request
|
||||
*
|
||||
* @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
|
||||
* @param success {function} A callback that is called when the request succeed
|
||||
* @param failure {function} A callback that is called when the request failed
|
||||
* @returns {string} returns a string that represents the requestId
|
||||
*/
|
||||
@Cordova({
|
||||
methodName: 'get',
|
||||
sync: true,
|
||||
})
|
||||
getSync(
|
||||
url: string,
|
||||
parameters: any,
|
||||
headers: any,
|
||||
success: (result: HTTPResponse) => void,
|
||||
failure: (error: any) => void
|
||||
): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a PUT 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
|
||||
* @returns {Promise<HTTPResponse>} returns a promise that will resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
put(url: string, body: any, headers: any): Promise<HTTPResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a sync PUT 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
|
||||
* @param success {function} A callback that is called when the request succeed
|
||||
* @param failure {function} A callback that is called when the request failed
|
||||
* @returns {string} returns a string that represents the requestId
|
||||
*/
|
||||
@Cordova({
|
||||
methodName: 'put',
|
||||
sync: true,
|
||||
})
|
||||
putSync(
|
||||
url: string,
|
||||
body: any,
|
||||
headers: any,
|
||||
success: (result: HTTPResponse) => void,
|
||||
failure: (error: any) => void
|
||||
): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a PATCH 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
|
||||
* @returns {Promise<HTTPResponse>} returns a promise that will resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
patch(url: string, body: any, headers: any): Promise<HTTPResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a sync PATCH 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
|
||||
* @param success {function} A callback that is called when the request succeed
|
||||
* @param failure {function} A callback that is called when the request failed
|
||||
* @returns {string} returns a string that represents the requestId
|
||||
*/
|
||||
@Cordova({
|
||||
methodName: 'patch',
|
||||
sync: true,
|
||||
})
|
||||
patchSync(
|
||||
url: string,
|
||||
body: any,
|
||||
headers: any,
|
||||
success: (result: HTTPResponse) => void,
|
||||
failure: (error: any) => void
|
||||
): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a DELETE request
|
||||
*
|
||||
* @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
|
||||
* @returns {Promise<HTTPResponse>} returns a promise that will resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
delete(url: string, parameters: any, headers: any): Promise<HTTPResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a sync DELETE request
|
||||
*
|
||||
* @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
|
||||
* @param success {function} A callback that is called when the request succeed
|
||||
* @param failure {function} A callback that is called when the request failed
|
||||
* @returns {string} returns a string that represents the requestId
|
||||
*/
|
||||
@Cordova({
|
||||
methodName: 'delete',
|
||||
sync: true,
|
||||
})
|
||||
deleteSync(
|
||||
url: string,
|
||||
parameters: any,
|
||||
headers: any,
|
||||
success: (result: HTTPResponse) => void,
|
||||
failure: (error: any) => void
|
||||
): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a HEAD request
|
||||
*
|
||||
* @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
|
||||
* @returns {Promise<HTTPResponse>} returns a promise that will resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
head(url: string, parameters: any, headers: any): Promise<HTTPResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a sync HEAD request
|
||||
*
|
||||
* @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
|
||||
* @param success {function} A callback that is called when the request succeed
|
||||
* @param failure {function} A callback that is called when the request failed
|
||||
* @returns {string} returns a string that represents the requestId
|
||||
*/
|
||||
@Cordova({
|
||||
methodName: 'head',
|
||||
sync: true,
|
||||
})
|
||||
headSync(
|
||||
url: string,
|
||||
parameters: any,
|
||||
headers: any,
|
||||
success: (result: HTTPResponse) => void,
|
||||
failure: (error: any) => void
|
||||
): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an OPTIONS request
|
||||
*
|
||||
* @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
|
||||
* @returns {Promise<HTTPResponse>} returns a promise that will resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
options(url: string, parameters: any, headers: any): Promise<HTTPResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an sync OPTIONS request
|
||||
*
|
||||
* @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
|
||||
* @param success {function} A callback that is called when the request succeed
|
||||
* @param failure {function} A callback that is called when the request failed
|
||||
* @returns {string} returns a string that represents the requestId
|
||||
*/
|
||||
@Cordova({
|
||||
methodName: 'options',
|
||||
sync: true,
|
||||
})
|
||||
optionsSync(
|
||||
url: string,
|
||||
parameters: any,
|
||||
headers: any,
|
||||
success: (result: HTTPResponse) => void,
|
||||
failure: (error: any) => void
|
||||
): string {
|
||||
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(s) of the file(s) to upload
|
||||
* @param name {string} The name(s) of the parameter to pass the file(s) along as
|
||||
* @returns {Promise<any>} returns a FileEntry promise that will resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
uploadFile(url: string, body: any, headers: any, filePath: string | string[], name: string | string[]): Promise<any> {
|
||||
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(s) of the file(s) to upload
|
||||
* @param name {string} The name(s) of the parameter to pass the file(s) along as
|
||||
* @param success {function} A callback that is called when the request succeed
|
||||
* @param failure {function} A callback that is called when the request failed
|
||||
* @returns {string} returns a string that represents the requestId
|
||||
*/
|
||||
@Cordova({
|
||||
methodName: 'uploadFile',
|
||||
sync: true,
|
||||
})
|
||||
uploadFileSync(
|
||||
url: string,
|
||||
body: any,
|
||||
headers: any,
|
||||
filePath: string | string[],
|
||||
name: string | string[],
|
||||
success: (result: any) => void,
|
||||
failure: (error: any) => void
|
||||
): string {
|
||||
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 download the file to, including the file name.
|
||||
* @returns {Promise<any>} returns a FileEntry promise that will resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
downloadFile(url: string, body: any, headers: any, filePath: string): Promise<any> {
|
||||
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 download the file to, including the file name.
|
||||
* @param success {function} A callback that is called when the request succeed
|
||||
* @param failure {function} A callback that is called when the request failed
|
||||
* @returns {string} returns a string that represents the requestId
|
||||
*/
|
||||
@Cordova({
|
||||
methodName: 'downloadFile',
|
||||
sync: true,
|
||||
})
|
||||
downloadFileSync(
|
||||
url: string,
|
||||
body: any,
|
||||
headers: any,
|
||||
filePath: string,
|
||||
success: (result: any) => void,
|
||||
failure: (error: any) => void
|
||||
): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param url {string} The url to send the request to
|
||||
* @param options {Object} options for individual request
|
||||
* @param options.method {string} request method
|
||||
* @param options.data {Object} payload to be send to the server (only applicable on post, put or patch methods)
|
||||
* @param options.params {Object} query params to be appended to the URL (only applicable on get, head, delete, upload or download methods)
|
||||
* @param options.serializer {string} data serializer to be used (only applicable on post, put or patch methods), defaults to global serializer value, see setDataSerializer for supported values
|
||||
* @param options.timeout {number} timeout value for the request in seconds, defaults to global timeout value
|
||||
* @param options.headers {Object} headers object (key value pair), will be merged with global values
|
||||
* @param options.filePath {string} file path(s) to be used during upload and download see uploadFile and downloadFile for detailed information
|
||||
* @param options.name {string} name(s) to be used during upload see uploadFile for detailed information
|
||||
* @param options.responseType {string} response type, defaults to text
|
||||
* @returns {Promise<HTTPResponse>} returns a promise that will resolve on success, and reject on failure
|
||||
*/
|
||||
@Cordova()
|
||||
sendRequest(
|
||||
url: string,
|
||||
options: {
|
||||
method: 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete' | 'options' | 'upload' | 'download';
|
||||
data?: { [index: string]: any };
|
||||
params?: { [index: string]: string | number };
|
||||
serializer?: 'json' | 'urlencoded' | 'utf8' | 'multipart' | 'raw';
|
||||
timeout?: number;
|
||||
headers?: { [index: string]: string };
|
||||
filePath?: string | string[];
|
||||
name?: string | string[];
|
||||
responseType?: 'text' | 'arraybuffer' | 'blob' | 'json';
|
||||
}
|
||||
): Promise<HTTPResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param url {string} The url to send the request to
|
||||
* @param options {Object} options for individual request
|
||||
* @param options.method {string} request method
|
||||
* @param options.data {Object} payload to be send to the server (only applicable on post, put or patch methods)
|
||||
* @param options.params {Object} query params to be appended to the URL (only applicable on get, head, delete, upload or download methods)
|
||||
* @param options.serializer {string} data serializer to be used (only applicable on post, put or patch methods), defaults to global serializer value, see setDataSerializer for supported values
|
||||
* @param options.timeout {number} timeout value for the request in seconds, defaults to global timeout value
|
||||
* @param options.headers {Object} headers object (key value pair), will be merged with global values
|
||||
* @param options.filePath {string} file path(s) to be used during upload and download see uploadFile and downloadFile for detailed information
|
||||
* @param options.name {string} name(s) to be used during upload see uploadFile for detailed information
|
||||
* @param options.responseType {string} response type, defaults to text
|
||||
* @param success {function} A callback that is called when the request succeed
|
||||
* @param failure {function} A callback that is called when the request failed
|
||||
* @returns {string} returns a string that represents the requestId
|
||||
*/
|
||||
@Cordova({
|
||||
methodName: 'sendRequest',
|
||||
sync: true,
|
||||
})
|
||||
sendRequestSync(
|
||||
url: string,
|
||||
options: {
|
||||
method: 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete' | 'options' | 'upload' | 'download';
|
||||
data?: { [index: string]: any };
|
||||
params?: { [index: string]: string | number };
|
||||
serializer?: 'json' | 'urlencoded' | 'utf8' | 'multipart';
|
||||
timeout?: number;
|
||||
headers?: { [index: string]: string };
|
||||
filePath?: string | string[];
|
||||
name?: string | string[];
|
||||
responseType?: 'text' | 'arraybuffer' | 'blob' | 'json';
|
||||
},
|
||||
success: (result: HTTPResponse) => void,
|
||||
failure: (error: any) => void
|
||||
): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param requestId {string} The RequestId of the request to abort
|
||||
*/
|
||||
@Cordova()
|
||||
abort(requestId: string): Promise<AbortedResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({ sync: true })
|
||||
initializeApproov(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({ sync: true })
|
||||
approovSetDataHashInToken(dataHash: string): void {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova({ sync: true })
|
||||
approovSetBindingHeader(header: string): void {
|
||||
return;
|
||||
}
|
||||
|
||||
@Cordova()
|
||||
getApproovLoggableToken(host: string): Promise<ApproovLoggableToken> {
|
||||
return;
|
||||
}
|
||||
}
|
212
src/@awesome-cordova-plugins/plugins/appsflyer/index.ts
Normal file
212
src/@awesome-cordova-plugins/plugins/appsflyer/index.ts
Normal file
@ -0,0 +1,212 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface AppsflyerOptions {
|
||||
/**
|
||||
* Appsflyer Dev key
|
||||
*/
|
||||
devKey: string;
|
||||
|
||||
/**
|
||||
* Apple Application ID(for iOS only)
|
||||
*/
|
||||
appId?: string;
|
||||
|
||||
/**
|
||||
* debug mode
|
||||
*/
|
||||
isDebug?: boolean;
|
||||
|
||||
/**
|
||||
* optout of collection of IMEI
|
||||
*/
|
||||
collectIMEI?: boolean;
|
||||
|
||||
/**
|
||||
* optout of collection of collectAndroidID
|
||||
*/
|
||||
collectAndroidID?: boolean;
|
||||
|
||||
/**
|
||||
* default false Accessing AppsFlyer Attribution / Conversion Data from the SDK (Deferred Deeplinking). Read more: Android, iOS. AppsFlyer plugin will return attribution data in onSuccess callback.
|
||||
*/
|
||||
onInstallConversionDataListener?: boolean;
|
||||
|
||||
/**
|
||||
* time for the sdk to wait before launch - IOS 14 ONLY!
|
||||
*/
|
||||
waitForATTUserAuthorization?: number;
|
||||
}
|
||||
|
||||
export interface AppsflyerEvent {
|
||||
[x: string]: any;
|
||||
}
|
||||
|
||||
export interface AppsflyerInviteOptions {
|
||||
channel?: string;
|
||||
campaign?: string;
|
||||
userParams?: {
|
||||
[x: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Appsflyer
|
||||
* @description
|
||||
* Appsflyer Cordova SDK support for Attribution
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Appsflyer } from '@awesome-cordova-plugins/appsflyer/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private appsflyer: Appsflyer) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.appsflyer.initSdk(options);
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* AppsflyerOptions
|
||||
* AppsflyerEvent
|
||||
* AppsflyerInviteOptions
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Appsflyer',
|
||||
plugin: 'cordova-plugin-appsflyer-sdk',
|
||||
pluginRef: 'window.plugins.appsFlyer',
|
||||
repo: 'https://github.com/AppsFlyerSDK/cordova-plugin-appsflyer-sdk',
|
||||
platforms: ['iOS', 'Android'],
|
||||
install: 'Add to config.xml like stated on github and then start',
|
||||
})
|
||||
@Injectable()
|
||||
export class Appsflyer extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* initialize the SDK
|
||||
*
|
||||
* @param {AppsflyerOptions} options
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
initSdk(options: AppsflyerOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* These in-app events help you track how loyal users discover your app, and attribute them to specific campaigns/media-sources. Please take the time define the event/s you want to measure to allow you to track ROI (Return on Investment) and LTV (Lifetime Value).
|
||||
*
|
||||
* @param {string} eventName custom event name, is presented in your dashboard
|
||||
* @param {AppsflyerEvent} eventValues event details
|
||||
*/
|
||||
@Cordova()
|
||||
logEvent(eventName: string, eventValues: AppsflyerEvent): void {}
|
||||
|
||||
/**
|
||||
* Setting your own Custom ID enables you to cross-reference your own unique ID with AppsFlyer’s user ID and the other devices’ IDs. This ID is available in AppsFlyer CSV reports along with postbacks APIs for cross-referencing with you internal IDs.
|
||||
*
|
||||
* @param {string} customerUserId user id
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setAppUserId(customerUserId: string): void {}
|
||||
|
||||
/**
|
||||
* Setting your own Custom ID enables you to cross-reference your own unique ID with AppsFlyer’s user ID and the other devices’ IDs. This ID is available in AppsFlyer CSV reports along with postbacks APIs for cross-referencing with you internal IDs.
|
||||
*
|
||||
* @param {boolean} customerUserId In some extreme cases you might want to shut down all SDK tracking due to legal and privacy compliance. This can be achieved with the isStopTracking API. Once this API is invoked, our SDK will no longer communicate with our servers and stop functioning.
|
||||
* @param isStopTracking
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
Stop(isStopTracking: boolean): void {}
|
||||
|
||||
/**
|
||||
* Get the data from Attribution
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
registerOnAppOpenAttribution(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Enables app uninstall tracking
|
||||
* @param {string} token GCM/FCM ProjectNumber
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
enableUninstallTracking(token: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to pass GCM/FCM Tokens that where collected by third party plugins to the AppsFlyer server. Can be used for Uninstall Tracking.
|
||||
*
|
||||
* @param {string} token GCM/FCM ProjectNumber
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
updateServerUninstallToken(token: string): void {}
|
||||
|
||||
/**
|
||||
* (iOS) Allows to pass APN Tokens that where collected by third party plugins to the AppsFlyer server. Can be used for Uninstall Tracking.
|
||||
*
|
||||
* @param {string} token APN Token
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
registerUninstall(token: string): void {}
|
||||
|
||||
/**
|
||||
* Get AppsFlyer’s proprietary Device ID. The AppsFlyer Device ID is the main ID used by AppsFlyer in Reports and APIs.
|
||||
*/
|
||||
@Cordova()
|
||||
getAppsFlyerUID(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* End User Opt-Out (Optional) AppsFlyer provides you a method to opt‐out specific users from AppsFlyer analytics. This method complies with the latest privacy requirements and complies with Facebook data and privacy policies. Default is FALSE, meaning tracking is enabled by default.
|
||||
*
|
||||
* @param {boolean} disable Set to true to opt-out user from tracking
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
anonymizeUser(disable: boolean): void {}
|
||||
|
||||
/**
|
||||
* Set AppsFlyer’s OneLink ID. Setting a valid OneLink ID will result in shortened User Invite links, when one is generated. The OneLink ID can be obtained on the AppsFlyer Dashboard.
|
||||
*
|
||||
* @param {string} oneLinkId OneLink ID
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setAppInviteOneLinkID(oneLinkId: string): void {}
|
||||
|
||||
/**
|
||||
* Allowing your existing users to invite their friends and contacts as new users to your app can be a key growth factor for your app. AppsFlyer allows you to track and attribute new installs originating from user invites within your app.
|
||||
*
|
||||
* @param {AppsflyerInviteOptions} options Parameters for Invite link
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
generateInviteLink(options: AppsflyerInviteOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this call to track an impression use the following API call. Make sure to use the promoted App ID as it appears within the AppsFlyer dashboard.
|
||||
*
|
||||
* @param {string} appId Promoted Application ID
|
||||
* @param {string} campaign Promoted Campaign
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
logCrossPromotionImpression(appId: string, campaign: string): void {}
|
||||
|
||||
/**
|
||||
* Use this call to track the click and launch the app store's app page (via Browser)
|
||||
*
|
||||
* @param {string} appId Promoted Application ID
|
||||
* @param {string} campaign Promoted Campaign
|
||||
* @param {Object} options Additional Parameters to track
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
logCrossPromotionAndOpenStore(appId: string, campaign: string, options: Object): void {}
|
||||
}
|
113
src/@awesome-cordova-plugins/plugins/background-fetch/index.ts
Normal file
113
src/@awesome-cordova-plugins/plugins/background-fetch/index.ts
Normal file
@ -0,0 +1,113 @@
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
export interface BackgroundFetchConfig {
|
||||
/**
|
||||
* Set true to cease background-fetch from operating after user "closes" the app. Defaults to true.
|
||||
*/
|
||||
stopOnTerminate?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Background Fetch
|
||||
* @description
|
||||
* iOS Background Fetch Implementation. See: https://developer.apple.com/reference/uikit/uiapplication#1657399
|
||||
* iOS Background Fetch is basically an API which wakes up your app about every 15 minutes (during the user's prime-time hours) and provides your app exactly 30s of background running-time. This plugin will execute your provided callbackFn whenever a background-fetch event occurs. There is no way to increase the rate which a fetch-event occurs and this plugin sets the rate to the most frequent possible value of UIApplicationBackgroundFetchIntervalMinimum -- iOS determines the rate automatically based upon device usage and time-of-day (ie: fetch-rate is about ~15min during prime-time hours; less frequently when the user is presumed to be sleeping, at 3am for example).
|
||||
* For more detail, please see https://github.com/transistorsoft/cordova-plugin-background-fetch
|
||||
* @usage
|
||||
*
|
||||
* ```typescript
|
||||
* import { BackgroundFetch, BackgroundFetchConfig } from '@awesome-cordova-plugins/background-fetch/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private backgroundFetch: BackgroundFetch) {
|
||||
*
|
||||
* const config: BackgroundFetchConfig = {
|
||||
* stopOnTerminate: false, // Set true to cease background-fetch from operating after user "closes" the app. Defaults to true.
|
||||
* }
|
||||
*
|
||||
* backgroundFetch.configure(config)
|
||||
* .then(() => {
|
||||
* console.log('Background Fetch initialized');
|
||||
*
|
||||
* this.backgroundFetch.finish();
|
||||
*
|
||||
* })
|
||||
* .catch(e => console.log('Error initializing background fetch', e));
|
||||
*
|
||||
* // Start the background-fetch API. Your callbackFn provided to #configure will be executed each time a background-fetch event occurs. NOTE the #configure method automatically calls #start. You do not have to call this method after you #configure the plugin
|
||||
* backgroundFetch.start();
|
||||
*
|
||||
* // Stop the background-fetch API from firing fetch events. Your callbackFn provided to #configure will no longer be executed.
|
||||
* backgroundFetch.stop();
|
||||
*
|
||||
*
|
||||
* }
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* BackgroundFetchConfig
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BackgroundFetch',
|
||||
plugin: 'cordova-plugin-background-fetch',
|
||||
pluginRef: 'BackgroundFetch',
|
||||
repo: 'https://github.com/transistorsoft/cordova-plugin-background-fetch',
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BackgroundFetch extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Configures the plugin's fetch callbackFn
|
||||
*
|
||||
* @param {BackgroundFetchConfig} config Configuration for plugin
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
configure(config: BackgroundFetchConfig): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the background-fetch API.
|
||||
* Your callbackFn provided to #configure will be executed each time a background-fetch event occurs. NOTE the #configure method automatically calls #start. You do not have to call this method after you #configure the plugin
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
start(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the background-fetch API from firing fetch events. Your callbackFn provided to #configure will no longer be executed.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
stop(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* You MUST call this method in your fetch callbackFn provided to #configure in order to signal to iOS that your fetch action is complete. iOS provides only 30s of background-time for a fetch-event -- if you exceed this 30s, iOS will kill your app.
|
||||
*
|
||||
* @param taskId
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
finish(taskId: string): void {}
|
||||
|
||||
/**
|
||||
* Return the status of the background-fetch
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
status(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,913 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export enum BackgroundGeolocationLocationCode {
|
||||
PERMISSION_DENIED = 1,
|
||||
LOCATION_UNAVAILABLE = 2,
|
||||
TIMEOUT = 3,
|
||||
}
|
||||
|
||||
export enum BackgroundGeolocationNativeProvider {
|
||||
gps = 'gps',
|
||||
network = 'network',
|
||||
passive = 'passive',
|
||||
fused = 'fused',
|
||||
}
|
||||
|
||||
export enum BackgroundGeolocationLocationProvider {
|
||||
DISTANCE_FILTER_PROVIDER = 0,
|
||||
ACTIVITY_PROVIDER = 1,
|
||||
RAW_PROVIDER = 2,
|
||||
}
|
||||
|
||||
export enum BackgroundGeolocationEvents {
|
||||
http_authorization = 'http_authorization', // Triggered when server responded with "<code>401 Unauthorized</code>" to post/sync request.
|
||||
abort_requested = 'abort_requested', // Triggered when server responded with "<code>285 Updates Not Required</code>" to post/sync request.
|
||||
background = 'background', // Triggered when app entered background state and (not visible to the user).
|
||||
foreground = 'foreground', // Triggered when app entered foreground state and (visible to the user).
|
||||
authorization = 'authorization', // Triggered when user changes authorization/permissions for the app or toggles location services.
|
||||
error = 'error', // Register error listener.
|
||||
stop = 'stop', // Triggered when background service has been stopped succesfully.
|
||||
start = 'start', // Event is triggered when background service has been started succesfully.
|
||||
activity = 'activity', // Register activity monitoring listener.
|
||||
stationary = 'stationary', // Register stationary location event listener.
|
||||
location = 'location', // Register location event listener.
|
||||
}
|
||||
|
||||
export enum BackgroundGeolocationAuthorizationStatus {
|
||||
NOT_AUTHORIZED = 0,
|
||||
AUTHORIZED = 1,
|
||||
AUTHORIZED_FOREGROUND = 2,
|
||||
}
|
||||
|
||||
export enum BackgroundGeolocationLogLevel {
|
||||
TRACE = 'TRACE',
|
||||
DEBUG = 'DEBUG',
|
||||
INFO = 'INFO',
|
||||
WARN = 'WARN',
|
||||
ERROR = 'ERROR',
|
||||
}
|
||||
|
||||
export interface BackgroundGeolocationLogEntry {
|
||||
/** ID of log entry as stored in db. */
|
||||
id: number;
|
||||
|
||||
/** Timestamp in milliseconds since beginning of UNIX epoch. */
|
||||
timestamp: number;
|
||||
|
||||
/** Log level */
|
||||
level: BackgroundGeolocationLogLevel;
|
||||
|
||||
/** Log message */
|
||||
message: string;
|
||||
|
||||
/** Recorded stacktrace. (Android only, on iOS part of message) */
|
||||
stackTrace: string;
|
||||
}
|
||||
|
||||
export interface ServiceStatus {
|
||||
/** TRUE if service is running. */
|
||||
isRunning: boolean;
|
||||
|
||||
/** TRUE if location services are enabled */
|
||||
locationServicesEnabled: boolean;
|
||||
|
||||
/**
|
||||
* Authorization status.
|
||||
*
|
||||
* Posible values:
|
||||
* NOT_AUTHORIZED, AUTHORIZED, AUTHORIZED_FOREGROUND
|
||||
*
|
||||
* @example
|
||||
* if (authorization == BackgroundGeolocation.NOT_AUTHORIZED) {...}
|
||||
*/
|
||||
authorization: BackgroundGeolocationAuthorizationStatus;
|
||||
}
|
||||
|
||||
export interface BackgroundGeolocation {
|
||||
code: BackgroundGeolocationLocationCode;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface BackgroundGeolocationCurrentPositionConfig {
|
||||
timeout: number;
|
||||
maximumAge: number;
|
||||
enableHighAccuracy: boolean;
|
||||
}
|
||||
|
||||
export interface BackgroundGeolocationResponse {
|
||||
/** ID of location as stored in DB (or null) */
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* Native provider reponsible for location.
|
||||
*
|
||||
* Possible values:
|
||||
* "gps", "network", "passive" or "fused"
|
||||
*/
|
||||
provider: BackgroundGeolocationNativeProvider;
|
||||
|
||||
/** Configured location provider. */
|
||||
locationProvider: BackgroundGeolocationLocationProvider;
|
||||
|
||||
/** 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.
|
||||
*
|
||||
* Note: Not all providers are capable of providing speed.
|
||||
* Typically network providers are not able to do so.
|
||||
*/
|
||||
speed: number;
|
||||
|
||||
/** Altitude if available, in meters above the WGS 84 reference ellipsoid. */
|
||||
altitude: number;
|
||||
|
||||
/** Bearing, in degrees. */
|
||||
bearing: number;
|
||||
|
||||
/**
|
||||
* True if location was recorded by mock provider. (ANDROID ONLY)
|
||||
*
|
||||
* Note: this property is not enabled by default!
|
||||
* You can enable it "postTemplate" configure option.
|
||||
*/
|
||||
isFromMockProvider?: boolean;
|
||||
|
||||
/**
|
||||
* True if device has mock locations enabled. (ANDROID ONLY)
|
||||
*
|
||||
* Note: this property is not enabled by default!
|
||||
* You can enable it "postTemplate" configure option.
|
||||
*/
|
||||
mockLocationsEnabled?: boolean;
|
||||
}
|
||||
|
||||
export interface BackgroundGeolocationConfig {
|
||||
/**
|
||||
* Set location provider
|
||||
*
|
||||
* Platform: all
|
||||
* Available providers:
|
||||
* DISTANCE_FILTER_PROVIDER,
|
||||
* ACTIVITY_PROVIDER
|
||||
* RAW_PROVIDER
|
||||
*
|
||||
* @default DISTANCE_FILTER_PROVIDER
|
||||
* @example
|
||||
* { locationProvider: LocationProvider.RAW_PROVIDER }
|
||||
*/
|
||||
locationProvider?: number;
|
||||
|
||||
/**
|
||||
* Desired accuracy in meters.
|
||||
*
|
||||
* Platform: all
|
||||
* Provider: all
|
||||
* Possible values:
|
||||
* HIGH_ACCURACY,
|
||||
* MEDIUM_ACCURACY,
|
||||
* LOW_ACCURACY,
|
||||
* PASSIVE_ACCURACY
|
||||
* Note: Accuracy has direct effect on power drain. Lower accuracy = lower power drain.
|
||||
*
|
||||
* @default MEDIUM_ACCURACY
|
||||
* @example
|
||||
* { desiredAccuracy: BackgroundGeolocationAccuracy.LOW }
|
||||
*/
|
||||
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.
|
||||
* Platform: all
|
||||
* Provider: DISTANCE_FILTER
|
||||
*
|
||||
* @default 50
|
||||
*/
|
||||
stationaryRadius?: number;
|
||||
|
||||
/**
|
||||
* When enabled, the plugin will emit sounds for life-cycle events of background-geolocation! See debugging sounds table.
|
||||
*
|
||||
* Platform: all
|
||||
* Provider: all
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
debug?: boolean;
|
||||
|
||||
/**
|
||||
* The minimum distance (measured in meters) a device must move horizontally before an update event is generated.
|
||||
*
|
||||
* Platform: all
|
||||
* Provider: DISTANCE_FILTER, RAW
|
||||
*
|
||||
* @default 500
|
||||
* @see {@link https://apple.co/2oHo2CV|Apple docs}
|
||||
*/
|
||||
distanceFilter?: number;
|
||||
|
||||
/**
|
||||
* Enable this in order to force a stop() when the application terminated.
|
||||
* E.g. on iOS, double-tap home button, swipe away the app.
|
||||
*
|
||||
* Platform: all
|
||||
* Provider: all
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
stopOnTerminate?: boolean;
|
||||
|
||||
/**
|
||||
* Start background service on device boot.
|
||||
*
|
||||
* Platform: Android
|
||||
* Provider: all
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
startOnBoot?: boolean;
|
||||
|
||||
/**
|
||||
* The minimum time interval between location updates in milliseconds.
|
||||
*
|
||||
* Platform: Android
|
||||
* Provider: all
|
||||
*
|
||||
* @default 60000
|
||||
* @see {@link https://bit.ly/1x00RUu|Android docs}
|
||||
*/
|
||||
interval?: number;
|
||||
|
||||
/**
|
||||
* Fastest rate in milliseconds at which your app can handle location updates.
|
||||
*
|
||||
* Platform: Android
|
||||
* Provider: ACTIVITY
|
||||
*
|
||||
* @default 120000
|
||||
* @see {@link https://bit.ly/1x00RUu|Android docs}
|
||||
*/
|
||||
fastestInterval?: number;
|
||||
|
||||
/**
|
||||
* Rate in milliseconds at which activity recognition occurs.
|
||||
* Larger values will result in fewer activity detections while improving battery life.
|
||||
*
|
||||
* Platform: Android
|
||||
* Provider: ACTIVITY
|
||||
*
|
||||
* @default 10000
|
||||
*/
|
||||
activitiesInterval?: number;
|
||||
|
||||
/**
|
||||
* @deprecated Stop location updates, when the STILL activity is detected.
|
||||
*/
|
||||
stopOnStillActivity?: boolean;
|
||||
|
||||
/**
|
||||
* Enable/disable local notifications when tracking and syncing locations.
|
||||
*
|
||||
* Platform: Android
|
||||
* Provider: all
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
notificationsEnabled?: boolean;
|
||||
|
||||
/**
|
||||
* Allow location sync service to run in foreground state.
|
||||
* Foreground state also requires a notification to be presented to the user.
|
||||
*
|
||||
* Platform: Android
|
||||
* Provider: all
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
startForeground?: boolean;
|
||||
|
||||
/**
|
||||
* Custom notification title in the drawer.
|
||||
*
|
||||
* Platform: Android
|
||||
* Provider: all
|
||||
*
|
||||
* @default "Background tracking"
|
||||
*/
|
||||
notificationTitle?: string;
|
||||
|
||||
/**
|
||||
* Custom notification text in the drawer.
|
||||
*
|
||||
* Platform: Android
|
||||
* Provider: all
|
||||
*
|
||||
* @default "ENABLED"
|
||||
*/
|
||||
notificationText?: string;
|
||||
|
||||
/**
|
||||
* The accent color (hex triplet) to use for notification.
|
||||
* Eg. <code>#4CAF50</code>.
|
||||
*
|
||||
* Platform: Android
|
||||
* Provider: all
|
||||
*/
|
||||
notificationIconColor?: string;
|
||||
|
||||
/**
|
||||
* The filename of a custom notification icon.
|
||||
*
|
||||
* Platform: Android
|
||||
* Provider: all
|
||||
*/
|
||||
notificationIconLarge?: string;
|
||||
|
||||
/**
|
||||
* The filename of a custom notification icon.
|
||||
*
|
||||
* Platform: Android
|
||||
* Provider: all
|
||||
*/
|
||||
notificationIconSmall?: string;
|
||||
|
||||
/**
|
||||
* Activity type.
|
||||
* Presumably, this affects iOS GPS algorithm.
|
||||
*
|
||||
* Possible values:
|
||||
* "AutomotiveNavigation", "OtherNavigation", "Fitness", "Other"
|
||||
*
|
||||
* Platform: iOS
|
||||
* Provider: all
|
||||
*
|
||||
* @default "OtherNavigation"
|
||||
* @see {@link https://apple.co/2oHofpH|Apple docs}
|
||||
*/
|
||||
activityType?: string;
|
||||
|
||||
/**
|
||||
* Pauses location updates when app is paused.
|
||||
*
|
||||
* Platform: iOS
|
||||
* Provider: all
|
||||
*
|
||||
* @default false
|
||||
* @see {@link https://apple.co/2CbjEW2|Apple docs}
|
||||
*/
|
||||
pauseLocationUpdates?: boolean;
|
||||
|
||||
/**
|
||||
* Switch to less accurate significant changes and region monitory when in background.
|
||||
*
|
||||
* Platform: iOS
|
||||
* Provider: all
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
saveBatteryOnBackground?: boolean;
|
||||
|
||||
/**
|
||||
* Server url where to send HTTP POST with recorded locations
|
||||
*
|
||||
* Platform: all
|
||||
* Provider: all
|
||||
*/
|
||||
url?: string;
|
||||
|
||||
/**
|
||||
* Server url where to send fail to post locations
|
||||
*
|
||||
* Platform: all
|
||||
* Provider: all
|
||||
*/
|
||||
syncUrl?: string;
|
||||
|
||||
/**
|
||||
* Specifies how many previously failed locations will be sent to server at once.
|
||||
*
|
||||
* Platform: all
|
||||
* Provider: all
|
||||
*
|
||||
* @default 100
|
||||
*/
|
||||
syncThreshold?: number;
|
||||
|
||||
/**
|
||||
* Optional HTTP headers sent along in HTTP request.
|
||||
*
|
||||
* Platform: all
|
||||
* Provider: all
|
||||
*/
|
||||
httpHeaders?: any;
|
||||
|
||||
/**
|
||||
* Limit maximum number of locations stored into db.
|
||||
*
|
||||
* Platform: all
|
||||
* Provider: all
|
||||
*
|
||||
* @default 10000
|
||||
*/
|
||||
maxLocations?: number;
|
||||
|
||||
/**
|
||||
* Customization post template.
|
||||
*
|
||||
* Platform: all
|
||||
* Provider: all
|
||||
*/
|
||||
postTemplate?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set location service provider @see https://github.com/mauron85/cordova-plugin-background-geolocation/wiki/Android-providers
|
||||
*
|
||||
* Possible values:
|
||||
* ANDROID_DISTANCE_FILTER_PROVIDER: 0,
|
||||
* ANDROID_ACTIVITY_PROVIDER: 1
|
||||
*
|
||||
* @enum {number}
|
||||
*/
|
||||
export declare enum BackgroundGeolocationProvider {
|
||||
ANDROID_DISTANCE_FILTER_PROVIDER = 0,
|
||||
ANDROID_ACTIVITY_PROVIDER = 1,
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Possible values:
|
||||
* HIGH: 0
|
||||
* MEDIUM: 10
|
||||
* LOW: 100
|
||||
* PASSIVE: 1000
|
||||
*
|
||||
* enum {number}
|
||||
*/
|
||||
export declare enum BackgroundGeolocationAccuracy {
|
||||
HIGH = 0,
|
||||
MEDIUM = 10,
|
||||
LOW = 100,
|
||||
PASSIVE = 1000,
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in the switchMode function
|
||||
*
|
||||
* Possible values:
|
||||
* BACKGROUND: 0
|
||||
* FOREGROUND: 1
|
||||
*
|
||||
* @enum {number}
|
||||
*/
|
||||
export declare enum BackgroundGeolocationMode {
|
||||
BACKGROUND = 0,
|
||||
FOREGROUND = 1,
|
||||
}
|
||||
|
||||
export declare enum BackgroundGeolocationIOSActivity {
|
||||
AutomotiveNavigation = 'AutomotiveNavigation',
|
||||
OtherNavigation = 'OtherNavigation',
|
||||
Fitness = 'Fitness',
|
||||
Other = 'Other',
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Background Geolocation
|
||||
* @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
|
||||
*
|
||||
* BackgroundGeolocation must be called within app.ts and or before Geolocation. Otherwise the platform will not ask you for background tracking permission.
|
||||
*
|
||||
* ```typescript
|
||||
* import { BackgroundGeolocation, BackgroundGeolocationConfig, BackgroundGeolocationEvents, BackgroundGeolocationResponse } from '@awesome-cordova-plugins/background-geolocation/ngx';
|
||||
*
|
||||
* constructor(private backgroundGeolocation: BackgroundGeolocation) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* const config: BackgroundGeolocationConfig = {
|
||||
* 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
|
||||
* };
|
||||
*
|
||||
* this.backgroundGeolocation.configure(config)
|
||||
* .then(() => {
|
||||
*
|
||||
* this.backgroundGeolocation.on(BackgroundGeolocationEvents.location).subscribe((location: BackgroundGeolocationResponse) => {
|
||||
* console.log(location);
|
||||
*
|
||||
* // 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 operations are successful or not.
|
||||
* // IF YOU DON'T, ios will CRASH YOUR APP for spending too much time in the background.
|
||||
* this.backgroundGeolocation.finish(); // FOR IOS ONLY
|
||||
* });
|
||||
*
|
||||
* });
|
||||
*
|
||||
* // start recording location
|
||||
* this.backgroundGeolocation.start();
|
||||
*
|
||||
* // If you wish to turn OFF background-tracking, call the #stop method.
|
||||
* this.backgroundGeolocation.stop();
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* BackgroundGeolocationResponse
|
||||
* BackgroundGeolocationConfig
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BackgroundGeolocation',
|
||||
plugin: '@mauron85/cordova-plugin-background-geolocation',
|
||||
pluginRef: 'BackgroundGeolocation',
|
||||
repo: 'https://github.com/mauron85/cordova-plugin-background-geolocation',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BackgroundGeolocation extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Configure the plugin.
|
||||
*
|
||||
* @param options {BackgroundGeolocationConfig} options An object of type Config
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
configure(options: BackgroundGeolocationConfig): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn ON the background-geolocation system.
|
||||
* The user will be tracked whenever they suspend the app.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
start(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn OFF background-tracking
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
stop(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform the native plugin that you're finished, the background-task may be completed
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
finish(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force the plugin to enter "moving" or "stationary" state
|
||||
*
|
||||
* @param isMoving {boolean}
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
changePace(isMoving: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup configuration
|
||||
*
|
||||
* @param options {BackgroundGeolocationConfig}
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
setConfig(options: BackgroundGeolocationConfig): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current stationaryLocation if available. null if not
|
||||
*
|
||||
* @returns {Promise<Location>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
getStationaryLocation(): Promise<BackgroundGeolocationResponse> {
|
||||
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
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
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).
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
})
|
||||
isLocationEnabled(): Promise<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display app settings to change permissions
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
showAppSettings(): void {}
|
||||
|
||||
/**
|
||||
* Display device location settings
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
showLocationSettings(): void {}
|
||||
|
||||
/**
|
||||
* 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 (SettingNotFoundException) fail callback will be executed.
|
||||
*
|
||||
* @returns {Observable<number>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
observable: true,
|
||||
})
|
||||
watchLocationMode(): Observable<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop watching for location mode changes.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
})
|
||||
stopWatchingLocationMode(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
})
|
||||
getLocations(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method will return locations, which has not been yet posted to server. NOTE: Locations does contain locationId.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getValidLocations(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete stored location by given locationId.
|
||||
*
|
||||
* @param locationId {number}
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
})
|
||||
deleteLocation(locationId: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored locations.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
})
|
||||
deleteAllLocations(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normally plugin will handle switching between BACKGROUND and FOREGROUND mode itself.
|
||||
* Calling switchMode you can override plugin behavior and force plugin to switch into other mode.
|
||||
*
|
||||
* In FOREGROUND mode plugin uses iOS local manager to receive locations and behavior is affected by option.desiredAccuracy and option.distanceFilter.
|
||||
* In BACKGROUND mode plugin uses significant changes and region monitoring to receive locations and uses option.stationaryRadius only.
|
||||
*
|
||||
* BackgroundGeolocation.Mode.FOREGROUND
|
||||
* BackgroundGeolocation.Mode.BACKGROUND
|
||||
*
|
||||
* @param modeId {number}
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
switchMode(modeId: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all logged events. Useful for plugin debugging. Parameter limit limits number of returned entries.
|
||||
*
|
||||
* @see https://github.com/mauron85/cordova-plugin-background-geolocation/tree/v2.2.1#debugging for more information.
|
||||
* @param fromId
|
||||
* @param minLevel
|
||||
* @param limit {number} Limits the number of entries
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getLogEntries(
|
||||
limit: number,
|
||||
fromId: number,
|
||||
minLevel: BackgroundGeolocationLogLevel
|
||||
): Promise<BackgroundGeolocationLogEntry[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all logged events. Useful for plugin debugging. Parameter limit limits number of returned entries.
|
||||
*
|
||||
* @see https://github.com/mauron85/cordova-plugin-background-geolocation/tree/v2.2.1#debugging for more information.
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getConfig(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* One time location check to get current location of the device.
|
||||
* {timeout: Maximum time in milliseconds device will wait for location,
|
||||
* maximumAge: Maximum age in milliseconds of a possible cached location that is acceptable to return;
|
||||
* enableHighAccuracy: if true and if the device is able to provide a more accurate position, it will do so}
|
||||
*
|
||||
* @param {BackgroundGeolocationCurrentPositionConfig} options
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
getCurrentLocation(options?: BackgroundGeolocationCurrentPositionConfig): Promise<BackgroundGeolocationResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check status of the service
|
||||
*/
|
||||
@Cordova()
|
||||
checkStatus(): Promise<ServiceStatus> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start background task (iOS only)
|
||||
*
|
||||
* To perform any long running operation on iOS
|
||||
* you need to create background task
|
||||
* IMPORTANT: task has to be ended by endTask
|
||||
*
|
||||
* @returns {Promise<number>} taskKey
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['IOS'],
|
||||
})
|
||||
startTask(): Promise<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* End background task indentified by taskKey (iOS only)
|
||||
*
|
||||
* @param taskKey
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['IOS'],
|
||||
})
|
||||
endTask(taskKey: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* A special task that gets executed when the app is terminated, but
|
||||
* the plugin was configured to continue running in the background
|
||||
* (option <code>stopOnTerminate: false</code>).
|
||||
*
|
||||
* In this scenario the Activity was killed by the system and all registered
|
||||
* event listeners will not be triggered until the app is relaunched.
|
||||
*
|
||||
* @example
|
||||
* BackgroundGeolocation.headlessTask(function(event) {
|
||||
*
|
||||
* if (event.name === 'location' || event.name === 'stationary') {
|
||||
* var xhr = new XMLHttpRequest();
|
||||
* xhr.open('POST', 'http://192.168.81.14:3000/headless');
|
||||
* xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
* xhr.send(JSON.stringify(event.params));
|
||||
* }
|
||||
*
|
||||
* return 'Processing event: ' + event.name; // will be logged
|
||||
* });
|
||||
* @param func
|
||||
*/
|
||||
@Cordova()
|
||||
headlessTask(func: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force sync of pending locations.
|
||||
* Option <code>syncThreshold</code> will be ignored and all pending locations will be immediately posted to <code>syncUrl</code> in single batch.
|
||||
*
|
||||
* Platform: Android, iOS
|
||||
*/
|
||||
@Cordova()
|
||||
forceSync(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register event listener.
|
||||
*
|
||||
* Triggered when server responded with "<code>285 Updates Not Required</code>" to post/sync request.
|
||||
*
|
||||
* @param event
|
||||
* @param callbackFn
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
})
|
||||
on(event: BackgroundGeolocationEvents): Observable<BackgroundGeolocationResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister all event listeners for given event.
|
||||
*
|
||||
* If parameter <code>event</code> is not provided then all event listeners will be removed.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Cordova()
|
||||
removeAllListeners(event?: BackgroundGeolocationEvents): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
283
src/@awesome-cordova-plugins/plugins/background-mode/index.ts
Normal file
283
src/@awesome-cordova-plugins/plugins/background-mode/index.ts
Normal file
@ -0,0 +1,283 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Configurations items that can be updated.
|
||||
*/
|
||||
export interface BackgroundModeConfiguration {
|
||||
/**
|
||||
* Title of the background task
|
||||
*/
|
||||
title?: string;
|
||||
|
||||
/**
|
||||
* Description of background task
|
||||
*/
|
||||
text?: string;
|
||||
|
||||
/**
|
||||
* This will look for `<icon name>.png` in platforms/android/res/drawable|mipmap
|
||||
*/
|
||||
icon?: string;
|
||||
|
||||
/**
|
||||
* Set the background color of the notification circle
|
||||
*/
|
||||
color?: string;
|
||||
|
||||
/**
|
||||
* By default the app will come to foreground when tapping on the notification. If false, plugin won't come to foreground when tapped.
|
||||
*/
|
||||
resume?: boolean;
|
||||
|
||||
/**
|
||||
* When set to false makes the notifications visible on lock screen (Android 5.0+)
|
||||
*/
|
||||
hidden?: boolean;
|
||||
|
||||
/** Big text */
|
||||
bigText?: boolean;
|
||||
|
||||
/**
|
||||
* The text that scrolls itself on statusbar
|
||||
*/
|
||||
ticker?: string;
|
||||
|
||||
/**
|
||||
* if true plugin will not display a notification. Default is false.
|
||||
*/
|
||||
silent?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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, visit: https://github.com/katzer/cordova-plugin-background-mode
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { BackgroundMode } from '@awesome-cordova-plugins/background-mode/ngx';
|
||||
*
|
||||
* constructor(private backgroundMode: BackgroundMode) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.backgroundMode.enable();
|
||||
* ```
|
||||
* @interfaces
|
||||
* BackgroundModeConfiguration
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BackgroundMode',
|
||||
plugin: 'cordova-plugin-background-mode',
|
||||
pluginRef: 'cordova.plugins.backgroundMode',
|
||||
repo: 'https://github.com/katzer/cordova-plugin-background-mode',
|
||||
platforms: ['AmazonFire OS', 'Android', 'Browser', 'iOS', 'Windows'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BackgroundMode extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Enable the background mode.
|
||||
* Once called, prevents the app from being paused while in background.
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
enable(): void {}
|
||||
|
||||
/**
|
||||
* Disable the background mode.
|
||||
* Once the background mode has been disabled, the app will be paused when in background.
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
disable(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable the background mode.
|
||||
*
|
||||
* @param enable {boolean} The status to set for.
|
||||
* @returns {void}
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
setEnabled(enable: boolean): void {}
|
||||
|
||||
/**
|
||||
* Fire event with given arguments.
|
||||
*
|
||||
* @param event {string} event The event's name.
|
||||
* @param args {array} The callback's arguments.
|
||||
* @returns {string}
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
fireEvent(event: string, ...args: any[]): string {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if background mode is enabled or not.
|
||||
*
|
||||
* @returns {boolean} returns a boolean that indicates if the background mode is enabled.
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
isEnabled(): boolean {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to get the information if the background mode is active.
|
||||
*
|
||||
* @returns {boolean} returns a boolean that indicates if the background mode is active.
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
isActive(): boolean {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite the default settings.
|
||||
* Available only for Android platform.
|
||||
*
|
||||
* @param overrides {BackgroundModeConfiguration} Dict of options to be overridden.
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
})
|
||||
setDefaults(overrides?: BackgroundModeConfiguration): void {}
|
||||
|
||||
/**
|
||||
* Modify the displayed information.
|
||||
* Available only for Android platform.
|
||||
*
|
||||
* @param {BackgroundModeConfiguration} [options] Any options you want to update. See table below.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
configure(options?: BackgroundModeConfiguration): void {}
|
||||
|
||||
/**
|
||||
* Register callback for given event.
|
||||
* > Available events are `enable`, `disable`, `activate`, `deactivate` and `failure`.
|
||||
*
|
||||
* @param event {string} Event name
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
clearFunction: 'un',
|
||||
clearWithArgs: true,
|
||||
})
|
||||
on(event: string): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen for events that the plugin fires. Available events are `enable`, `disable`, `activate`, `deactivate` and `failure`.
|
||||
*
|
||||
* @param event {string} Event name
|
||||
* @param callback {function} The function to be exec as callback.
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
un(event: string, callback: (...args: any[]) => void): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Android allows to programmatically move from foreground to background.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
moveToBackground(): void {}
|
||||
|
||||
/**
|
||||
* Enable GPS-tracking in background (Android).
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
disableWebViewOptimizations(): void {}
|
||||
|
||||
/**
|
||||
* Android allows to programmatically move from background to foreground.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
moveToForeground(): void {}
|
||||
|
||||
/**
|
||||
* Override the back button on Android to go to background instead of closing the app.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
overrideBackButton(): void {}
|
||||
|
||||
/**
|
||||
* Exclude the app from the recent task list. Works on Android 5.0+.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
excludeFromTaskList(): void {}
|
||||
|
||||
/**
|
||||
* If the screen is off.
|
||||
*
|
||||
* @param fn {function} Callback function to invoke with boolean arg.
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
})
|
||||
isScreenOff(fn: (arg0: boolean) => void): void {}
|
||||
|
||||
/**
|
||||
* Turn screen on
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
wakeUp(): void {}
|
||||
|
||||
/**
|
||||
* Turn screen on and show app even locked
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
unlock(): void {}
|
||||
|
||||
/**
|
||||
* Disables battery optimazation mode for the app (android only)
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
disableBatteryOptimizations(): void {}
|
||||
}
|
111
src/@awesome-cordova-plugins/plugins/background-upload/index.ts
Normal file
111
src/@awesome-cordova-plugins/plugins/background-upload/index.ts
Normal file
@ -0,0 +1,111 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, CordovaInstance, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
declare const window: any;
|
||||
|
||||
export enum UploadState {
|
||||
UPLOADED = 'UPLOADED',
|
||||
FAILED = 'FAILED',
|
||||
UPLOADING = 'UPLOADING',
|
||||
INITIALIZED = 'INITIALIZED',
|
||||
}
|
||||
|
||||
export type UploadStateType = keyof typeof UploadState;
|
||||
|
||||
export interface UploadEvent {
|
||||
id?: string; // id of the upload
|
||||
state?: UploadStateType; // state of the upload (either UPLOADING, UPLOADED or FAILED)
|
||||
statusCode?: number; // response code returned by server after upload is completed
|
||||
serverResponse?: any; // server response received after upload is completed
|
||||
error?: any; // error message in case of failure
|
||||
errorCode?: number; // error code for any exception encountered
|
||||
progress?: any; // progress for ongoing upload
|
||||
eventId?: string; // id of the event
|
||||
}
|
||||
|
||||
export interface FTMPayloadOptions {
|
||||
id: string;
|
||||
filePath: string;
|
||||
fileKey?: string;
|
||||
serverUrl: string;
|
||||
notificationTitle?: string;
|
||||
headers?: {
|
||||
[name: string]: string;
|
||||
};
|
||||
parameters?: {
|
||||
[name: string]: string;
|
||||
};
|
||||
[prop: string]: any;
|
||||
}
|
||||
|
||||
export interface FTMOptions {
|
||||
callBack: (event: UploadEvent) => any;
|
||||
config?: {
|
||||
parallelUploadsLimit?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export class FileTransferManager {
|
||||
private _objectInstance: any;
|
||||
|
||||
constructor(options: FTMOptions) {
|
||||
this._objectInstance = window.FileTransferManager.init(options.config, options.callBack);
|
||||
}
|
||||
|
||||
@CordovaInstance()
|
||||
startUpload(payload: FTMPayloadOptions): void {
|
||||
return;
|
||||
}
|
||||
|
||||
@CordovaInstance()
|
||||
removeUpload(id: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@CordovaInstance()
|
||||
acknowledgeEvent(id: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
@CordovaInstance()
|
||||
destroy(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name BackgroundUpload
|
||||
* @description
|
||||
* This plugin does something
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { BackgroundUpload } from '@awesome-cordova-plugins/background-upload/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private backgroundUpload: BackgroundUpload) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.backgroundUpload.init({})
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BackgroundUpload',
|
||||
plugin: '@spoonconsulting/cordova-plugin-background-upload',
|
||||
pluginRef: 'FileTransferManager',
|
||||
repo: 'https://github.com/spoonconsulting/cordova-plugin-background-upload',
|
||||
install: 'ionic cordova plugin add @spoonconsulting/cordova-plugin-background-upload',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BackgroundUpload extends AwesomeCordovaNativePlugin {
|
||||
FileTransferManager = FileTransferManager;
|
||||
|
||||
init(options: FTMOptions): FileTransferManager {
|
||||
return new FileTransferManager(options);
|
||||
}
|
||||
}
|
117
src/@awesome-cordova-plugins/plugins/badge/index.ts
Normal file
117
src/@awesome-cordova-plugins/plugins/badge/index.ts
Normal file
@ -0,0 +1,117 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name Badge
|
||||
* @premier badge
|
||||
* @description
|
||||
* The essential purpose of badge numbers is to enable an application to inform its users that it has something for them — for example, unread messages — when the application isn’t running in the foreground.
|
||||
*
|
||||
* Requires Cordova plugin: cordova-plugin-badge. For more info, please see the [Badge plugin docs](https://github.com/katzer/cordova-plugin-badge).
|
||||
*
|
||||
* Android Note: Badges have historically only been a feature implemented by third party launchers and not visible unless one of those launchers was being used (E.G. Samsung or Nova Launcher) and if enabled by the user. As of Android 8 (Oreo), [notification badges](https://developer.android.com/training/notify-user/badges) were introduced officially to reflect unread notifications. This plugin is unlikely to work as expected on devices running Android 8 or newer. Please see the [local notifications plugin docs](https://github.com/katzer/cordova-plugin-local-notifications) for more information on badge use with notifications.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Badge } from '@awesome-cordova-plugins/badge/ngx';
|
||||
*
|
||||
* constructor(private badge: Badge) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.badge.set(10);
|
||||
* this.badge.increase(1);
|
||||
* this.badge.clear();
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Badge',
|
||||
plugin: 'cordova-plugin-badge',
|
||||
pluginRef: 'cordova.plugins.notification.badge',
|
||||
repo: 'https://github.com/katzer/cordova-plugin-badge',
|
||||
platforms: ['Android', 'Browser', 'iOS', 'Windows'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Badge extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Clear the badge of the app icon.
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
clear(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the badge of the app icon.
|
||||
*
|
||||
* @param {number} badgeNumber The new badge number.
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
set(badgeNumber: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the badge of the app icon.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
get(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase the badge number.
|
||||
*
|
||||
* @param {number} increaseBy Count to add to the current badge number
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
increase(increaseBy: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the badge number.
|
||||
*
|
||||
* @param {number} decreaseBy Count to subtract from the current badge number
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
decrease(decreaseBy: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check support to show badges.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
isSupported(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the app has permission to show badges.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
hasPermission(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register permission to set badge notifications
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
requestPermission(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
154
src/@awesome-cordova-plugins/plugins/barcode-scanner/index.ts
Normal file
154
src/@awesome-cordova-plugins/plugins/barcode-scanner/index.ts
Normal file
@ -0,0 +1,154 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface BarcodeScannerOptions {
|
||||
/**
|
||||
* Prefer front camera. Supported on iOS and Android.
|
||||
*/
|
||||
preferFrontCamera?: boolean;
|
||||
|
||||
/**
|
||||
* Show flip camera button. Supported on iOS and Android.
|
||||
*/
|
||||
showFlipCameraButton?: boolean;
|
||||
|
||||
/**
|
||||
* Show torch button. Supported on iOS and Android.
|
||||
*/
|
||||
showTorchButton?: boolean;
|
||||
|
||||
/**
|
||||
* Disable animations. Supported on iOS only.
|
||||
*/
|
||||
disableAnimations?: boolean;
|
||||
|
||||
/**
|
||||
* Disable success beep. Supported on iOS only.
|
||||
*/
|
||||
disableSuccessBeep?: boolean;
|
||||
|
||||
/**
|
||||
* Prompt text. Supported on Android only.
|
||||
*/
|
||||
prompt?: string;
|
||||
|
||||
/**
|
||||
* Formats separated by commas. Defaults to all formats except `PDF_417` and `RSS_EXPANDED`.
|
||||
*/
|
||||
formats?: string;
|
||||
|
||||
/**
|
||||
* Orientation. Supported on Android only. Can be set to `portrait` or `landscape`. Defaults to none so the user can rotate the phone and pick an orientation.
|
||||
*/
|
||||
orientation?: string;
|
||||
|
||||
/**
|
||||
* Launch with the torch switched on (if available). Supported on Android only.
|
||||
*/
|
||||
torchOn?: boolean;
|
||||
|
||||
/**
|
||||
* Save scan history. Defaults to `false`. Supported on Android only.
|
||||
*/
|
||||
saveHistory?: boolean;
|
||||
|
||||
/**
|
||||
* Display scanned text for X ms. 0 suppresses it entirely, default 1500. Supported on Android only.
|
||||
*/
|
||||
resultDisplayDuration?: number;
|
||||
}
|
||||
|
||||
export interface BarcodeScanResult {
|
||||
format:
|
||||
| 'QR_CODE'
|
||||
| 'DATA_MATRIX'
|
||||
| 'UPC_E'
|
||||
| 'UPC_A'
|
||||
| 'EAN_8'
|
||||
| 'EAN_13'
|
||||
| 'CODE_128'
|
||||
| 'CODE_39'
|
||||
| 'CODE_93'
|
||||
| 'CODABAR'
|
||||
| 'ITF'
|
||||
| 'RSS14'
|
||||
| 'RSS_EXPANDED'
|
||||
| 'PDF_417'
|
||||
| 'AZTEC'
|
||||
| 'MSI';
|
||||
cancelled: boolean;
|
||||
text: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Barcode Scanner
|
||||
* @description
|
||||
* The Barcode Scanner Plugin opens a camera view and automatically scans a barcode, returning the data back to you.
|
||||
*
|
||||
* Requires Cordova plugin: `phonegap-plugin-barcodescanner`. For more info, please see the [BarcodeScanner plugin docs](https://github.com/phonegap/phonegap-plugin-barcodescanner).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { BarcodeScanner } from '@awesome-cordova-plugins/barcode-scanner/ngx';
|
||||
*
|
||||
* constructor(private barcodeScanner: BarcodeScanner) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.barcodeScanner.scan().then(barcodeData => {
|
||||
* console.log('Barcode data', barcodeData);
|
||||
* }).catch(err => {
|
||||
* console.log('Error', err);
|
||||
* });
|
||||
* ```
|
||||
* @interfaces
|
||||
* BarcodeScannerOptions
|
||||
* BarcodeScanResult
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BarcodeScanner',
|
||||
plugin: 'phonegap-plugin-barcodescanner',
|
||||
pluginRef: 'cordova.plugins.barcodeScanner',
|
||||
repo: 'https://github.com/phonegap/phonegap-plugin-barcodescanner',
|
||||
platforms: ['Android', 'BlackBerry 10', 'Browser', 'iOS', 'Windows'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BarcodeScanner extends AwesomeCordovaNativePlugin {
|
||||
Encode: {
|
||||
TEXT_TYPE: string;
|
||||
EMAIL_TYPE: string;
|
||||
PHONE_TYPE: string;
|
||||
SMS_TYPE: string;
|
||||
} = {
|
||||
TEXT_TYPE: 'TEXT_TYPE',
|
||||
EMAIL_TYPE: 'EMAIL_TYPE',
|
||||
PHONE_TYPE: 'PHONE_TYPE',
|
||||
SMS_TYPE: 'SMS_TYPE',
|
||||
};
|
||||
|
||||
/**
|
||||
* Open the barcode scanner.
|
||||
*
|
||||
* @param {BarcodeScannerOptions} [options] Optional options to pass to the scanner
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with scanner data, or rejects with an error.
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
scan(options?: BarcodeScannerOptions): Promise<BarcodeScanResult> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes data into a barcode.
|
||||
* NOTE: not well supported on Android
|
||||
*
|
||||
* @param {string} type Type of encoding
|
||||
* @param {any} data Data to encode
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
encode(type: string, data: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
89
src/@awesome-cordova-plugins/plugins/battery-status/index.ts
Normal file
89
src/@awesome-cordova-plugins/plugins/battery-status/index.ts
Normal file
@ -0,0 +1,89 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface BatteryStatusResponse {
|
||||
/**
|
||||
* The battery charge percentage
|
||||
*/
|
||||
level: number;
|
||||
|
||||
/**
|
||||
* A boolean that indicates whether the device is plugged in
|
||||
*/
|
||||
isPlugged: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Battery Status
|
||||
* @description
|
||||
* Requires Cordova plugin: cordova-plugin-batterystatus. For more info, please see the [BatteryStatus plugin docs](https://github.com/apache/cordova-plugin-battery-status).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { BatteryStatus } from '@awesome-cordova-plugins/battery-status/ngx';
|
||||
*
|
||||
* constructor(private batteryStatus: BatteryStatus) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* // watch change in battery status
|
||||
* const subscription = this.batteryStatus.onChange().subscribe(status => {
|
||||
* console.log(status.level, status.isPlugged);
|
||||
* });
|
||||
*
|
||||
* // stop watch
|
||||
* subscription.unsubscribe();
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* BatteryStatusResponse
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BatteryStatus',
|
||||
plugin: 'cordova-plugin-battery-status',
|
||||
pluginRef: 'navigator.battery',
|
||||
repo: 'https://github.com/apache/cordova-plugin-battery-status',
|
||||
platforms: ['iOS', 'Android', 'Windows', 'Browser'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BatteryStatus extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Watch the change in battery level
|
||||
*
|
||||
* @returns {Observable<BatteryStatusResponse>} Returns an observable that pushes a status object
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'batterystatus',
|
||||
})
|
||||
onChange(): Observable<BatteryStatusResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Watch when the battery level goes low
|
||||
*
|
||||
* @returns {Observable<BatteryStatusResponse>} Returns an observable that pushes a status object
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'batterylow',
|
||||
})
|
||||
onLow(): Observable<BatteryStatusResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Watch when the battery level goes to critical
|
||||
*
|
||||
* @returns {Observable<BatteryStatusResponse>} Returns an observable that pushes a status object
|
||||
*/
|
||||
@Cordova({
|
||||
eventObservable: true,
|
||||
event: 'batterycritical',
|
||||
})
|
||||
onCritical(): Observable<BatteryStatusResponse> {
|
||||
return;
|
||||
}
|
||||
}
|
107
src/@awesome-cordova-plugins/plugins/biocatch/index.ts
Normal file
107
src/@awesome-cordova-plugins/plugins/biocatch/index.ts
Normal file
@ -0,0 +1,107 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name BioCatch
|
||||
* @description
|
||||
* BioCatch SDK Cordova support
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { BioCatch } from '@awesome-cordova-plugins/biocatch';
|
||||
*
|
||||
*
|
||||
* constructor(private biocatch: BioCatch) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.biocatch.start('customer-session-1', 'http://example.com', 'some-public-key')
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BioCatch',
|
||||
plugin: 'cordova-plugin-biocatch',
|
||||
pluginRef: 'BioCatch',
|
||||
repo: 'https://bitbucket.org/carlos_orellana/ionic-plugin',
|
||||
platforms: ['iOS', 'Android'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BioCatch extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Start a session
|
||||
*
|
||||
* @param customerSessionID {String} Customer session id
|
||||
* @param wupUrl {String} WUP server URL
|
||||
* @param publicKey {String} Public Key
|
||||
* @returns {Promise<void>} Returns a promise
|
||||
*/
|
||||
@Cordova()
|
||||
start(customerSessionID: string | null, wupUrl: string, publicKey: string | null): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause the session
|
||||
*
|
||||
* @returns {Promise<void>} Returns a promise
|
||||
*/
|
||||
@Cordova()
|
||||
pause(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume the session
|
||||
*
|
||||
* @returns {Promise<void>} Returns a promise
|
||||
*/
|
||||
@Cordova()
|
||||
resume(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the session
|
||||
*
|
||||
* @returns {Promise<void>} Returns a promise
|
||||
*/
|
||||
@Cordova()
|
||||
stop(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the session
|
||||
*
|
||||
* @returns {Promise<void>} Returns a promise
|
||||
*/
|
||||
@Cordova()
|
||||
resetSession(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the session context
|
||||
*
|
||||
* @param contextName {String} Context name
|
||||
* @returns {Promise<void>} Returns a promise
|
||||
*/
|
||||
@Cordova()
|
||||
changeContext(contextName: string): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the customer session ID
|
||||
*
|
||||
* @param customerSessionID {String}
|
||||
* @returns {Promise<void>} Returns a promise
|
||||
*/
|
||||
@Cordova()
|
||||
updateCustomerSessionID(customerSessionID: string | null): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name BiometricWrapper
|
||||
* @description
|
||||
* This plugin capture biometric(Iris and Fingerprint) and validate the user.
|
||||
* May be used in Banking domain
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { BiometricWrapper } from '@awesome-cordova-plugins/biometric-wrapper/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private biometricWrapper: BiometricWrapper) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.biometricWrapper.activateIris({'PID_XML': '<pid-xml/>'})
|
||||
* .then((res: any) => )
|
||||
* .catch((error: any) => );
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
|
||||
@Plugin({
|
||||
pluginName: 'BiometricWrapper',
|
||||
plugin: 'cordova-plugin-biometric',
|
||||
pluginRef: 'cordova.plugins.BiometricWrapper',
|
||||
repo: '',
|
||||
install: '',
|
||||
installVariables: [],
|
||||
platforms: ['Android'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BiometricWrapper extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* This function activate iris activity
|
||||
*
|
||||
* @param args
|
||||
* @returns {Promise<any>} Returns a promise that resolves when iris data captured
|
||||
*/
|
||||
@Cordova()
|
||||
activateIris(args: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function activate fingerprint activity
|
||||
*
|
||||
* @param args
|
||||
* @returns {Promise<any>} Returns a promise that resolves when FP data captured
|
||||
*/
|
||||
@Cordova()
|
||||
activateFingerprint(args: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
675
src/@awesome-cordova-plugins/plugins/ble/index.ts
Normal file
675
src/@awesome-cordova-plugins/plugins/ble/index.ts
Normal file
@ -0,0 +1,675 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface BLEScanOptions {
|
||||
/** true if duplicate devices should be reported, false (default) if devices should only be reported once. */
|
||||
reportDuplicates?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name BLE
|
||||
* @description
|
||||
* This plugin enables communication between a phone and Bluetooth Low Energy (BLE) peripherals.
|
||||
*
|
||||
* The plugin provides a simple JavaScript API for iOS and Android.
|
||||
*
|
||||
* - Scan for peripherals
|
||||
* - Connect to a peripheral
|
||||
* - Read the value of a characteristic
|
||||
* - Write new value to a characteristic
|
||||
* - Get notified when characteristic's value changes
|
||||
*
|
||||
* Advertising information is returned when scanning for peripherals. Service, characteristic, and property info is returned when connecting to a peripheral. All access is via service and characteristic UUIDs. The plugin manages handles internally.
|
||||
*
|
||||
* Simultaneous connections to multiple peripherals are supported.
|
||||
* @usage
|
||||
*
|
||||
* ```typescript
|
||||
*
|
||||
* import { BLE } from '@awesome-cordova-plugins/ble/ngx';
|
||||
*
|
||||
* constructor(private ble: BLE) { }
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* ## Peripheral Data
|
||||
*
|
||||
* Peripheral Data is passed to the success callback when scanning and connecting. Limited data is passed when scanning.
|
||||
*
|
||||
* ```typescript
|
||||
* {
|
||||
* 'name': 'Battery Demo',
|
||||
* 'id': '20:FF:D0:FF:D1:C0',
|
||||
* 'advertising': [2,1,6,3,3,15,24,8,9,66,97,116,116,101,114,121],
|
||||
* 'rssi': -55
|
||||
* }
|
||||
* ```
|
||||
* After connecting, the peripheral object also includes service, characteristic and descriptor information.
|
||||
*
|
||||
* ```typescript
|
||||
* {
|
||||
* 'name': 'Battery Demo',
|
||||
* 'id': '20:FF:D0:FF:D1:C0',
|
||||
* 'advertising': [2,1,6,3,3,15,24,8,9,66,97,116,116,101,114,121],
|
||||
* 'rssi': -55,
|
||||
* 'services': [
|
||||
* '1800',
|
||||
* '1801',
|
||||
* '180f'
|
||||
* ],
|
||||
* 'characteristics': [
|
||||
* {
|
||||
* 'service': '1800',
|
||||
* 'characteristic': '2a00',
|
||||
* 'properties': [
|
||||
* 'Read'
|
||||
* ]
|
||||
* },
|
||||
* {
|
||||
* 'service': '1800',
|
||||
* 'characteristic': '2a01',
|
||||
* 'properties': [
|
||||
* 'Read'
|
||||
* ]
|
||||
* },
|
||||
* {
|
||||
* 'service': '1801',
|
||||
* 'characteristic': '2a05',
|
||||
* 'properties': [
|
||||
* 'Read'
|
||||
* ]
|
||||
* },
|
||||
* {
|
||||
* 'service': '180f',
|
||||
* 'characteristic': '2a19',
|
||||
* 'properties': [
|
||||
* 'Read'
|
||||
* ],
|
||||
* 'descriptors': [
|
||||
* {
|
||||
* 'uuid': '2901'
|
||||
* },
|
||||
* {
|
||||
* 'uuid': '2904'
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* ## Advertising Data
|
||||
* Bluetooth advertising data is returned in when scanning for devices. The format varies depending on your platform. On Android advertising data will be the raw advertising bytes. iOS does not allow access to raw advertising data, so a dictionary of data is returned.
|
||||
*
|
||||
* The advertising information for both Android and iOS appears to be a combination of advertising data and scan response data.
|
||||
*
|
||||
* ### Android
|
||||
*
|
||||
* ```typescript
|
||||
* {
|
||||
* 'name': 'demo',
|
||||
* 'id': '00:1A:7D:DA:71:13',
|
||||
* 'advertising': ArrayBuffer,
|
||||
* 'rssi': -37
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Convert the advertising info to a Uint8Array for processing. `var adData = new Uint8Array(peripheral.advertising)`
|
||||
*
|
||||
* ### iOS
|
||||
*
|
||||
* Note that iOS uses the string value of the constants for the [Advertisement Data Retrieval Keys](https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CBCentralManagerDelegate_Protocol/index.html#//apple_ref/doc/constant_group/Advertisement_Data_Retrieval_Keys). This will likely change in the future.
|
||||
*
|
||||
* ```typescript
|
||||
* {
|
||||
* 'name': 'demo',
|
||||
* 'id': 'D8479A4F-7517-BCD3-91B5-3302B2F81802',
|
||||
* 'advertising': {
|
||||
* 'kCBAdvDataChannel': 37,
|
||||
* 'kCBAdvDataServiceData': {
|
||||
* 'FED8': {
|
||||
* 'byteLength': 7 // data not shown
|
||||
* }
|
||||
* },
|
||||
* 'kCBAdvDataLocalName': 'demo',
|
||||
* 'kCBAdvDataServiceUUIDs': ['FED8'],
|
||||
* 'kCBAdvDataManufacturerData': {
|
||||
* 'byteLength': 7 // data not shown
|
||||
* },
|
||||
* 'kCBAdvDataTxPowerLevel': 32,
|
||||
* 'kCBAdvDataIsConnectable': true
|
||||
* },
|
||||
* 'rssi': -53
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* ## Typed Arrays
|
||||
*
|
||||
* This plugin uses typed Arrays or ArrayBuffers for sending and receiving data.
|
||||
*
|
||||
* This means that you need convert your data to ArrayBuffers before sending and from ArrayBuffers when receiving.
|
||||
*
|
||||
* ```typescript
|
||||
* // ASCII only
|
||||
* function stringToBytes(string) {
|
||||
* var array = new Uint8Array(string.length);
|
||||
* for (var i = 0, l = string.length; i < l; i++) {
|
||||
* array[i] = string.charCodeAt(i);
|
||||
* }
|
||||
* return array.buffer;
|
||||
* }
|
||||
*
|
||||
* // ASCII only
|
||||
* function bytesToString(buffer) {
|
||||
* return String.fromCharCode.apply(null, new Uint8Array(buffer));
|
||||
* }
|
||||
* ```
|
||||
* You can read more about typed arrays in these articles on [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays) and [HTML5 Rocks](http://www.html5rocks.com/en/tutorials/webgl/typed_arrays/).
|
||||
*
|
||||
* ## UUIDs
|
||||
*
|
||||
* UUIDs are always strings and not numbers. Some 16-bit UUIDs, such as '2220' look like integers, but they're not. (The integer 2220 is 0x8AC in hex.) This isn't a problem with 128 bit UUIDs since they look like strings 82b9e6e1-593a-456f-be9b-9215160ebcac. All 16-bit UUIDs should also be passed to methods as strings.
|
||||
* @interfaces
|
||||
* BLEScanOptions
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BLE',
|
||||
plugin: 'cordova-plugin-ble-central',
|
||||
pluginRef: 'ble',
|
||||
repo: 'https://github.com/don/cordova-plugin-ble-central',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BLE extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Scan and discover BLE peripherals for the specified amount of time.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* BLE.scan([], 5).subscribe(device => {
|
||||
* console.log(JSON.stringify(device));
|
||||
* });
|
||||
* ```
|
||||
* @param {string[]} services List of service UUIDs to discover, or `[]` to find all devices
|
||||
* @param {number} seconds Number of seconds to run discovery
|
||||
* @returns {Observable<any>} Returns an Observable that notifies of each peripheral that is discovered during the specified time.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
})
|
||||
scan(services: string[], seconds: number): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan and discover BLE peripherals until `stopScan` is called.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* BLE.startScan([]).subscribe(device => {
|
||||
* console.log(JSON.stringify(device));
|
||||
* });
|
||||
*
|
||||
* setTimeout(() => {
|
||||
* BLE.stopScan();
|
||||
* }, 5000);
|
||||
* ```
|
||||
* @param {string[]} services List of service UUIDs to discover, or `[]` to find all devices
|
||||
* @returns {Observable<any>} Returns an Observable that notifies of each peripheral discovered.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
clearFunction: 'stopScan',
|
||||
clearWithArgs: false,
|
||||
})
|
||||
startScan(services: string[]): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans for BLE devices. This function operates similarly to the `startScan` function, but allows you to specify extra options (like allowing duplicate device reports).
|
||||
*
|
||||
* @param {string[]} services List of service UUIDs to discover, or `[]` to find all devices
|
||||
* @param {BLEScanOptions} options Options
|
||||
* @returns {Observable<any>} Returns an Observable that notifies of each peripheral discovered.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
clearFunction: 'stopScan',
|
||||
clearWithArgs: false,
|
||||
})
|
||||
startScanWithOptions(services: string[], options: BLEScanOptions): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop a scan started by `startScan`.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* BLE.startScan([]).subscribe(device => {
|
||||
* console.log(JSON.stringify(device));
|
||||
* });
|
||||
* setTimeout(() => {
|
||||
* BLE.stopScan().then(() => { console.log('scan stopped'); });
|
||||
* }, 5000);
|
||||
* ```
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
stopScan(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set device pin.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* BLE.setPin(pin).subscribe(success => {
|
||||
* console.log(success);
|
||||
* },
|
||||
* failure => {
|
||||
* console.log('failure');
|
||||
* });
|
||||
* ```
|
||||
* @param {string} pin Pin of the device as a string
|
||||
* @returns {Observable<any>} Returns an Observable that notifies of success/failure.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
})
|
||||
setPin(pin: string): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to a peripheral.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* BLE.connect('12:34:56:78:9A:BC').subscribe(peripheralData => {
|
||||
* console.log(peripheralData);
|
||||
* },
|
||||
* peripheralData => {
|
||||
* console.log('disconnected');
|
||||
* });
|
||||
* ```
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @returns {Observable<any>} Returns an Observable that notifies of connect/disconnect.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
clearFunction: 'disconnect',
|
||||
clearWithArgs: true,
|
||||
})
|
||||
connect(deviceId: string): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Establish an automatic connection to a peripheral. The phone will automatically connect to the Bluetooth peripheral
|
||||
* whenever it is in range. The autoConnect function uses callbacks instead of observables because connect and
|
||||
* disconnect can each be called many times as a devices connects and disconnects.
|
||||
*
|
||||
* On Android you can pass a MAC address directly to autoConnect. With iOS, you need to get a device id by scanning,
|
||||
* calling ble.peripheralsWithIdentifiers, or calling ble.connectedPeripheralsWithServices.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* someFunction() {
|
||||
* this.ble.autoConnect(deviceId, onConnected.bind(this), onDisconnected.bind(this));
|
||||
* }
|
||||
*
|
||||
* onConnected(peripheral) {
|
||||
* console.log(`Connected to ${peripheral.id}`)l
|
||||
* }
|
||||
*
|
||||
* onDisconnected(peripheral) {
|
||||
* console.log(`Disconnected from ${peripheral.id}`)l
|
||||
* }
|
||||
*
|
||||
* ```
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @param {Function} connectCallback function that is called with peripheral data when the devices connects
|
||||
* @param {Function} disconnectCallback function that is called with peripheral data when the devices disconnects
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
autoConnect(deviceId: string, connectCallback: any, disconnectCallback: any) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request MTU size.
|
||||
* May be used to fix the Error 14 "Unlikely" on write requests with more than 20 bytes.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* BLE.requestMtu('12:34:56:78:9A:BC', 512).then(() => {
|
||||
* console.log('MTU Size Accepted');
|
||||
* }, error => {
|
||||
* console.log('MTU Size Failed');
|
||||
* });
|
||||
* ```
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @param {number} mtuSize The new MTU size. (23 - 517, default is usually 23. Max recommended: 512)
|
||||
* @returns {Promise<any>} Returns a Promise.
|
||||
*/
|
||||
@Cordova()
|
||||
requestMtu(deviceId: string, mtuSize: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh Device Cache
|
||||
* This method may fix a issue of old cached services and characteristics.
|
||||
* NOTE Since this uses an undocumented API it's not guaranteed to work.
|
||||
* If you choose a too low delay time (timeoutMillis) the method could fail.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* BLE.refreshDeviceCache('12:34:56:78:9A:BC', 10000).then(discoveredServices => {
|
||||
* console.log('The new discovered services after the clean: ', discoveredServices);
|
||||
* }, error => {
|
||||
* console.log('Refresh device cache failed.');
|
||||
* });
|
||||
* ```
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @param {number} timeoutMillis Delay in milliseconds after refresh before discovering services.
|
||||
* @returns {Promise<any>} Returns a Promise.
|
||||
*/
|
||||
@Cordova()
|
||||
refreshDeviceCache(deviceId: string, timeoutMillis: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect from a peripheral.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* BLE.disconnect('12:34:56:78:9A:BC').then(() => {
|
||||
* console.log('Disconnected');
|
||||
* });
|
||||
* ```
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @returns {Promise<any>} Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
disconnect(deviceId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the value of a characteristic.
|
||||
*
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @param {string} serviceUUID UUID of the BLE service
|
||||
* @param {string} characteristicUUID UUID of the BLE characteristic
|
||||
* @returns {Promise<any>} Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
read(deviceId: string, serviceUUID: string, characteristicUUID: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the value of a characteristic.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* // send 1 byte to switch a light on
|
||||
* var data = new Uint8Array(1);
|
||||
* data[0] = 1;
|
||||
* BLE.write(device_id, 'FF10', 'FF11', data.buffer);
|
||||
*
|
||||
* // send a 3 byte value with RGB color
|
||||
* var data = new Uint8Array(3);
|
||||
* data[0] = 0xFF; // red
|
||||
* data[0] = 0x00; // green
|
||||
* data[0] = 0xFF; // blue
|
||||
* BLE.write(device_id, 'ccc0', 'ccc1', data.buffer);
|
||||
*
|
||||
* // send a 32 bit integer
|
||||
* var data = new Uint32Array(1);
|
||||
* data[0] = counterInput.value;
|
||||
* BLE.write(device_id, SERVICE, CHARACTERISTIC, data.buffer);
|
||||
*
|
||||
* ```
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @param {string} serviceUUID UUID of the BLE service
|
||||
* @param {string} characteristicUUID UUID of the BLE characteristic
|
||||
* @param {ArrayBuffer} value Data to write to the characteristic, as an ArrayBuffer.
|
||||
* @returns {Promise<any>} Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
write(deviceId: string, serviceUUID: string, characteristicUUID: string, value: ArrayBuffer): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the value of a characteristic without waiting for confirmation from the peripheral.
|
||||
*
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @param {string} serviceUUID UUID of the BLE service
|
||||
* @param {string} characteristicUUID UUID of the BLE characteristic
|
||||
* @param {ArrayBuffer} value Data to write to the characteristic, as an ArrayBuffer.
|
||||
* @returns {Promise<any>} Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
writeWithoutResponse(
|
||||
deviceId: string,
|
||||
serviceUUID: string,
|
||||
characteristicUUID: string,
|
||||
value: ArrayBuffer
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register to be notified when the value of a characteristic changes.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* BLE.startNotification(device_id, 'FF10', 'FF11').subscribe(buffer => {
|
||||
* console.log(String.fromCharCode.apply(null, new Uint8Array(buffer));
|
||||
* });
|
||||
* ```
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @param {string} serviceUUID UUID of the BLE service
|
||||
* @param {string} characteristicUUID UUID of the BLE characteristic
|
||||
* @returns {Observable<any>} Returns an Observable that notifies of characteristic changes.
|
||||
* The observer emit an array with data at index 0 and sequence order at index 1.
|
||||
* The sequence order is always undefined on iOS. On android it leave the client to check the sequence order and reorder if needed
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
destruct: true,
|
||||
clearFunction: 'stopNotification',
|
||||
clearWithArgs: true,
|
||||
})
|
||||
startNotification(deviceId: string, serviceUUID: string, characteristicUUID: string): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop being notified when the value of a characteristic changes.
|
||||
*
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @param {string} serviceUUID UUID of the BLE service
|
||||
* @param {string} characteristicUUID UUID of the BLE characteristic
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
stopNotification(deviceId: string, serviceUUID: string, characteristicUUID: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report the connection status.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* BLE.isConnected('FFCA0B09-CB1D-4DC0-A1EF-31AFD3EDFB53').then(
|
||||
* () => { console.log('connected'); },
|
||||
* () => { console.log('not connected'); }
|
||||
* );
|
||||
* ```
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
isConnected(deviceId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report if bluetooth is enabled.
|
||||
*
|
||||
* @returns {Promise<void>} Returns a Promise that resolves if Bluetooth is enabled, and rejects if disabled.
|
||||
*/
|
||||
@Cordova()
|
||||
isEnabled(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register to be notified when Bluetooth state changes on the device.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* BLE.startStateNotifications().subscribe(state => {
|
||||
* console.log("Bluetooth is " + state);
|
||||
* });
|
||||
* ```
|
||||
* @returns {Observable<any>} Returns an Observable that notifies when the Bluetooth is enabled or disabled on the device.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
clearFunction: 'stopStateNotifications',
|
||||
clearWithArgs: false,
|
||||
})
|
||||
startStateNotifications(): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop state notifications.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
stopStateNotifications(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers to be notified when Location service state changes on the device.
|
||||
*
|
||||
* @usage
|
||||
* ```
|
||||
* ble.startLocationStateNotifications(success, failure);
|
||||
* // Or using await with promises
|
||||
* // Note, initial promise resolves or rejects depending on whether the subscribe was successful
|
||||
* await ble.withPromises.startLocationStateNotifications(success, failure)
|
||||
* ```
|
||||
* @returns {Observable<any>} Returns an Observable that notifies when Location is enabled or disabled on the device.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
clearFunction: 'stopLocationStateNotifications',
|
||||
clearWithArgs: false,
|
||||
})
|
||||
startLocationStateNotifications(): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop location state notifications.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
stopLocationStateNotifications(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open System Bluetooth settings (Android only).
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
showBluetoothSettings(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable Bluetooth on the device (Android only).
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
enable(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the RSSI value on the device connection.
|
||||
*
|
||||
* @param {string} deviceId UUID or MAC address of the peripheral
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
readRSSI(deviceId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of the peripherals (containing any of the specified services)
|
||||
* currently connected to the system. The peripheral list is sent to the success callback.
|
||||
* iOS only
|
||||
*
|
||||
* @param {string[]} services List of services to discover
|
||||
* @returns {Promise<any>} Returns a promise with a list of peripheral objects
|
||||
*/
|
||||
@Cordova()
|
||||
connectedPeripheralsWithServices(services: string[]): Promise<any[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the connected peripherals offering the listed service UUIDs.
|
||||
* iOS only
|
||||
*
|
||||
* @param {string[]} uuids List of peripheral UUIDs
|
||||
* @returns {Promise<any>} Returns a promise with a list of peripheral objects
|
||||
*/
|
||||
@Cordova()
|
||||
peripheralsWithIdentifiers(uuids: string[]): Promise<any[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the bonded devices
|
||||
* Android only
|
||||
*
|
||||
* @returns {Promise<any>} Returns a promise with a list of peripheral objects
|
||||
*/
|
||||
@Cordova()
|
||||
bondedDevices(): Promise<any[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports if location services are enabled.
|
||||
* Android only
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
isLocationEnabled(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
2949
src/@awesome-cordova-plugins/plugins/blinkid/index.ts
Normal file
2949
src/@awesome-cordova-plugins/plugins/blinkid/index.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,358 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface BluetoothClassicSerialPortDevice {
|
||||
id: string;
|
||||
class?: string | number;
|
||||
address?: string;
|
||||
name?: string;
|
||||
protocols?: string[]; // ios only
|
||||
[p: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Bluetooth Classic Serial Port
|
||||
* @description This plugin is written using the iOS Accessory Framework (MFi) to support Classic Bluetooth on iOS.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { BluetoothClassicSerialPort } from '@awesome-cordova-plugins/bluetooth-classic-serial-port/ngx';
|
||||
*
|
||||
* constructor(private bluetoothClassicSerialPort: BluetoothClassicSerialPort) { }
|
||||
*
|
||||
*
|
||||
* // Write a string
|
||||
* this.bluetoothClassicSerialPort.write("00001101-0000-1000-8000-00805F9B34FB", "hello, world", success, failure);
|
||||
*
|
||||
* // Array of int or bytes
|
||||
* this.bluetoothClassicSerialPort.write("00001101-0000-1000-8000-00805F9B34FB", [186, 220, 222], success, failure);
|
||||
*
|
||||
* // Typed Array
|
||||
* var data = new Uint8Array(4);
|
||||
* data[0] = 0x41;
|
||||
* data[1] = 0x42;
|
||||
* data[2] = 0x43;
|
||||
* data[3] = 0x44;
|
||||
* this.bluetoothClassicSerialPort.write(interfaceId, data, success, failure);
|
||||
*
|
||||
* // Array Buffer
|
||||
* this.bluetoothClassicSerialPort.write(interfaceId, data.buffer, success, failure);
|
||||
* ```
|
||||
*
|
||||
* // iOS select accessory
|
||||
*
|
||||
* ```typescript
|
||||
* async selectAccessory() {
|
||||
* const deviceDiscovery = this.bluetoothClassicSerialPort.setDeviceDiscoveredListener().subscribe(async (connectionConfig) => {
|
||||
* deviceDiscovery.unsubscribe();
|
||||
* })
|
||||
*
|
||||
* await this.bluetoothClassicSerialPort.discoverUnpaired().catch(error => {
|
||||
* deviceDiscovery.unsubscribe();
|
||||
* })
|
||||
*
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BluetoothClassicSerialPort',
|
||||
repo: 'https://github.com/MaximBelov/cordova-plugin-bluetooth-classic-serial-port',
|
||||
plugin: 'cordova-plugin-bluetooth-classic-serial-port',
|
||||
pluginRef: 'bluetoothClassicSerial',
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BluetoothClassicSerialPort extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Connect to a Bluetooth device
|
||||
*
|
||||
* @param {string} deviceId Identifier of the remote device.
|
||||
* @param {string} deviceId this is the MAC address.
|
||||
* @param {string|string[]} interfaceId Identifier of the remote device
|
||||
* @param {string|string[]} interfaceId This identifies the serial port to connect to.
|
||||
* @returns {Observable<any>} Subscribe to connect.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS'],
|
||||
observable: true,
|
||||
})
|
||||
connect(deviceId: string | number, interfaceId: string | string[]): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to a Bluetooth device
|
||||
*
|
||||
* @deprecated
|
||||
* @param {string} deviceId Identifier of the remote device.
|
||||
* @param {number} deviceId this is the connection ID
|
||||
* @param {string|string[]} interfaceArray Identifier of the remote device
|
||||
* @param {string|string[]} interfaceArray this is the Protocol String
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
methodName: 'connect',
|
||||
})
|
||||
connectIos(deviceId: string | number, interfaceArray: string | string[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect insecurely to a Bluetooth device
|
||||
*
|
||||
* @param {string} deviceId Identifier of the remote device. For Android this is the MAC address
|
||||
* @param {string | string[]} interfaceArray This identifies the serial port to connect to. For Android this is the SPP_UUID.
|
||||
* @returns {Promise<any>} Subscribe to connect.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
observable: true,
|
||||
})
|
||||
connectInsecure(deviceId: string, interfaceArray: string | string[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect from the connected device
|
||||
*
|
||||
* @param {string} interfaceId The interface to Disconnect
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
disconnect(interfaceId: string | string[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect from all the connected device
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
methodName: 'connect',
|
||||
})
|
||||
disconnectAll(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes data to the serial port
|
||||
*
|
||||
* @param {string} interfaceId The interface to send the data to
|
||||
* @param {ArrayBuffer | string | number[] | Uint8Array} data ArrayBuffer of data
|
||||
* @returns {Promise<any>} returns a promise when data has been written
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
write(interfaceId: string, data: ArrayBuffer | string | number[] | Uint8Array): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of bytes of data available
|
||||
*
|
||||
* @param {string} interfaceId The interface to check
|
||||
* @returns {Promise<any>} returns a promise that contains the available bytes
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'Browser'],
|
||||
})
|
||||
available(interfaceId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function read reads the data from the buffer. The data is passed to the success callback as a String. Calling read when no data is available will pass an empty String to the callback.
|
||||
*
|
||||
* @param {string} interfaceId The interface to read
|
||||
* @returns {Promise<any>} returns a promise with data from the buffer
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
read(interfaceId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads data from the buffer until it reaches a delimiter
|
||||
*
|
||||
* @param {string} interfaceId The interface to read
|
||||
* @param {string} delimiter string that you want to search until
|
||||
* @returns {Observable<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
readUntil(interfaceId: string, delimiter: string): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to be notified when data is received
|
||||
*
|
||||
* @param {string | string[]} interfaceId The interface to subscribe to
|
||||
* @param {string} delimiter the string you want to watch for
|
||||
* @returns {Observable<any>} returns an observable.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
observable: true,
|
||||
})
|
||||
subscribe(interfaceId: string | string[], delimiter: string): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe from a subscription
|
||||
*
|
||||
* @param {string | string[]} interfaceId The interface to unsubscribe from
|
||||
* @returns {Promise<any>} returns an promise.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
unsubscribe(interfaceId: string | string[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to be notified when data is received
|
||||
*
|
||||
* @param {string | string[]} interfaceId The interface to subscribe to
|
||||
* @returns {Observable<any>} returns an observable
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
observable: true,
|
||||
})
|
||||
subscribeRawData(interfaceId: string | string[]): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe from a subscription
|
||||
*
|
||||
* @param {string | string[]} interfaceId The interface to unsubscribe from
|
||||
* @returns {Promise<any>} returns an promise.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
unsubscribeRawData(interfaceId: string | string[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears data in buffer
|
||||
*
|
||||
* @param {string} interfaceId The interface to clear data
|
||||
* @returns {Promise<any>} returns a promise when completed
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
clear(interfaceId: string): Promise<[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists bonded devices
|
||||
*
|
||||
* @returns {Promise<BluetoothClassicSerialPortDevice>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
list(): Promise<BluetoothClassicSerialPortDevice[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports the connection status
|
||||
*
|
||||
* @param {string} interfaceId The interface to check
|
||||
* @returns {Promise<boolean>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
isConnected(interfaceId: string): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports if bluetooth is enabled
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
isEnabled(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Bluetooth settings on the device
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
})
|
||||
showBluetoothSettings(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable Bluetooth on the device
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'Browser'],
|
||||
})
|
||||
enable(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover unpaired devices
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
discoverUnpaired(): Promise<BluetoothClassicSerialPortDevice[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to be notified on Bluetooth device discovery. Discovery process must be initiated with the `discoverUnpaired` function.
|
||||
*
|
||||
* @returns {Observable<any>} Returns an observable
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
observable: true,
|
||||
clearFunction: 'clearDeviceDiscoveredListener',
|
||||
})
|
||||
setDeviceDiscoveredListener(): Observable<BluetoothClassicSerialPortDevice> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears notify callback function registered with setDeviceDiscoveredListener.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
sync: true,
|
||||
})
|
||||
clearDeviceDiscoveredListener() {
|
||||
return;
|
||||
}
|
||||
}
|
1175
src/@awesome-cordova-plugins/plugins/bluetooth-le/index.ts
Normal file
1175
src/@awesome-cordova-plugins/plugins/bluetooth-le/index.ts
Normal file
File diff suppressed because it is too large
Load Diff
292
src/@awesome-cordova-plugins/plugins/bluetooth-serial/index.ts
Normal file
292
src/@awesome-cordova-plugins/plugins/bluetooth-serial/index.ts
Normal file
@ -0,0 +1,292 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/**
|
||||
* @name Bluetooth Serial
|
||||
* @description This plugin enables serial communication over Bluetooth. It was written for communicating between Android or iOS and an Arduino (not Android to Android or iOS to iOS).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { BluetoothSerial } from '@awesome-cordova-plugins/bluetooth-serial/ngx';
|
||||
*
|
||||
* constructor(private bluetoothSerial: BluetoothSerial) { }
|
||||
*
|
||||
*
|
||||
* // Write a string
|
||||
* this.bluetoothSerial.write('hello world').then(success, failure);
|
||||
*
|
||||
* // Array of int or bytes
|
||||
* this.bluetoothSerial.write([186, 220, 222]).then(success, failure);
|
||||
*
|
||||
* // Typed Array
|
||||
* var data = new Uint8Array(4);
|
||||
* data[0] = 0x41;
|
||||
* data[1] = 0x42;
|
||||
* data[2] = 0x43;
|
||||
* data[3] = 0x44;
|
||||
* this.bluetoothSerial.write(data).then(success, failure);
|
||||
*
|
||||
* // Array Buffer
|
||||
* this.bluetoothSerial.write(data.buffer).then(success, failure);
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BluetoothSerial',
|
||||
repo: 'https://github.com/don/BluetoothSerial',
|
||||
plugin: 'cordova-plugin-bluetooth-serial',
|
||||
pluginRef: 'bluetoothSerial',
|
||||
platforms: ['Android', 'iOS', 'Windows Phone 8'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BluetoothSerial extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Connect to a Bluetooth device
|
||||
*
|
||||
* @param {string} macAddress_or_uuid Identifier of the remote device
|
||||
* @returns {Observable<any>} Subscribe to connect, unsubscribe to disconnect.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
observable: true,
|
||||
clearFunction: 'disconnect',
|
||||
})
|
||||
connect(macAddress_or_uuid: string): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect insecurely to a Bluetooth device
|
||||
*
|
||||
* @param {string} macAddress Identifier of the remote device
|
||||
* @returns {Observable<any>} Subscribe to connect, unsubscribe to disconnect.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
observable: true,
|
||||
clearFunction: 'disconnect',
|
||||
})
|
||||
connectInsecure(macAddress: string): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect from the connected device
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
disconnect(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes data to the serial port
|
||||
*
|
||||
* @param {any} data ArrayBuffer of data
|
||||
* @returns {Promise<any>} returns a promise when data has been written
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
write(data: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of bytes of data available
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise that contains the available bytes
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
available(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads data from the buffer
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise with data from the buffer
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
read(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads data from the buffer until it reaches a delimiter
|
||||
*
|
||||
* @param {string} delimiter string that you want to search until
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
readUntil(delimiter: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to be notified when data is received
|
||||
*
|
||||
* @param {string} delimiter the string you want to watch for
|
||||
* @returns {Observable<any>} returns an observable.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
observable: true,
|
||||
clearFunction: 'unsubscribe',
|
||||
})
|
||||
subscribe(delimiter: string): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to be notified when data is received
|
||||
*
|
||||
* @returns {Observable<any>} returns an observable
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
observable: true,
|
||||
clearFunction: 'unsubscribeRawData',
|
||||
})
|
||||
subscribeRawData(): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears data in buffer
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise when completed
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
clear(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists bonded devices
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
list(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports if bluetooth is enabled
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
isEnabled(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports the connection status
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
isConnected(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the RSSI from the connected peripheral
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
readRSSI(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Bluetooth settings on the device
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
showBluetoothSettings(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable Bluetooth on the device
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
enable(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Discover unpaired devices
|
||||
*
|
||||
* @returns {Promise<any>} returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
})
|
||||
discoverUnpaired(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to be notified on Bluetooth device discovery. Discovery process must be initiated with the `discoverUnpaired` function.
|
||||
*
|
||||
* @returns {Observable<any>} Returns an observable
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android', 'iOS', 'Windows Phone'],
|
||||
observable: true,
|
||||
clearFunction: 'clearDeviceDiscoveredListener',
|
||||
})
|
||||
setDeviceDiscoveredListener(): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the human readable device name that is broadcasted to other devices
|
||||
*
|
||||
* @param {string} newName Desired name of device
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
setName(newName: string): void {}
|
||||
|
||||
/**
|
||||
* Makes the device discoverable by other devices
|
||||
*
|
||||
* @param {number} discoverableDuration Desired number of seconds device should be discoverable for
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
sync: true,
|
||||
})
|
||||
setDiscoverable(discoverableDuration: number): void {}
|
||||
}
|
261
src/@awesome-cordova-plugins/plugins/branch-io/index.ts
Normal file
261
src/@awesome-cordova-plugins/plugins/branch-io/index.ts
Normal file
@ -0,0 +1,261 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface BranchIoPromise {
|
||||
$identity_id?: number;
|
||||
$one_time_use?: boolean;
|
||||
'+click_timestamp'?: number;
|
||||
'+clicked_branch_link'?: boolean;
|
||||
'+is_first_session'?: boolean;
|
||||
'+match_guaranteed'?: boolean;
|
||||
contentMetadata?: string;
|
||||
source?: string;
|
||||
'~campaign'?: string;
|
||||
'~channel'?: string;
|
||||
'~creation_source'?: string;
|
||||
'~feature'?: string;
|
||||
'~id'?: number;
|
||||
'~referring_link:'?: string;
|
||||
[x: string]: any;
|
||||
}
|
||||
|
||||
export interface BranchIoAnalytics {
|
||||
channel?: string;
|
||||
feature?: string;
|
||||
campaign?: string;
|
||||
stage?: string;
|
||||
tags?: string[];
|
||||
[x: string]: any;
|
||||
}
|
||||
|
||||
export interface BranchIoProperties {
|
||||
contentMetadata?: {
|
||||
[x: string]: any;
|
||||
};
|
||||
[x: string]: any;
|
||||
}
|
||||
|
||||
export interface BranchUniversalObject {
|
||||
generateShortUrl(analytics: BranchIoAnalytics, properties: BranchIoProperties): Promise<any>;
|
||||
registerView(): Promise<any>;
|
||||
showShareSheet(analytics: BranchIoAnalytics, properties: BranchIoProperties, shareText: string): Promise<any>;
|
||||
onShareSheetLaunched(callback: any): void;
|
||||
onShareSheetDismissed(callback: any): void;
|
||||
onLinkShareResponse(callback: any): void;
|
||||
onChannelSelected(callback: any): void;
|
||||
listOnSpotlight(): Promise<any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name BranchIo
|
||||
* @description
|
||||
* Branch.io is an attribution service for deeplinking and invitation links
|
||||
* @usage
|
||||
* ```
|
||||
* import { BranchIo } from '@awesome-cordova-plugins/branch-io/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private branch: BranchIo) { }
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* BranchIoPromise
|
||||
* BranchIoAnalytics
|
||||
* BranchIoProperties
|
||||
* BranchUniversalObject
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BranchIo',
|
||||
plugin: 'branch-cordova-sdk',
|
||||
pluginRef: 'Branch',
|
||||
repo: 'https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking',
|
||||
platforms: ['iOS', 'Android'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BranchIo extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* for development and debugging only
|
||||
*
|
||||
* @param {boolean} enable Enable debug
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
setDebug(enable: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable tracking
|
||||
*
|
||||
* @param {boolean} disable disable tracking
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
disableTracking(disable: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes Branch
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
initSession(): Promise<BranchIoPromise> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes Branch with callback
|
||||
*
|
||||
* @returns {Observable<any>}
|
||||
*/
|
||||
@Cordova({ observable: true })
|
||||
initSessionWithCallback(): Observable<BranchIoPromise> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Request Metadata
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
setRequestMetadata(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* for better Android matching
|
||||
*
|
||||
* @param {string} linkDomain LinkDomain at branch
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
setCookieBasedMatching(linkDomain: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* First data
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
getFirstReferringParams(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Latest data
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
getLatestReferringParams(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set identy of user
|
||||
*
|
||||
* @param {string} userId
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
setIdentity(userId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout user
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
logout(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a custom event
|
||||
*
|
||||
* @param {string} eventName
|
||||
* @param {any} metaData
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
userCompletedAction(eventName: string, metaData: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Commerce Event
|
||||
*
|
||||
* @deprecated since v.3.1.0. As of https://help.branch.io/developers-hub/docs/cordova-phonegap-ionic#track-commerce
|
||||
* @param {string} event
|
||||
* @param {any} metaData
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
sendCommerceEvent(event: string, metaData: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Branch Event
|
||||
*
|
||||
* @param {string} event
|
||||
* @param {any} metaData
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
sendBranchEvent(event: string, metaData: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* create a branchUniversalObj variable to reference with other Branch methods
|
||||
*
|
||||
* @param {BranchIoProperties} properties
|
||||
* @returns {Promise<BranchUniversalObject>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
createBranchUniversalObject(properties: BranchIoProperties): Promise<BranchUniversalObject> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load credits
|
||||
*
|
||||
* @param {any} bucket
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
loadRewards(bucket: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Redeem Rewards
|
||||
*
|
||||
* @param {string} value
|
||||
* @param {any} bucket
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
redeemRewards(value: string, bucket: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show credit history
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({ otherPromise: true })
|
||||
creditHistory(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
62
src/@awesome-cordova-plugins/plugins/brightness/index.ts
Normal file
62
src/@awesome-cordova-plugins/plugins/brightness/index.ts
Normal file
@ -0,0 +1,62 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name Brightness
|
||||
* @description
|
||||
* The Brightness plugin let you control the display brightness of your device.
|
||||
*
|
||||
* Requires Cordova plugin: `cordova-plugin-brightness`. For more info, please see the [Brightness plugin docs](https://github.com/mgcrea/cordova-plugin-brightness).
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Brightness } from '@awesome-cordova-plugins/brightness/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private brightness: Brightness) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* let brightnessValue = 0.8;
|
||||
* this.brightness.setBrightness(brightnessValue);
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Brightness',
|
||||
plugin: 'cordova-plugin-brightness',
|
||||
pluginRef: 'cordova.plugins.brightness',
|
||||
repo: 'https://github.com/mgcrea/cordova-plugin-brightness',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Brightness extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Sets the brightness of the display.
|
||||
* @param value {number} Floating number between 0 and 1 in which case 1 means 100% brightness and 0 means 0% brightness.
|
||||
* @returns {Promise<any>} Returns a Promise that resolves if setting brightness was successful.
|
||||
*/
|
||||
@Cordova()
|
||||
setBrightness(value: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the current brightness of the device display.
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with the
|
||||
* brightness value of the device display (floating number between 0 and 1).
|
||||
*/
|
||||
@Cordova()
|
||||
getBrightness(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps the screen on. Prevents the device from setting the screen to sleep.
|
||||
* @param {boolean} value
|
||||
*/
|
||||
@Cordova()
|
||||
setKeepScreenOn(value: boolean): void {
|
||||
return;
|
||||
}
|
||||
}
|
79
src/@awesome-cordova-plugins/plugins/broadcaster/index.ts
Normal file
79
src/@awesome-cordova-plugins/plugins/broadcaster/index.ts
Normal file
@ -0,0 +1,79 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Specific data for Android implementation
|
||||
*/
|
||||
export interface AndroidData {
|
||||
extras: object;
|
||||
flags: number;
|
||||
category: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possibly Event Data types
|
||||
*/
|
||||
export type EventData = object | AndroidData | null;
|
||||
|
||||
/**
|
||||
* @name Broadcaster
|
||||
* @description
|
||||
* This plugin adds exchanging events between native code and your app.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Broadcaster } from '@awesome-cordova-plugins/broadcaster/ngx';
|
||||
*
|
||||
* constructor(private broadcaster: Broadcaster) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Listen to events from Native
|
||||
* this.broadcaster.addEventListener('eventName').subscribe((event) => console.log(event));
|
||||
*
|
||||
* // Send event to Native
|
||||
* this.broadcaster.fireNativeEvent('eventName', {}).then(() => console.log('success'));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Broadcaster',
|
||||
plugin: 'cordova-plugin-broadcaster',
|
||||
pluginRef: 'broadcaster',
|
||||
repo: 'https://github.com/bsorrentino/cordova-broadcaster',
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Broadcaster extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* This function listen to an event sent from the native code
|
||||
*
|
||||
* @param {string} eventName
|
||||
* @param {boolean} isGlobal Valid only for Android. It allows to listen for global messages(i.e. intents)
|
||||
* @returns {Observable<any>} Returns an observable to watch when an event is received
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
clearFunction: 'removeEventListener',
|
||||
clearWithArgs: true,
|
||||
})
|
||||
addEventListener(eventName: string, isGlobal = false): Observable<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function sends data to the native code
|
||||
*
|
||||
* @param {string} eventName
|
||||
* @param {boolean} isGlobalOrEventData means that message is global (valid only on Android)
|
||||
* @param {AndroidData} isGlobalOrEventData allows to specify 'flags` and 'category' (valid only on Android)
|
||||
* @param {object} isGlobalOrEventData allows to specify a generic object containing custom event data (all platform)
|
||||
* @param {AndroidData} [data] if isGlobal is set, allows to specify 'flags` and 'category' if isGlobal is set (valid only on Android)
|
||||
* @param {object} [data] if isGlobal is set, allows to specify a generic object containing custom event data (all platform)
|
||||
* @returns {Promise<any>} Returns a promise that resolves when an event is successfully fired
|
||||
*/
|
||||
@Cordova()
|
||||
fireNativeEvent(eventName: string, isGlobalOrEventData: boolean | EventData, data?: EventData): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
63
src/@awesome-cordova-plugins/plugins/browser-tab/index.ts
Normal file
63
src/@awesome-cordova-plugins/plugins/browser-tab/index.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name Browser Tab
|
||||
* @description
|
||||
* This plugin provides an interface to in-app browser tabs that exist on some mobile platforms, specifically [Custom Tabs](http://developer.android.com/tools/support-library/features.html#custom-tabs) on Android (including the [Chrome Custom Tabs](https://developer.chrome.com/multidevice/android/customtabs) implementation), and [SFSafariViewController](https://developer.apple.com/library/ios/documentation/SafariServices/Reference/SFSafariViewController_Ref/) on iOS.
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { BrowserTab } from '@awesome-cordova-plugins/browser-tab/ngx';
|
||||
*
|
||||
* constructor(private browserTab: BrowserTab) {
|
||||
*
|
||||
* browserTab.isAvailable()
|
||||
* .then(isAvailable => {
|
||||
* if (isAvailable) {
|
||||
* browserTab.openUrl('https://ionic.io');
|
||||
* } else {
|
||||
* // open URL with InAppBrowser instead or SafariViewController
|
||||
* }
|
||||
* });
|
||||
* }
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BrowserTab',
|
||||
plugin: 'cordova-plugin-browsertab',
|
||||
pluginRef: 'cordova.plugins.browsertab',
|
||||
repo: 'https://github.com/google/cordova-plugin-browsertab',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BrowserTab extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Check if BrowserTab option is available
|
||||
* @return {Promise<any>} Returns a promise that resolves when check is successful and returns true or false
|
||||
*/
|
||||
@Cordova()
|
||||
isAvailable(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the provided URL using a browser tab
|
||||
* @param {string} url The URL you want to open
|
||||
* @return {Promise<any>} Returns a promise that resolves when check open was successful
|
||||
*/
|
||||
@Cordova()
|
||||
openUrl(url: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes browser tab
|
||||
* @return {Promise<any>} Returns a promise that resolves when close was finished
|
||||
*/
|
||||
@Cordova()
|
||||
close(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
329
src/@awesome-cordova-plugins/plugins/build-info/index.ts
Normal file
329
src/@awesome-cordova-plugins/plugins/build-info/index.ts
Normal file
@ -0,0 +1,329 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, CordovaProperty, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name Build Info
|
||||
* @description
|
||||
* This plugin provides build information.
|
||||
* @usage
|
||||
* ```
|
||||
* import { BuildInfo } from '@awesome-cordova-plugins/build-info/ngx';
|
||||
*
|
||||
* this.platform.ready().then(() => {
|
||||
* console.log('BuildInfo.baseUrl =' + BuildInfo.baseUrl)
|
||||
* console.log('BuildInfo.packageName =' + BuildInfo.packageName)
|
||||
* console.log('BuildInfo.basePackageName=' + BuildInfo.basePackageName)
|
||||
* console.log('BuildInfo.displayName =' + BuildInfo.displayName)
|
||||
* console.log('BuildInfo.name =' + BuildInfo.name)
|
||||
* console.log('BuildInfo.version =' + BuildInfo.version)
|
||||
* console.log('BuildInfo.versionCode =' + BuildInfo.versionCode)
|
||||
* console.log('BuildInfo.debug =' + BuildInfo.debug)
|
||||
* console.log('BuildInfo.buildType =' + BuildInfo.buildType)
|
||||
* console.log('BuildInfo.flavor =' + BuildInfo.flavor)
|
||||
* console.log('BuildInfo.buildDate =' + BuildInfo.buildDate)
|
||||
* console.log('BuildInfo.installDate =' + BuildInfo.installDate)
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'BuildInfo',
|
||||
plugin: 'cordova-plugin-buildinfo',
|
||||
pluginRef: 'BuildInfo',
|
||||
repo: 'https://github.com/lynrin/cordova-plugin-buildinfo',
|
||||
platforms: ['Android', 'iOS', 'Windows', 'macOS', 'browser', 'Electron'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BuildInfo extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* The baseUrl where cordova.js was loaded.
|
||||
*/
|
||||
@CordovaProperty()
|
||||
baseUrl: string;
|
||||
|
||||
/**
|
||||
* Get the packageName of Application ID.
|
||||
*
|
||||
* |Platform|Value|Type|
|
||||
* |--------|-----|----|
|
||||
* |Android|Package Name|String|
|
||||
* |iOS|Bundle Identifier|String|
|
||||
* |Windows|Identity name|String|
|
||||
* |macOS(OS X)|Bundle Identifier|String|
|
||||
* |Browser|Get the id attribute of the widget element in config.xml file.|String|
|
||||
* |Electron|Get the id attribute of the widget element in config.xml file.|String|
|
||||
*/
|
||||
@CordovaProperty()
|
||||
packageName: string;
|
||||
|
||||
/**
|
||||
* Android only.
|
||||
*
|
||||
* Get the packageName of BuildConfig class.
|
||||
*
|
||||
* If you use the configure of "build types" or "product flavors", because you can specify a different package name is the id attribute of the widget element of config.xml, is the property to get the package name that BuildConfig class belongs.
|
||||
* (ought be the same as the id attribute of the widget element of config.xml)
|
||||
*
|
||||
*
|
||||
* |Platform|Value|Type|
|
||||
* |--------|-----|----|
|
||||
* |Android|Package name of BuildConfig class|String|
|
||||
* |iOS|Bundle Identifier(equals BuildInfo.packageName)|String|
|
||||
* |Windows|Identity name(equals BuildInfo.packageName)|String|
|
||||
* |macOS(OS X)|Bundle Identifier(equals BuildInfo.packageName)|String|
|
||||
* |Browser|equals BuildInfo.packageName|String|
|
||||
* |Electron|equals BuildInfo.packageName|String|
|
||||
*/
|
||||
@CordovaProperty()
|
||||
basePackageName: string;
|
||||
|
||||
/**
|
||||
* Get the displayName.
|
||||
*
|
||||
* |Platform|Value|Type|
|
||||
* |--------|-----|----|
|
||||
* |Android|Application Label|String|
|
||||
* |iOS|CFBundleDisplayName (CFBundleName if not present)|String|
|
||||
* |Windows|Get the DisplayName attribute of the VisualElements element in AppxManifest.xml file.|String|
|
||||
* |macOS(OS X)|CFBundleDisplayName (CFBundleName if not present)|String|
|
||||
* |Browser|Get the short attribute of the name element in config.xml file.|String|
|
||||
* |Electron|Get the short attribute of the name element in config.xml file.|String|
|
||||
*/
|
||||
@CordovaProperty()
|
||||
displayName: string;
|
||||
|
||||
/**
|
||||
* Get the name.
|
||||
*
|
||||
* |Platform|Value|Type|
|
||||
* |--------|-----|----|
|
||||
* |Android|Application Label(equal BuildInfo.displayName)|String|
|
||||
* |iOS|CFBundleName|String|
|
||||
* |Windows|Windows Store display name|String|
|
||||
* |macOS(OS X)|CFBundleName|String|
|
||||
* |Browser|Get value of the name element in config.xml file.|String|
|
||||
* |Electron|Get value of the name element in config.xml file.|String|
|
||||
*/
|
||||
@CordovaProperty()
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Get the version.
|
||||
*
|
||||
* |Platform|Value|Type|
|
||||
* |--------|-----|----|
|
||||
* |Android|BuildConfig.VERSION_NAME|String|
|
||||
* |iOS|CFBundleShortVersionString|String|
|
||||
* |Windows|Major.Minor.Build ex) "1.2.3"|String|
|
||||
* |macOS(OS X)|CFBundleShortVersionString|String|
|
||||
* |Browser|Get the version attribute of the widget element in config.xml file.|String|
|
||||
* |Electron|Get the version attribute of the widget element in config.xml file.|String|
|
||||
*/
|
||||
@CordovaProperty()
|
||||
version: string;
|
||||
|
||||
/**
|
||||
* Get the version code.
|
||||
*
|
||||
* |Platform|Value|Type|
|
||||
* |--------|-----|----|
|
||||
* |Android|BuildConfig.VERSION_CODE|integer|
|
||||
* |iOS|CFBundleVersion|String|
|
||||
* |Windows|Major.Minor.Build.Revision ex) "1.2.3.4"|String|
|
||||
* |macOS(OS X)|CFBundleVersion|String|
|
||||
* |Browser|equals BuildInfo.version|String|
|
||||
* |Electron|equals BuildInfo.version|String|
|
||||
*/
|
||||
@CordovaProperty()
|
||||
versionCode: string | number;
|
||||
|
||||
/**
|
||||
* Get the debug flag.
|
||||
*
|
||||
* |Platform|Value|Type|
|
||||
* |--------|-----|----|
|
||||
* |Android|BuildConfig.DEBUG|Boolean|
|
||||
* |iOS|defined "DEBUG" is true|Boolean|
|
||||
* |Windows|isDevelopmentMode is true|Boolean|
|
||||
* |macOS(OS X)|defined "DEBUG" is true|Boolean|
|
||||
* |Browser|Always false|Boolean|
|
||||
* |Electron|True when ```cordova build electron --debug``` is executed with the "--debug" flag.|Boolean|
|
||||
*/
|
||||
@CordovaProperty()
|
||||
debug: boolean;
|
||||
|
||||
/**
|
||||
* Android , Windows Only.
|
||||
*
|
||||
* Get the build type.
|
||||
*
|
||||
* |Platform|Value|Type|
|
||||
* |--------|-----|----|
|
||||
* |Android|BuildConfig.BUILD_TYPE|String|
|
||||
* |iOS|empty string|String|
|
||||
* |Windows|"release" or "debug"|String|
|
||||
* |macOS(OS X)|empty string|String|
|
||||
* |Browser|empty string|String|
|
||||
* |Electron|empty string|String|
|
||||
*
|
||||
*/
|
||||
@CordovaProperty()
|
||||
buildType: string;
|
||||
/**
|
||||
* Android Only.
|
||||
*
|
||||
* Get the flavor.
|
||||
*
|
||||
* |Platform|Value|Type|
|
||||
* |--------|-----|----|
|
||||
* |Android|BuildConfig.FLAVOR|String|
|
||||
* |iOS|empty string|String|
|
||||
* |Windows|empty string|String|
|
||||
* |macOS(OS X)|empty string|String|
|
||||
* |Browser|empty string|String|
|
||||
* |Electron|empty string|String|
|
||||
*/
|
||||
@CordovaProperty()
|
||||
flavor: string;
|
||||
|
||||
/**
|
||||
* Get the build date and time in the Date object returns.
|
||||
*
|
||||
* Attention:
|
||||
* - Android: Add the BuildInfo.gradle file to your Android project.
|
||||
* The BuildInfo.gradle file contains the setting to add the _BUILDINFO_TIMESTAMP field to the BuildConfig class.
|
||||
* - Windows: Add the buildinfo.resjson file to your Windows project.
|
||||
* The buildinfo.resjson file into the "strings" folder.
|
||||
* And also add a task to rewrite buildinfo.resjson in the CordovaApp.projitems file.
|
||||
* - Browser and Electron: When ```cordova prepare``` is executed Build date and time is embedded in
|
||||
* platforms/**browser**\/www/plugins/cordova-plugin-buildinfo/src/browser/BuildInfoProxy.js file.
|
||||
* (Or platforms/**electron**\/www/plugins/cordova-plugin-buildinfo/src/browser/BuildInfoProxy.js file.)
|
||||
* ```cordova prepare``` is also executed for ```cordova build```, ```cordova run``` and ```cordova platform add```.
|
||||
* (Reference: [Hooks Guide - Apache Cordova](https://cordova.apache.org/docs/en/9.x/guide/appdev/hooks/index.html))
|
||||
*
|
||||
* |Platform|Value|Type|
|
||||
* |--------|-----|----|
|
||||
* |Android|BuildConfig.\_BUILDINFO\_TIMESTAMP value|Date|
|
||||
* |iOS|Get the modification date and time of the Info.plist file acquired from the executionPath property of the main bundle.|Date|
|
||||
* |Windows|Resource value of "/buildinfo/Timestamp" string.|Date|
|
||||
* |macOS(OS X)|Get the modification date and time of the config.xml file acquired from the resource of the main bundle.|Date|
|
||||
* |Browser|The date and time when ```cordova prepare``` was executed.|Date|
|
||||
* |Electron|The date and time when ```cordova prepare``` was executed.|Date|
|
||||
*
|
||||
*/
|
||||
@CordovaProperty()
|
||||
buildDate: Date;
|
||||
|
||||
/**
|
||||
* Get the install date and time in the Date object returns.
|
||||
*
|
||||
* Attention:
|
||||
* - Browser and Electron: Installation date and time is unknown.
|
||||
*
|
||||
* |Platform|Value|Type|
|
||||
* |--------|-----|----|
|
||||
* |Android|The firstInstallTime property of PackageInfo|Date|
|
||||
* |iOS|Get the creation date and time of the document directory.|Date|
|
||||
* |Windows|The installedDate property of Windows.ApplicatinoModel.Package.current|Date|
|
||||
* |macOS(OS X)|Date and time of kMDItemDateAdded recorded in File Metadata of application package.|Date|
|
||||
* |Browser|Not available.|null|
|
||||
* |Electron|Not available.|null|
|
||||
*/
|
||||
@CordovaProperty()
|
||||
installDate: Date | null;
|
||||
|
||||
/**
|
||||
* Windows Only.
|
||||
*
|
||||
* Get the windows extra information.
|
||||
*/
|
||||
@CordovaProperty()
|
||||
windows?: {
|
||||
/**
|
||||
* indows.ApplicationModel.Package.current.id.architecture|
|
||||
*/
|
||||
architecture: number;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.description|
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.displayName|
|
||||
*/
|
||||
displayName: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.id.familyName|
|
||||
*/
|
||||
familyName: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.id.fullName|
|
||||
*/
|
||||
fullName: string;
|
||||
logo: WindowsLogo;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.id.publisher|
|
||||
*/
|
||||
publisher: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.id.publisherId|
|
||||
*/
|
||||
publisherId: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.publisherDisplayName|
|
||||
*/
|
||||
publisherDisplayName: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.id.resourceId|
|
||||
*/
|
||||
resourceId: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.id.version|
|
||||
*/
|
||||
version: WindowsVersionInfo;
|
||||
};
|
||||
}
|
||||
|
||||
export interface WindowsLogo {
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.logo.absoluteCanonicalUri
|
||||
*/
|
||||
absoluteCannonicalUri: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.logo.absoluteUri
|
||||
*/
|
||||
absoluteUri: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.logo.displayIri
|
||||
*/
|
||||
displayIri: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.logo.displayUri
|
||||
*/
|
||||
displayUri: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.logo.path
|
||||
*/
|
||||
path: string;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.logo.rawUri
|
||||
*/
|
||||
rawUri: string;
|
||||
}
|
||||
|
||||
export interface WindowsVersionInfo {
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.id.version.major
|
||||
*/
|
||||
major: number;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.id.version.minor
|
||||
*/
|
||||
minor: number;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.id.version.build
|
||||
*/
|
||||
build: number;
|
||||
/**
|
||||
* Windows.ApplicationModel.Package.current.id.version.revision
|
||||
*/
|
||||
revision: number;
|
||||
}
|
493
src/@awesome-cordova-plugins/plugins/calendar/index.ts
Normal file
493
src/@awesome-cordova-plugins/plugins/calendar/index.ts
Normal file
@ -0,0 +1,493 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface CalendarOptions {
|
||||
/**
|
||||
* Id
|
||||
*/
|
||||
id?: string;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
firstReminderMinutes?: number;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
secondReminderMinutes?: number;
|
||||
|
||||
/**
|
||||
* Recurrence. Can be set to `daily`, `weekly`, `monthly` or `yearly`
|
||||
*/
|
||||
recurrence?: string;
|
||||
|
||||
/**
|
||||
* Recurrence interval. Valid only when `recurrence` option is set.
|
||||
*/
|
||||
recurrenceInterval?: number;
|
||||
|
||||
/**
|
||||
* Recurrence end date. Valid only when `recurrence` option is set.
|
||||
*/
|
||||
recurrenceEndDate?: Date;
|
||||
|
||||
/**
|
||||
* Calendar name. Ths is supported by `iOS` only.
|
||||
*/
|
||||
calendarName?: string;
|
||||
|
||||
/**
|
||||
* Calendar id
|
||||
*/
|
||||
calendarId?: number;
|
||||
|
||||
/**
|
||||
* URL
|
||||
*/
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export interface NameOrOptions {
|
||||
/** Calendar name */
|
||||
calendarName?: string;
|
||||
|
||||
/** Calendar color as a HEX string */
|
||||
calendarColor?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Calendar
|
||||
* @premier calendar
|
||||
* @description
|
||||
* This plugin allows you to add events to the Calendar of the mobile device.
|
||||
*
|
||||
* Requires Cordova plugin: `cordova-plugin-calendar`. For more info, please see the [Calendar plugin docs](https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Calendar } from '@awesome-cordova-plugins/calendar/ngx';
|
||||
*
|
||||
* constructor(private calendar: Calendar) { }
|
||||
*
|
||||
*
|
||||
* this.calendar.createCalendar('MyCalendar').then(
|
||||
* (msg) => { console.log(msg); },
|
||||
* (err) => { console.log(err); }
|
||||
* );
|
||||
* ```
|
||||
* @interfaces
|
||||
* CalendarOptions
|
||||
* NameOrOptions
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Calendar',
|
||||
plugin: 'cordova-plugin-calendar',
|
||||
pluginRef: 'plugins.calendar',
|
||||
repo: 'https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Calendar extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* 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 targeting API level lower than 23, or
|
||||
* - You're using Android < 6, or
|
||||
* - You've already granted permission
|
||||
*
|
||||
* If this returns false, you should call the `requestReadWritePermission` function
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
hasReadWritePermission(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have read permission
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
hasReadPermission(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have write permission
|
||||
*
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
@Cordova()
|
||||
hasWritePermission(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request write permission
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
requestWritePermission(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request read permission
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
requestReadPermission(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests read/write permissions
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
requestReadWritePermission(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a calendar. (iOS only)
|
||||
*
|
||||
* @param {string | NameOrOptions} nameOrOptions either a string name or a options object. If string, provide the calendar name. IF an object, provide a calendar name as a string and a calendar color in hex format as a string
|
||||
* @returns {Promise<any>} Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
createCalendar(nameOrOptions: string | NameOrOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a calendar. (iOS only)
|
||||
*
|
||||
* @param {string} name Name of the calendar to delete.
|
||||
* @returns {Promise<any>} Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
deleteCalendar(name: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default calendar options.
|
||||
*
|
||||
* @returns {CalendarOptions} Returns an object with the default calendar options
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
getCalendarOptions(): CalendarOptions {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns options for a custom calender with specific color
|
||||
*
|
||||
* @returns {NameOrOptions} Returns an object with the default options
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
getCreateCalendarOptions(): NameOrOptions {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Silently create an event.
|
||||
*
|
||||
* @param {string} [title] The event title
|
||||
* @param {string} [location] The event location
|
||||
* @param {string} [notes] The event notes
|
||||
* @param {Date} [startDate] The event start date
|
||||
* @param {Date} [endDate] The event end date
|
||||
* @returns {Promise<any>} Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
createEvent(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Silently create an event with additional options.
|
||||
*
|
||||
* @param {string} [title] The event title
|
||||
* @param {string} [location] The event location
|
||||
* @param {string} [notes] The event notes
|
||||
* @param {Date} [startDate] The event start date
|
||||
* @param {Date} [endDate] The event end date
|
||||
* @param {CalendarOptions} [options] Additional options, see `getCalendarOptions`
|
||||
* @returns {Promise<any>} Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
createEventWithOptions(
|
||||
title?: string,
|
||||
location?: string,
|
||||
notes?: string,
|
||||
startDate?: Date,
|
||||
endDate?: Date,
|
||||
options?: CalendarOptions
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interactively create an event.
|
||||
*
|
||||
* @param {string} [title] The event title
|
||||
* @param {string} [location] The event location
|
||||
* @param {string} [notes] The event notes
|
||||
* @param {Date} [startDate] The event start date
|
||||
* @param {Date} [endDate] The event end date
|
||||
* @returns {Promise<any>} Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
createEventInteractively(
|
||||
title?: string,
|
||||
location?: string,
|
||||
notes?: string,
|
||||
startDate?: Date,
|
||||
endDate?: Date
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interactively create an event with additional options.
|
||||
*
|
||||
* @param {string} [title] The event title
|
||||
* @param {string} [location] The event location
|
||||
* @param {string} [notes] The event notes
|
||||
* @param {Date} [startDate] The event start date
|
||||
* @param {Date} [endDate] The event end date
|
||||
* @param {CalendarOptions} [options] Additional options, see `getCalendarOptions`
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
createEventInteractivelyWithOptions(
|
||||
title?: string,
|
||||
location?: string,
|
||||
notes?: string,
|
||||
startDate?: Date,
|
||||
endDate?: Date,
|
||||
options?: CalendarOptions
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an event.
|
||||
*
|
||||
* @param {string} [title] The event title
|
||||
* @param {string} [location] The event location
|
||||
* @param {string} [notes] The event notes
|
||||
* @param {Date} [startDate] The event start date
|
||||
* @param {Date} [endDate] The event end date
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
findEvent(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an event with additional options.
|
||||
*
|
||||
* @param {string} [title] The event title
|
||||
* @param {string} [location] The event location
|
||||
* @param {string} [notes] The event notes
|
||||
* @param {Date} [startDate] The event start date
|
||||
* @param {Date} [endDate] The event end date
|
||||
* @param {CalendarOptions} [options] Additional options, see `getCalendarOptions`
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with the event, or rejects with an error.
|
||||
*/
|
||||
@Cordova()
|
||||
findEventWithOptions(
|
||||
title?: string,
|
||||
location?: string,
|
||||
notes?: string,
|
||||
startDate?: Date,
|
||||
endDate?: Date,
|
||||
options?: CalendarOptions
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a list of events within the specified date range. (Android only)
|
||||
*
|
||||
* @param {Date} [startDate] The start date
|
||||
* @param {Date} [endDate] The end date
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with the list of events, or rejects with an error.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['Android'],
|
||||
})
|
||||
listEventsInRange(startDate: Date, endDate: Date): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all calendars.
|
||||
*
|
||||
* @returns {Promise<any>} A Promise that resolves with the list of calendars, or rejects with an error.
|
||||
*/
|
||||
@Cordova()
|
||||
listCalendars(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all future events in the specified calendar. (iOS only)
|
||||
*
|
||||
* @param calendarName
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with the list of events, or rejects with an error.
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
findAllEventsInNamedCalendar(calendarName: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify an event. (iOS only)
|
||||
*
|
||||
* @param {string} [title] The event title
|
||||
* @param {string} [location] The event location
|
||||
* @param {string} [notes] The event notes
|
||||
* @param {Date} [startDate] The event start date
|
||||
* @param {Date} [endDate] The event end date
|
||||
* @param {string} [newTitle] The new event title
|
||||
* @param {string} [newLocation] The new event location
|
||||
* @param {string} [newNotes] The new event notes
|
||||
* @param {Date} [newStartDate] The new event start date
|
||||
* @param {Date} [newEndDate] The new event end date
|
||||
* @returns Returns a Promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
modifyEvent(
|
||||
title?: string,
|
||||
location?: string,
|
||||
notes?: string,
|
||||
startDate?: Date,
|
||||
endDate?: Date,
|
||||
newTitle?: string,
|
||||
newLocation?: string,
|
||||
newNotes?: string,
|
||||
newStartDate?: Date,
|
||||
newEndDate?: Date
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify an event with additional options. (iOS only)
|
||||
*
|
||||
* @param {string} [title] The event title
|
||||
* @param {string} [location] The event location
|
||||
* @param {string} [notes] The event notes
|
||||
* @param {Date} [startDate] The event start date
|
||||
* @param {Date} [endDate] The event end date
|
||||
* @param {string} [newTitle] The new event title
|
||||
* @param {string} [newLocation] The new event location
|
||||
* @param {string} [newNotes] The new event notes
|
||||
* @param {Date} [newStartDate] The new event start date
|
||||
* @param {Date} [newEndDate] The new event end date
|
||||
* @param {CalendarOptions} [filterOptions] Event Options, see `getCalendarOptions`
|
||||
* @param {CalendarOptions} [newOptions] New event options, see `getCalendarOptions`
|
||||
* @returns Returns a Promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
modifyEventWithOptions(
|
||||
title?: string,
|
||||
location?: string,
|
||||
notes?: string,
|
||||
startDate?: Date,
|
||||
endDate?: Date,
|
||||
newTitle?: string,
|
||||
newLocation?: string,
|
||||
newNotes?: string,
|
||||
newStartDate?: Date,
|
||||
newEndDate?: Date,
|
||||
filterOptions?: CalendarOptions,
|
||||
newOptions?: CalendarOptions
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an event.
|
||||
*
|
||||
* @param {string} [title] The event title
|
||||
* @param {string} [location] The event location
|
||||
* @param {string} [notes] The event notes
|
||||
* @param {Date} [startDate] The event start date
|
||||
* @param {Date} [endDate] The event end date
|
||||
* @returns Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
deleteEvent(title?: string, location?: string, notes?: string, startDate?: Date, endDate?: Date): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an event from the specified Calendar. (iOS only)
|
||||
*
|
||||
* @param {string} [title] The event title
|
||||
* @param {string} [location] The event location
|
||||
* @param {string} [notes] The event notes
|
||||
* @param {Date} [startDate] The event start date
|
||||
* @param {Date} [endDate] The event end date
|
||||
* @param {string} calendarName
|
||||
* @returns Returns a Promise
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
deleteEventFromNamedCalendar(
|
||||
title?: string,
|
||||
location?: string,
|
||||
notes?: string,
|
||||
startDate?: Date,
|
||||
endDate?: Date,
|
||||
calendarName?: string
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an event by id.
|
||||
*
|
||||
* @param {string} [id] The event id
|
||||
* @param {Date} [fromDate] The date where it start deleting from
|
||||
* @returns Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
deleteEventById(id: string, fromDate?: Date): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the calendar at the specified date.
|
||||
*
|
||||
* @param {Date} date The date you want to open the calendar on
|
||||
* @returns {Promise<any>} Promise returns a promise
|
||||
*/
|
||||
@Cordova()
|
||||
openCalendar(date: Date): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
123
src/@awesome-cordova-plugins/plugins/call-directory/index.ts
Normal file
123
src/@awesome-cordova-plugins/plugins/call-directory/index.ts
Normal file
@ -0,0 +1,123 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface CallDirectoryItem {
|
||||
label: string;
|
||||
number: string;
|
||||
}
|
||||
|
||||
export interface CallDirectoryLog {
|
||||
plugin: string[];
|
||||
extension: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Call Directory
|
||||
* @description
|
||||
* This plugin can add phone numbers to an Callkit call directory extension. Call `reloadExtension` after using `addIdentification` and `removeIdentification`
|
||||
* to process the changes in the call directory extension.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { CallDirectory } from '@awesome-cordova-plugins/call-directory/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private callDirectory: CallDirectory) { }
|
||||
*
|
||||
*
|
||||
* let items = [{label: "Hello", number: "123"}];
|
||||
* this.callDirectory.addIdentification(items)
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* this.callDirectory.reloadExtension()
|
||||
* .then(res: string) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
* ```
|
||||
* @Interfaces
|
||||
* CallDirectoryItem
|
||||
* CallDirectoryLog
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'CallDirectory',
|
||||
plugin: 'cordova-plugin-call-directory',
|
||||
pluginRef: 'CallDirectory',
|
||||
repo: 'https://github.com/GEDYSIntraWare/cordova-plugin-call-directory',
|
||||
install:
|
||||
'cordova plugin add cordova-plugin-call-directory --variable EXT_NAME="Cordova-Directory" --variable ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES="NO"',
|
||||
installVariables: ['EXT_NAME', 'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'],
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class CallDirectory extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Check if the call directory extension is available and enabled
|
||||
*
|
||||
* @returns {Promise<boolean>} Returns a promise with result
|
||||
*/
|
||||
@Cordova()
|
||||
isAvailable(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add identification numbers
|
||||
*
|
||||
* @param {CallDirectoryItem[]} items Set of numbers with labels
|
||||
* @returns {Promise<any>} Returns a promise that resolves when numbers are added
|
||||
*/
|
||||
@Cordova()
|
||||
addIdentification(items: CallDirectoryItem[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove identification numbers
|
||||
*
|
||||
* @param {CallDirectoryItem[]} items Set of numbers with arbitrary label
|
||||
* @returns {Promise<any>} Returns a promise that resolves when numbers are removed
|
||||
*/
|
||||
@Cordova()
|
||||
removeIdentification(items: CallDirectoryItem[]): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all items from call directory. Refreshes immediately.
|
||||
*
|
||||
* @returns {Promise<any>} Returns a promise after refresh with message
|
||||
*/
|
||||
@Cordova()
|
||||
removeAllIdentification(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all numbers and labels in call directory
|
||||
*
|
||||
* @returns {CallDirectoryItem[]} Returns a promise that resolves with an array of all items
|
||||
*/
|
||||
@Cordova()
|
||||
getAllItems(): Promise<CallDirectoryItem[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload extension to process queued changes
|
||||
*
|
||||
* @returns {Promise<string>} Returns a promise after refresh with message
|
||||
*/
|
||||
@Cordova()
|
||||
reloadExtension(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get log from plugin and call directory extension
|
||||
*
|
||||
* @returns {Promise<CallDirectoryLog>} Returns a promise with an object of log messages
|
||||
*/
|
||||
@Cordova()
|
||||
getLog(): Promise<CallDirectoryLog> {
|
||||
return;
|
||||
}
|
||||
}
|
56
src/@awesome-cordova-plugins/plugins/call-number/index.ts
Normal file
56
src/@awesome-cordova-plugins/plugins/call-number/index.ts
Normal file
@ -0,0 +1,56 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name Call Number
|
||||
* @description
|
||||
* Call a number directly from your Cordova/Ionic application.
|
||||
* NOTE**: The iOS Simulator (and maybe Android Simulators) do not provide access to the phone subsystem.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { CallNumber } from '@awesome-cordova-plugins/call-number/ngx';
|
||||
*
|
||||
* constructor(private callNumber: CallNumber) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.callNumber.callNumber("18001010101", true)
|
||||
* .then(res => console.log('Launched dialer!', res))
|
||||
* .catch(err => console.log('Error launching dialer', err));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'CallNumber',
|
||||
plugin: 'call-number',
|
||||
pluginRef: 'plugins.CallNumber',
|
||||
repo: 'https://github.com/Rohfosho/CordovaCallNumberPlugin',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class CallNumber extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Calls a phone number
|
||||
*
|
||||
* @param {string} numberToCall The phone number to call as a string
|
||||
* @param {boolean} bypassAppChooser Set to true to bypass the app chooser and go directly to dialer
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
callNumber(numberToCall: string, bypassAppChooser: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if call feature is available
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
isCallSupported(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
551
src/@awesome-cordova-plugins/plugins/camera-preview/index.ts
Normal file
551
src/@awesome-cordova-plugins/plugins/camera-preview/index.ts
Normal file
@ -0,0 +1,551 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface CameraPreviewDimensions {
|
||||
/** The width of the camera preview, default to window.screen.width */
|
||||
width?: number;
|
||||
|
||||
/** The height of the camera preview, default to window.screen.height */
|
||||
height?: number;
|
||||
}
|
||||
|
||||
export interface CameraPreviewOptions {
|
||||
/** The left edge in pixels, default 0 */
|
||||
x?: number;
|
||||
|
||||
/** The top edge in pixels, default 0 */
|
||||
y?: number;
|
||||
|
||||
/** The width in pixels, default window.screen.width */
|
||||
width?: number;
|
||||
|
||||
/** The height in pixels, default window.screen.height */
|
||||
height?: number;
|
||||
|
||||
/** Choose the camera to use 'front' or 'rear', default 'front' */
|
||||
camera?: string;
|
||||
|
||||
/** Tap to take a photo, default true (picture quality by default : 85) */
|
||||
tapPhoto?: boolean;
|
||||
|
||||
/** Preview box drag across the screen, default 'false' */
|
||||
previewDrag?: boolean;
|
||||
|
||||
/** Capture images to a file and return back the file path instead of returning base64 encoded data. */
|
||||
storeToFile: boolean;
|
||||
|
||||
/** Preview box to the back of the webview (true => back, false => front) , default false */
|
||||
toBack?: boolean;
|
||||
|
||||
/** Alpha channel of the preview box, float, [0,1], default 1 */
|
||||
alpha?: number;
|
||||
|
||||
/** Tap to set specific focus point. Note, this assumes the camera is full-screen. default false */
|
||||
tapFocus?: boolean;
|
||||
|
||||
/** On Android disable automatic rotation of the image and stripping of Exit header. default false */
|
||||
disableExifHeaderStripping?: boolean;
|
||||
}
|
||||
|
||||
export interface CameraPreviewPictureOptions {
|
||||
/** The width in pixels, default 0 */
|
||||
width?: number;
|
||||
/** The height in pixels, default 0 */
|
||||
height?: number;
|
||||
/** The picture quality, 0 - 100, default 85 */
|
||||
quality?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @beta
|
||||
* @name Camera Preview
|
||||
* @description
|
||||
* Showing camera preview in HTML
|
||||
*
|
||||
* Requires Cordova plugin: `https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview.git`. For more info, please see the [Cordova Camera Preview docs](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { CameraPreview, CameraPreviewPictureOptions, CameraPreviewOptions, CameraPreviewDimensions } from '@awesome-cordova-plugins/camera-preview/ngx';
|
||||
*
|
||||
* constructor(private cameraPreview: CameraPreview) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // camera options (Size and location). In the following example, the preview uses the rear camera and display the preview in the back of the webview
|
||||
* const cameraPreviewOpts: CameraPreviewOptions = {
|
||||
* x: 0,
|
||||
* y: 0,
|
||||
* width: window.screen.width,
|
||||
* height: window.screen.height,
|
||||
* camera: 'rear',
|
||||
* tapPhoto: true,
|
||||
* previewDrag: true,
|
||||
* toBack: true,
|
||||
* alpha: 1
|
||||
* }
|
||||
*
|
||||
* // start camera
|
||||
* this.cameraPreview.startCamera(cameraPreviewOpts).then(
|
||||
* (res) => {
|
||||
* console.log(res)
|
||||
* },
|
||||
* (err) => {
|
||||
* console.log(err)
|
||||
* });
|
||||
*
|
||||
* // Set the handler to run every time we take a picture
|
||||
* this.cameraPreview.setOnPictureTakenHandler().subscribe((result) => {
|
||||
* console.log(result);
|
||||
* // do something with the result
|
||||
* });
|
||||
*
|
||||
*
|
||||
* // picture options
|
||||
* const pictureOpts: CameraPreviewPictureOptions = {
|
||||
* width: 1280,
|
||||
* height: 1280,
|
||||
* quality: 85
|
||||
* }
|
||||
*
|
||||
* // take a picture
|
||||
* this.cameraPreview.takePicture(this.pictureOpts).then((imageData) => {
|
||||
* this.picture = 'data:image/jpeg;base64,' + imageData;
|
||||
* }, (err) => {
|
||||
* console.log(err);
|
||||
* this.picture = 'assets/img/test.jpg';
|
||||
* });
|
||||
*
|
||||
* // take a snap shot
|
||||
* this.cameraPreview.takeSnapshot(this.pictureOpts).then((imageData) => {
|
||||
* this.picture = 'data:image/jpeg;base64,' + imageData;
|
||||
* }, (err) => {
|
||||
* console.log(err);
|
||||
* this.picture = 'assets/img/test.jpg';
|
||||
* });
|
||||
*
|
||||
*
|
||||
* // Switch camera
|
||||
* this.cameraPreview.switchCamera();
|
||||
*
|
||||
* // set color effect to negative
|
||||
* this.cameraPreview.setColorEffect('negative');
|
||||
*
|
||||
* // Stop the camera preview
|
||||
* this.cameraPreview.stopCamera();
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* CameraPreviewOptions
|
||||
* CameraPreviewPictureOptions
|
||||
* CameraPreviewDimensions
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'CameraPreview',
|
||||
plugin: 'cordova-plugin-camera-preview',
|
||||
pluginRef: 'CameraPreview',
|
||||
repo: 'https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class CameraPreview extends AwesomeCordovaNativePlugin {
|
||||
FOCUS_MODE = {
|
||||
FIXED: 'fixed',
|
||||
AUTO: 'auto',
|
||||
CONTINUOUS: 'continuous', // IOS Only
|
||||
CONTINUOUS_PICTURE: 'continuous-picture', // Android Only
|
||||
CONTINUOUS_VIDEO: 'continuous-video', // Android Only
|
||||
EDOF: 'edof', // Android Only
|
||||
INFINITY: 'infinity', // Android Only
|
||||
MACRO: 'macro', // Android Only
|
||||
};
|
||||
|
||||
EXPOSURE_MODE = {
|
||||
LOCK: 'lock', // IOS Only
|
||||
AUTO: 'auto', // IOS Only
|
||||
CONTINUOUS: 'continuous',
|
||||
CUSTOM: 'custom',
|
||||
};
|
||||
|
||||
FLASH_MODE = {
|
||||
OFF: 'off',
|
||||
ON: 'on',
|
||||
AUTO: 'auto',
|
||||
RED_EYE: 'red-eye',
|
||||
TORCH: 'torch', // Android Only
|
||||
};
|
||||
|
||||
COLOR_EFFECT = {
|
||||
AQUA: 'aqua', // Android Only
|
||||
BLACKBOARD: 'blackboard', // Android Only
|
||||
MONO: 'mono',
|
||||
NEGATIVE: 'negative',
|
||||
NONE: 'none',
|
||||
POSTERIZE: 'posterize',
|
||||
SEPIA: 'sepia',
|
||||
SOLARIZE: 'solarize', // Android Only
|
||||
WHITEBOARD: 'whiteboard', // Android Only
|
||||
};
|
||||
|
||||
CAMERA_DIRECTION = {
|
||||
BACK: 'back',
|
||||
FRONT: 'front',
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts the camera preview instance.
|
||||
*
|
||||
* @param {CameraPreviewOptions} options
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
startCamera(options: CameraPreviewOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the camera video instance.
|
||||
*
|
||||
* @param {any} options
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
startRecordVideo(options: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the camera preview instance. (iOS & Android)
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
stopCamera(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the camera video instance. (iOS & Android)
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
stopRecordVideo(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch from the rear camera and front camera, if available.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
switchCamera(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the camera preview box.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
hide(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the camera preview box.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
show(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take the picture (base64)
|
||||
*
|
||||
* @param {CameraPreviewPictureOptions} [options] size and quality of the picture to take
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
takePicture(options?: CameraPreviewPictureOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a snapshot of preview window (size specified in startCamera options)
|
||||
*
|
||||
* @param {CameraPreviewPictureOptions} [options] quality of the picture to take
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
takeSnapshot(options?: CameraPreviewPictureOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Set camera color effect.
|
||||
*
|
||||
* @static
|
||||
* @param {string} effect name : 'none' (iOS & Android), 'aqua' (Android), 'blackboard' (Android), 'mono' (iOS & Android), 'negative' (iOS & Android), 'posterize' (iOS & Android), 'sepia' (iOS & Android), 'solarize' (Android) or 'whiteboard' (Android)
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
setColorEffect(effect: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the zoom (Android)
|
||||
*
|
||||
* @param [zoom] {number} Zoom value
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
setZoom(zoom?: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum zoom (Android)
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getMaxZoom(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current zoom (Android)
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getZoom(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the preview Size
|
||||
*
|
||||
* @param {CameraPreviewDimensions} [dimensions]
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
setPreviewSize(dimensions?: CameraPreviewDimensions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get focus mode
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getFocusMode(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the focus mode
|
||||
*
|
||||
* @param {string} [focusMode] 'fixed', 'auto', 'continuous-picture', 'continuous-video' (iOS & Android), 'edof', 'infinity', 'macro' (Android Only)
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
setFocusMode(focusMode?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get supported focus modes
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getSupportedFocusModes(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current flash mode
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getFlashMode(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the flash mode
|
||||
*
|
||||
* @param {string} [flashMode] 'off' (iOS & Android), 'on' (iOS & Android), 'auto' (iOS & Android), 'torch' (Android)
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
setFlashMode(flashMode?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get supported flash modes
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getSupportedFlashModes(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get supported picture sizes
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getSupportedPictureSizes(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get exposure mode
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getExposureMode(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get exposure modes
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getExposureModes(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set exposure mode
|
||||
*
|
||||
* @param {string} [lock]
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
setExposureMode(lock?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get exposure compensation (Android)
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getExposureCompensation(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set exposure compensation (Android)
|
||||
*
|
||||
* @param {number} [exposureCompensation]
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
setExposureCompensation(exposureCompensation?: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get exposure compensation range (Android)
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getExposureCompensationRange(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set specific focus point. Note, this assumes the camera is full-screen.
|
||||
*
|
||||
* @param {number} xPoint
|
||||
* @param {number} yPoint
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
tapToFocus(xPoint: number, yPoint: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a listener for the back event for the preview
|
||||
*
|
||||
* @returns {Promise<any>} if back button pressed
|
||||
*/
|
||||
@Cordova()
|
||||
onBackButton(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return in use device camera fov
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getHorizontalFOV(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the characteristics of all available cameras
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
getCameraCharacteristics(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
268
src/@awesome-cordova-plugins/plugins/camera/index.ts
Normal file
268
src/@awesome-cordova-plugins/plugins/camera/index.ts
Normal file
@ -0,0 +1,268 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface CameraOptions {
|
||||
/** Picture quality in range 0-100. Default is 50 */
|
||||
quality?: number;
|
||||
/**
|
||||
* Choose the format of the return value.
|
||||
* Defined in Camera.DestinationType. Default is FILE_URI.
|
||||
* DATA_URL : 0, Return image as base64-encoded string (DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible),
|
||||
* FILE_URI : 1, Return image file URI,
|
||||
* NATIVE_URI : 2 Return image native URI
|
||||
* (e.g., assets-library:// on iOS or content:// on Android)
|
||||
*/
|
||||
destinationType?: number;
|
||||
/**
|
||||
* Set the source of the picture.
|
||||
* Defined in Camera.PictureSourceType. Default is CAMERA.
|
||||
* PHOTOLIBRARY : 0,
|
||||
* CAMERA : 1,
|
||||
* SAVEDPHOTOALBUM : 2
|
||||
*/
|
||||
sourceType?: number;
|
||||
/** Allow simple editing of image before selection. */
|
||||
allowEdit?: boolean;
|
||||
/**
|
||||
* Choose the returned image file's encoding.
|
||||
* Defined in Camera.EncodingType. Default is JPEG
|
||||
* JPEG : 0 Return JPEG encoded image
|
||||
* PNG : 1 Return PNG encoded image
|
||||
*/
|
||||
encodingType?: number;
|
||||
/**
|
||||
* Width in pixels to scale image. Must be used with targetHeight.
|
||||
* Aspect ratio remains constant.
|
||||
*/
|
||||
targetWidth?: number;
|
||||
/**
|
||||
* Height in pixels to scale image. Must be used with targetWidth.
|
||||
* Aspect ratio remains constant.
|
||||
*/
|
||||
targetHeight?: number;
|
||||
/**
|
||||
* Set the type of media to select from. Only works when PictureSourceType
|
||||
* is PHOTOLIBRARY or SAVEDPHOTOALBUM. Defined in Camera.MediaType
|
||||
* PICTURE: 0 allow selection of still pictures only. DEFAULT.
|
||||
* Will return format specified via DestinationType
|
||||
* VIDEO: 1 allow selection of video only, WILL ALWAYS RETURN FILE_URI
|
||||
* ALLMEDIA : 2 allow selection from all media types
|
||||
*/
|
||||
mediaType?: number;
|
||||
/** Rotate the image to correct for the orientation of the device during capture. */
|
||||
correctOrientation?: boolean;
|
||||
/** Save the image to the photo album on the device after capture. */
|
||||
saveToPhotoAlbum?: boolean;
|
||||
/**
|
||||
* Choose the camera to use (front- or back-facing).
|
||||
* Defined in Camera.Direction. Default is BACK.
|
||||
* BACK: 0
|
||||
* FRONT: 1
|
||||
*/
|
||||
cameraDirection?: number;
|
||||
/** iOS-only options that specify popover location in iPad. Defined in CameraPopoverOptions. */
|
||||
popoverOptions?: CameraPopoverOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* iOS-only parameters that specify the anchor element location and arrow direction
|
||||
* of the popover when selecting images from an iPad's library or album.
|
||||
*/
|
||||
export interface CameraPopoverOptions {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
/**
|
||||
* Direction the arrow on the popover should point. Defined in Camera.PopoverArrowDirection
|
||||
* Matches iOS UIPopoverArrowDirection constants.
|
||||
* ARROW_UP : 1,
|
||||
* ARROW_DOWN : 2,
|
||||
* ARROW_LEFT : 4,
|
||||
* ARROW_RIGHT : 8,
|
||||
* ARROW_ANY : 15
|
||||
*/
|
||||
arrowDir: number;
|
||||
}
|
||||
|
||||
export enum DestinationType {
|
||||
DATA_URL = 0,
|
||||
FILE_URL,
|
||||
NATIVE_URI,
|
||||
}
|
||||
|
||||
export enum EncodingType {
|
||||
JPEG = 0,
|
||||
PNG,
|
||||
}
|
||||
|
||||
export enum MediaType {
|
||||
PICTURE = 0,
|
||||
VIDEO,
|
||||
ALLMEDIA,
|
||||
}
|
||||
|
||||
export enum PictureSourceType {
|
||||
PHOTOLIBRARY = 0,
|
||||
CAMERA,
|
||||
SAVEDPHOTOALBUM,
|
||||
}
|
||||
|
||||
export enum PopoverArrowDirection {
|
||||
ARROW_UP = 1,
|
||||
ARROW_DOWN,
|
||||
ARROW_LEFT,
|
||||
ARROW_RIGHT,
|
||||
ARROW_ANY,
|
||||
}
|
||||
|
||||
export enum Direction {
|
||||
BACK = 0,
|
||||
FRONT,
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Camera
|
||||
* @premier camera
|
||||
* @description
|
||||
* Take a photo or capture video.
|
||||
*
|
||||
* Requires the Cordova plugin: `cordova-plugin-camera`. For more info, please see the [Cordova Camera Plugin Docs](https://github.com/apache/cordova-plugin-camera).
|
||||
*
|
||||
* [Warning] Since IOS 10 the camera requires permissions to be placed in your config.xml add
|
||||
* ```xml
|
||||
* <config-file parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist">
|
||||
* <string>You can take photos</string>
|
||||
* </config-file>
|
||||
* ```
|
||||
* inside of the `<platform name='ios>` section
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Camera, CameraOptions } from '@awesome-cordova-plugins/camera/ngx';
|
||||
*
|
||||
* constructor(private camera: Camera) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* const options: CameraOptions = {
|
||||
* quality: 100,
|
||||
* destinationType: this.camera.DestinationType.FILE_URI,
|
||||
* encodingType: this.camera.EncodingType.JPEG,
|
||||
* mediaType: this.camera.MediaType.PICTURE
|
||||
* }
|
||||
*
|
||||
* this.camera.getPicture(options).then((imageData) => {
|
||||
* // imageData is either a base64 encoded string or a file URI
|
||||
* // If it's base64 (DATA_URL):
|
||||
* let base64Image = 'data:image/jpeg;base64,' + imageData;
|
||||
* }, (err) => {
|
||||
* // Handle error
|
||||
* });
|
||||
* ```
|
||||
* @interfaces
|
||||
* CameraOptions
|
||||
* CameraPopoverOptions
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Camera',
|
||||
plugin: 'cordova-plugin-camera',
|
||||
pluginRef: 'navigator.camera',
|
||||
repo: 'https://github.com/apache/cordova-plugin-camera',
|
||||
platforms: ['Android', 'Browser', 'iOS', 'Windows'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Camera extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Constant for possible destination types
|
||||
*/
|
||||
DestinationType = {
|
||||
/** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible */
|
||||
DATA_URL: 0,
|
||||
/** Return file uri (content://media/external/images/media/2 for Android) */
|
||||
FILE_URI: 1,
|
||||
/** Return native uri (eg. asset-library://... for iOS) */
|
||||
NATIVE_URI: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Convenience constant
|
||||
*/
|
||||
EncodingType = {
|
||||
/** Return JPEG encoded image */
|
||||
JPEG: 0,
|
||||
/** Return PNG encoded image */
|
||||
PNG: 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Convenience constant
|
||||
*/
|
||||
MediaType = {
|
||||
/** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */
|
||||
PICTURE: 0,
|
||||
/** Allow selection of video only, ONLY RETURNS URL */
|
||||
VIDEO: 1,
|
||||
/** Allow selection from all media types */
|
||||
ALLMEDIA: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Convenience constant
|
||||
*/
|
||||
PictureSourceType = {
|
||||
/** Choose image from picture library (same as PHOTOLIBRARY for Android) */
|
||||
PHOTOLIBRARY: 0,
|
||||
/** Take picture from camera */
|
||||
CAMERA: 1,
|
||||
/** Choose image from picture library (same as SAVEDPHOTOALBUM for Android) */
|
||||
SAVEDPHOTOALBUM: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Convenience constant
|
||||
*/
|
||||
PopoverArrowDirection = {
|
||||
ARROW_UP: 1,
|
||||
ARROW_DOWN: 2,
|
||||
ARROW_LEFT: 4,
|
||||
ARROW_RIGHT: 8,
|
||||
ARROW_ANY: 15,
|
||||
};
|
||||
|
||||
/**
|
||||
* Convenience constant
|
||||
*/
|
||||
Direction = {
|
||||
/** Use the back-facing camera */
|
||||
BACK: 0,
|
||||
/** Use the front-facing camera */
|
||||
FRONT: 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Take a picture or video, or load one from the library.
|
||||
*
|
||||
* @param {CameraOptions} [options] Options that you want to pass to the camera. Encoding type, quality, etc. Platform-specific quirks are described in the [Cordova plugin docs](https://github.com/apache/cordova-plugin-camera#cameraoptions-errata-).
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with Base64 encoding of the image data, or the image file URI, depending on cameraOptions, otherwise rejects with an error.
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
getPicture(options?: CameraOptions): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove intermediate image files that are kept in temporary storage after calling camera.getPicture.
|
||||
* Applies only when the value of Camera.sourceType equals Camera.PictureSourceType.CAMERA and the Camera.destinationType equals Camera.DestinationType.FILE_URI.
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
cleanup(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
223
src/@awesome-cordova-plugins/plugins/checkout/index.ts
Normal file
223
src/@awesome-cordova-plugins/plugins/checkout/index.ts
Normal file
@ -0,0 +1,223 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface CkoCardTokenRequest {
|
||||
/**
|
||||
* The card number
|
||||
*/
|
||||
number: string;
|
||||
/**
|
||||
* The expiry month of the card
|
||||
*/
|
||||
expiry_month: string;
|
||||
/**
|
||||
* The expiry year of the card
|
||||
*/
|
||||
expiry_year: string;
|
||||
/**
|
||||
* The card verification value/code. 3 digits, except for Amex (4 digits)
|
||||
*/
|
||||
cvv?: string;
|
||||
/**
|
||||
* The cardholder's name
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* The cardholder's billing address
|
||||
*/
|
||||
billing_address?: Address;
|
||||
/**
|
||||
* The cardholder's phone number
|
||||
*/
|
||||
phone?: Phone;
|
||||
}
|
||||
|
||||
export interface CkoCardTokenResponse {
|
||||
/**
|
||||
* The token type
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* The token value
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* The expiration datetime of the token
|
||||
*/
|
||||
expires_on: string;
|
||||
/**
|
||||
* The expiry month of the card
|
||||
*/
|
||||
expiry_month: number;
|
||||
/**
|
||||
* The expiry year of the card
|
||||
*/
|
||||
expiry_year: number;
|
||||
/**
|
||||
* The cardholder's name
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The card scheme
|
||||
*/
|
||||
scheme: string;
|
||||
/**
|
||||
* The last 4 digit of the card number
|
||||
*/
|
||||
last4: string;
|
||||
/**
|
||||
* The bin range of the card
|
||||
*/
|
||||
bin: string;
|
||||
/**
|
||||
* The card type
|
||||
*/
|
||||
card_type: string;
|
||||
/**
|
||||
* The card category
|
||||
*/
|
||||
card_category: string;
|
||||
/**
|
||||
* The card issuer name
|
||||
*/
|
||||
issuer: string;
|
||||
/**
|
||||
* The card issuer country (two-letter ISO)
|
||||
*/
|
||||
issuer_country: string;
|
||||
/**
|
||||
* The card product id
|
||||
*/
|
||||
product_id: string;
|
||||
/**
|
||||
* The card product type
|
||||
*/
|
||||
product_type: string;
|
||||
/**
|
||||
* The cardholder's billing address
|
||||
*/
|
||||
billing_address: Address;
|
||||
/**
|
||||
* The cardholder's phone number
|
||||
*/
|
||||
phone: Phone;
|
||||
}
|
||||
|
||||
export interface Address {
|
||||
/**
|
||||
* The first line of the address
|
||||
*/
|
||||
address_line1?: string;
|
||||
/**
|
||||
* The second line of the address
|
||||
*/
|
||||
address_line2?: string;
|
||||
/**
|
||||
* The address city
|
||||
*/
|
||||
city?: string;
|
||||
/**
|
||||
* The address state
|
||||
*/
|
||||
state?: string;
|
||||
/**
|
||||
* The address zip/postal code
|
||||
*/
|
||||
zip?: string;
|
||||
/**
|
||||
* The two-letter ISO country code of the address
|
||||
*/
|
||||
country?: string;
|
||||
}
|
||||
|
||||
export interface Phone {
|
||||
/**
|
||||
* The international country calling code. Required for some risk checks
|
||||
*/
|
||||
country_code: string;
|
||||
/**
|
||||
* The phone number
|
||||
*/
|
||||
number: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Checkout
|
||||
* @description
|
||||
* Checkout.com cordova plugin
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Checkout } from '@awesome-cordova-plugins/checkout/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private checkout: Checkout) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.checkout.initSandboxClient("pk_test_7d395871-0d66-4b62-85b6-8424df78b125")
|
||||
* .then(() => this.label = "CKO init completed")
|
||||
* .catch(err => this.label = err)
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* let tokenRequest: CkoCardTokenRequest = {
|
||||
* number: "4543474002249996",
|
||||
* cvv: "010",
|
||||
* expiry_month: "08",
|
||||
* expiry_year: "2025",
|
||||
* billing_address: {
|
||||
* country: "FR"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
*
|
||||
* this.cko.generateToken(tokenRequest)
|
||||
* .then(tokenResponse => this.label = "Token: " + tokenResponse.token)
|
||||
* .catch(err => this.label = err)
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Checkout',
|
||||
plugin: '@checkout.com/cordova-plugin-checkout',
|
||||
pluginRef: 'cordova.plugins.Checkout',
|
||||
repo: 'https://github.com/checkout/frames-cordova',
|
||||
install: '',
|
||||
installVariables: [],
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Checkout extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Initialize Frames plugin in Sandbox mode
|
||||
*
|
||||
* @param publicKey {string} Merchant's sandbox public key
|
||||
* @returns {Promise<any>} Returns a promise that resolves when Frames initiation is completed
|
||||
*/
|
||||
@Cordova()
|
||||
initSandboxClient(publicKey: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Frames plugin in Live mode
|
||||
*
|
||||
* @param publicKey {string} Merchant's live public key
|
||||
* @returns {Promise<any>} Returns a promise that resolves when Frames initiation is completed
|
||||
*/
|
||||
@Cordova()
|
||||
initLiveClient(publicKey: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exchange card details for a reference token that can be used later to request a card payment from your backend. Tokens are single use and expire after 15 minutes.
|
||||
*
|
||||
* @param ckoCardTokenRequest {CkoCardTokenRequest} Card tokenization request object
|
||||
* @returns {Promise<CkoCardTokenResponse>} Returns a promise that resolves when Token response object
|
||||
*/
|
||||
@Cordova()
|
||||
generateToken(ckoCardTokenRequest: CkoCardTokenRequest): Promise<CkoCardTokenResponse> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface ChooserResult {
|
||||
mediaType: string;
|
||||
name: string;
|
||||
uri: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Chooser
|
||||
* @description
|
||||
* File chooser plugin for Cordova.
|
||||
*
|
||||
* The following must be added to config.xml to prevent crashing when selecting large files on Android:
|
||||
* ```xml
|
||||
* <platform name="android">
|
||||
* <edit-config
|
||||
* file="app/src/main/AndroidManifest.xml"
|
||||
* mode="merge"
|
||||
* target="/manifest/application">
|
||||
* <application android:largeHeap="true" />
|
||||
* </edit-config>
|
||||
* </platform>
|
||||
* ```
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Chooser } from '@awesome-cordova-plugins/chooser-simple-file/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private chooser: Chooser) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.chooser.getFiles()
|
||||
* .then(files => console.log(files ? files.name : 'canceled'))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* ChooserResult
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Chooser',
|
||||
plugin: 'cordova-plugin-simple-file-chooser',
|
||||
pluginRef: 'chooser',
|
||||
repo: 'https://github.com/hc-oss/cordova-plugin-simple-file-chooser',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Chooser extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Displays native prompt for user to select a file.
|
||||
*
|
||||
* @param {string} [accept] Optional MIME type filter (e.g. 'image/gif,video/*').
|
||||
* @returns {Promise<any>} Promise containing selected file's
|
||||
* data: MIME type, display name, and original URI.
|
||||
*/
|
||||
@Cordova()
|
||||
getFiles(accept?: string): Promise<ChooserResult[] | undefined> {
|
||||
return;
|
||||
}
|
||||
}
|
81
src/@awesome-cordova-plugins/plugins/chooser/index.ts
Normal file
81
src/@awesome-cordova-plugins/plugins/chooser/index.ts
Normal file
@ -0,0 +1,81 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface ChooserOptions {
|
||||
mimeTypes?: string;
|
||||
maxFileSize?: number;
|
||||
}
|
||||
|
||||
export interface ChooserResult {
|
||||
path: string;
|
||||
/**
|
||||
* without extension
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* with extension
|
||||
*/
|
||||
displayName: string;
|
||||
mimeType: string;
|
||||
extension: string;
|
||||
size: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Chooser
|
||||
* @description
|
||||
* File chooser plugin for Cordova.
|
||||
*
|
||||
* The following must be added to config.xml to prevent crashing when selecting large files on Android:
|
||||
* ```xml
|
||||
* <platform name="android">
|
||||
* <edit-config
|
||||
* file="app/src/main/AndroidManifest.xml"
|
||||
* mode="merge"
|
||||
* target="/manifest/application">
|
||||
* <application android:largeHeap="true" />
|
||||
* </edit-config>
|
||||
* </platform>
|
||||
* ```
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Chooser } from '@awesome-cordova-plugins/chooser/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private chooser: Chooser) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.chooser.getFile()
|
||||
* .then(file => console.log(file ? file.name : 'canceled'))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* ChooserResult
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Chooser',
|
||||
plugin: 'cordova-plugin-chooser',
|
||||
pluginRef: 'chooser',
|
||||
repo: 'https://github.com/MaximBelov/cordova-plugin-chooser',
|
||||
platforms: ['Android', 'iOS'],
|
||||
install: 'ionic cordova plugin add http://github.com/MaximBelov/cordova-plugin-chooser.git',
|
||||
})
|
||||
@Injectable()
|
||||
export class Chooser extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Displays native prompt for user to select a file.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @param {string} options.mimeTypes Optional MIME type filter (e.g. 'image/gif,video/*').
|
||||
* @param {string} options.maxFileSize Optional Max file size.
|
||||
* @returns {Promise<any>} Promise containing selected file's
|
||||
* data: MIME type, display name, and original URI.
|
||||
*/
|
||||
@Cordova()
|
||||
getFile(options?: ChooserOptions): Promise<ChooserResult | undefined> {
|
||||
return;
|
||||
}
|
||||
}
|
1048
src/@awesome-cordova-plugins/plugins/clevertap/index.ts
Normal file
1048
src/@awesome-cordova-plugins/plugins/clevertap/index.ts
Normal file
File diff suppressed because it is too large
Load Diff
70
src/@awesome-cordova-plugins/plugins/clipboard/index.ts
Normal file
70
src/@awesome-cordova-plugins/plugins/clipboard/index.ts
Normal file
@ -0,0 +1,70 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
/**
|
||||
* @name Clipboard
|
||||
* @premier clipboard
|
||||
* @description
|
||||
* Clipboard management plugin for Cordova that supports iOS, Android, and Windows Phone 8.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Clipboard } from '@awesome-cordova-plugins/clipboard/ngx';
|
||||
*
|
||||
* constructor(private clipboard: Clipboard) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.clipboard.copy('Hello world');
|
||||
*
|
||||
* this.clipboard.paste().then(
|
||||
* (resolve: string) => {
|
||||
* alert(resolve);
|
||||
* },
|
||||
* (reject: string) => {
|
||||
* alert('Error: ' + reject);
|
||||
* }
|
||||
* );
|
||||
*
|
||||
* this.clipboard.clear();
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Clipboard',
|
||||
plugin: 'cordova-clipboard',
|
||||
pluginRef: 'cordova.plugins.clipboard',
|
||||
repo: 'https://github.com/ihadeed/cordova-clipboard',
|
||||
platforms: ['Android', 'iOS', 'Windows Phone 8'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Clipboard extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Copies the given text
|
||||
*
|
||||
* @param {string} text Text that gets copied on the system clipboard
|
||||
* @returns {Promise<any>} Returns a promise after the text has been copied
|
||||
*/
|
||||
@Cordova()
|
||||
copy(text: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pastes the text stored in clipboard
|
||||
*
|
||||
* @returns {Promise<any>} Returns a promise after the text has been pasted
|
||||
*/
|
||||
@Cordova()
|
||||
paste(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the text stored in clipboard
|
||||
*
|
||||
* @returns {Promise<any>} Returns a promise after the text has been cleaned
|
||||
*/
|
||||
@Cordova()
|
||||
clear(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
94
src/@awesome-cordova-plugins/plugins/cloud-settings/index.ts
Normal file
94
src/@awesome-cordova-plugins/plugins/cloud-settings/index.ts
Normal file
@ -0,0 +1,94 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name Cloud Settings
|
||||
* @description
|
||||
* Stores app settings in cloud storage so if the user re-installs the app or installs it on a different device, the settings will be restored and available in the new installation.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { CloudSettings } from '@awesome-cordova-plugins/cloud-settings/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private cloudSettings: CloudSettings) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.cloudSettings.exists()
|
||||
* .then((exists: boolean) => console.log("Saved settings exist: " + exists) )
|
||||
*
|
||||
* this.cloudSettings.load()
|
||||
* .then((settings: any) => this.settings = settings)
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* this.cloudSettings.save(this.settings)
|
||||
* .then((savedSettings: any) => console.log("Saved settings: " + JSON.stringify(savedSettings)))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'CloudSettings',
|
||||
plugin: 'cordova-plugin-cloud-settings',
|
||||
pluginRef: 'cordova.plugin.cloudsettings',
|
||||
repo: 'https://github.com/dpa99c/cordova-plugin-cloud-settings',
|
||||
install: 'ionic cordova plugin add cordova-plugin-cloud-settings --variable ANDROID_BACKUP_SERVICE_KEY=myapikey',
|
||||
installVariables: ['ANDROID_BACKUP_SERVICE_KEY'],
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class CloudSettings extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Indicates if any stored cloud settings currently exist for the current user.
|
||||
*
|
||||
* @returns {Promise<boolean>} Will be passed a boolean flag which indicates whether an store settings exist for the user.
|
||||
*/
|
||||
@Cordova()
|
||||
exists(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the settings to cloud backup.
|
||||
*
|
||||
* @param {object} settings - a JSON structure representing the user settings to save to cloud backup.
|
||||
* @param {boolean} [overwrite] - (optional) if true, existing settings will be replaced rather than updated. Defaults to false.
|
||||
* If false, existing settings will be merged with the new settings passed to this function.
|
||||
* @returns {Promise<any>} Will be passed a single object argument which contains the saved settings as a JSON object.
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
save(settings: any, overwrite?: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the current settings.
|
||||
*
|
||||
* @returns {Promise<any>} Will be passed a single object argument which contains the saved settings as a JSON object.
|
||||
*/
|
||||
@Cordova()
|
||||
load(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a function which will be called if/when settings on the device have been updated from the cloud.
|
||||
*
|
||||
* @param {Function} handler - callback function to invoke when device settings have been updated from the cloud.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
onRestore(handler: Function): void {}
|
||||
|
||||
/**
|
||||
* Outputs verbose log messages from the native plugin components to the JS console.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
enableDebug(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
553
src/@awesome-cordova-plugins/plugins/code-push/index.ts
Normal file
553
src/@awesome-cordova-plugins/plugins/code-push/index.ts
Normal file
@ -0,0 +1,553 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
namespace Http {
|
||||
export const enum Verb {
|
||||
GET,
|
||||
HEAD,
|
||||
POST,
|
||||
PUT,
|
||||
DELETE,
|
||||
TRACE,
|
||||
OPTIONS,
|
||||
CONNECT,
|
||||
PATCH,
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
statusCode: number;
|
||||
body?: string;
|
||||
}
|
||||
|
||||
export interface Requester {
|
||||
request(verb: Verb, url: string, callback: Callback<Response>): void;
|
||||
request(verb: Verb, url: string, requestBody: string, callback: Callback<Response>): void;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a package. All fields are non-nullable, except when retrieving the currently running package on the first run of the app,
|
||||
* in which case only the appVersion is compulsory.
|
||||
*
|
||||
* !! THIS TYPE IS READ FROM NATIVE CODE AS WELL. ANY CHANGES TO THIS INTERFACE NEEDS TO BE UPDATED IN NATIVE CODE !!
|
||||
*/
|
||||
export interface IPackage {
|
||||
deploymentKey: string;
|
||||
description: string;
|
||||
label: string;
|
||||
appVersion: string;
|
||||
isMandatory: boolean;
|
||||
packageHash: string;
|
||||
packageSize: number;
|
||||
failedInstall: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a remote package, which represents an update package available for download.
|
||||
*/
|
||||
export interface IRemotePackage extends IPackage {
|
||||
/**
|
||||
* The URL at which the package is available for download.
|
||||
*/
|
||||
downloadUrl: string;
|
||||
|
||||
/**
|
||||
* Downloads the package update from the CodePush service.
|
||||
*
|
||||
* @param {SuccessCallback} downloadSuccess Called with one parameter, the downloaded package information, once the download completed successfully.
|
||||
* @param {ErrorCallback} [downloadError] Optional callback invoked in case of an error.
|
||||
* @param {SuccessCallback<DownloadProgress>} [downloadProgress] Optional callback invoked during the download process. It is called several times with one DownloadProgress parameter.
|
||||
*/
|
||||
download(
|
||||
downloadSuccess: SuccessCallback<ILocalPackage>,
|
||||
downloadError?: ErrorCallback,
|
||||
downloadProgress?: SuccessCallback<DownloadProgress>
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Aborts the current download session, previously started with download().
|
||||
*
|
||||
* @param {SuccessCallback<void>} [abortSuccess] Optional callback invoked if the abort operation succeeded.
|
||||
* @param {ErrorCallback} [abortError] Optional callback invoked in case of an error.
|
||||
*/
|
||||
abortDownload(abortSuccess?: SuccessCallback<void>, abortError?: ErrorCallback): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a local package.
|
||||
*
|
||||
* !! THIS TYPE IS READ FROM NATIVE CODE AS WELL. ANY CHANGES TO THIS INTERFACE NEEDS TO BE UPDATED IN NATIVE CODE !!
|
||||
*/
|
||||
export interface ILocalPackage extends IPackage {
|
||||
/**
|
||||
* The local storage path where this package is located.
|
||||
*/
|
||||
localPath: string;
|
||||
|
||||
/**
|
||||
* Indicates if the current application run is the first one after the package was applied.
|
||||
*/
|
||||
isFirstRun: boolean;
|
||||
|
||||
/**
|
||||
* Applies this package to the application. The application will be reloaded with this package and on every application launch this package will be loaded.
|
||||
* On the first run after the update, the application will wait for a codePush.notifyApplicationReady() call. Once this call is made, the install operation is considered a success.
|
||||
* Otherwise, the install operation will be marked as failed, and the application is reverted to its previous version on the next run.
|
||||
*
|
||||
* @param {SuccessCallback<InstallMode>} installSuccess Callback invoked if the install operation succeeded.
|
||||
* @param {ErrorCallback} [installError] Optional callback invoked in case of an error.
|
||||
* @param {InstallOptions} [installOptions] Optional parameter used for customizing the installation behavior.
|
||||
*/
|
||||
install(
|
||||
installSuccess: SuccessCallback<InstallMode>,
|
||||
errorCallback?: ErrorCallback,
|
||||
installOptions?: InstallOptions
|
||||
): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decomposed static side of RemotePackage.
|
||||
* For Class Decomposition guidelines see http://www.typescriptlang.org/Handbook#writing-dts-files-guidelines-and-specifics
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
interface RemotePackage_Static {
|
||||
new (): IRemotePackage;
|
||||
}
|
||||
|
||||
/* tslint:enable */
|
||||
|
||||
/**
|
||||
* Decomposed static side of LocalPackage.
|
||||
* For Class Decomposition guidelines see http://www.typescriptlang.org/Handbook#writing-dts-files-guidelines-and-specifics
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
interface LocalPackage_Static {
|
||||
new (): ILocalPackage;
|
||||
}
|
||||
|
||||
/* tslint:enable */
|
||||
|
||||
declare const RemotePackage: RemotePackage_Static;
|
||||
declare const LocalPackage: LocalPackage_Static;
|
||||
|
||||
/**
|
||||
* Defines the JSON format of the current package information file.
|
||||
* This file is stored in the local storage of the device and persists between store updates and code-push updates.
|
||||
*
|
||||
* !! THIS FILE IS READ FROM NATIVE CODE AS WELL. ANY CHANGES TO THIS INTERFACE NEEDS TO BE UPDATED IN NATIVE CODE !!
|
||||
*/
|
||||
interface IPackageInfoMetadata extends ILocalPackage {
|
||||
nativeBuildTime: string;
|
||||
}
|
||||
|
||||
interface NativeUpdateNotification {
|
||||
updateAppVersion: boolean; // Always true
|
||||
appVersion: string;
|
||||
}
|
||||
|
||||
export type Callback<T> = (error: Error, parameter: T) => void;
|
||||
export type SuccessCallback<T> = (result?: T) => void;
|
||||
export type ErrorCallback = (error?: Error) => void;
|
||||
|
||||
interface Configuration {
|
||||
appVersion: string;
|
||||
clientUniqueId: string;
|
||||
deploymentKey: string;
|
||||
serverUrl: string;
|
||||
ignoreAppVersion?: boolean;
|
||||
}
|
||||
|
||||
declare class AcquisitionStatus {
|
||||
static DeploymentSucceeded: string;
|
||||
static DeploymentFailed: string;
|
||||
}
|
||||
|
||||
declare class AcquisitionManager {
|
||||
constructor(httpRequester: Http.Requester, configuration: Configuration);
|
||||
queryUpdateWithCurrentPackage(
|
||||
currentPackage: IPackage,
|
||||
callback?: Callback<IRemotePackage | NativeUpdateNotification>
|
||||
): void;
|
||||
reportStatusDeploy(
|
||||
pkg?: IPackage,
|
||||
status?: string,
|
||||
previousLabelOrAppVersion?: string,
|
||||
previousDeploymentKey?: string,
|
||||
callback?: Callback<void>
|
||||
): void;
|
||||
reportStatusDownload(pkg: IPackage, callback?: Callback<void>): void;
|
||||
}
|
||||
|
||||
interface CodePushCordovaPlugin {
|
||||
/**
|
||||
* Get the current package information.
|
||||
*
|
||||
* @param packageSuccess Callback invoked with the currently deployed package information.
|
||||
* @param packageError Optional callback invoked in case of an error.
|
||||
*/
|
||||
getCurrentPackage(packageSuccess: SuccessCallback<ILocalPackage>, packageError?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Gets the pending package information, if any. A pending package is one that has been installed but the application still runs the old code.
|
||||
* This happens only after a package has been installed using ON_NEXT_RESTART or ON_NEXT_RESUME mode, but the application was not restarted/resumed yet.
|
||||
*/
|
||||
getPendingPackage(packageSuccess: SuccessCallback<ILocalPackage>, packageError?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Checks with the CodePush server if an update package is available for download.
|
||||
*
|
||||
* @param {SuccessCallback<IRemotePackage>} querySuccess Callback invoked in case of a successful response from the server.
|
||||
* The callback takes one RemotePackage parameter. A non-null package is a valid update.
|
||||
* A null package means the application is up to date for the current native application version.
|
||||
* @param {ErrorCallback} [queryError] Optional callback invoked in case of an error.
|
||||
* @param {string} [deploymentKey] Optional deployment key that overrides the config.xml setting.
|
||||
*/
|
||||
checkForUpdate(
|
||||
querySuccess: SuccessCallback<IRemotePackage>,
|
||||
queryError?: ErrorCallback,
|
||||
deploymentKey?: string
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Notifies the plugin that the update operation succeeded and that the application is ready.
|
||||
* Calling this function is required on the first run after an update. On every subsequent application run, calling this function is a noop.
|
||||
* If using sync API, calling this function is not required since sync calls it internally.
|
||||
*
|
||||
* @param {SuccessCallback<void>} [notifySucceeded] Optional callback invoked if the plugin was successfully notified.
|
||||
* @param {ErrorCallback} [notifyFailed] Optional callback invoked in case of an error during notifying the plugin.
|
||||
*/
|
||||
notifyApplicationReady(notifySucceeded?: SuccessCallback<void>, notifyFailed?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Reloads the application. If there is a pending update package installed using ON_NEXT_RESTART or ON_NEXT_RESUME modes, the update
|
||||
* will be immediately visible to the user. Otherwise, calling this function will simply reload the current version of the application.
|
||||
*
|
||||
* @param {SuccessCallback<void>} installSuccess
|
||||
* @param {ErrorCallback} [errorCallback]
|
||||
*/
|
||||
restartApplication(installSuccess: SuccessCallback<void>, errorCallback?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Convenience method for installing updates in one method call.
|
||||
* This method is provided for simplicity, and its behavior can be replicated by using window.codePush.checkForUpdate(), RemotePackage's download() and LocalPackage's install() methods.
|
||||
*
|
||||
* The algorithm of this method is the following:
|
||||
* - Checks for an update on the CodePush server.
|
||||
* - If an update is available
|
||||
* - If the update is mandatory and the alertMessage is set in options, the user will be informed that the application will be updated to the latest version.
|
||||
* The update package will then be downloaded and applied.
|
||||
* - If the update is not mandatory and the confirmMessage is set in options, the user will be asked if they want to update to the latest version.
|
||||
* If they decline, the syncCallback will be invoked with SyncStatus.UPDATE_IGNORED.
|
||||
* - Otherwise, the update package will be downloaded and applied with no user interaction.
|
||||
* - If no update is available on the server, or if a previously rolled back update is available and the ignoreFailedUpdates is set to true, the syncCallback will be invoked with the SyncStatus.UP_TO_DATE.
|
||||
* - If an error occurs during checking for update, downloading or installing it, the syncCallback will be invoked with the SyncStatus.ERROR.
|
||||
*
|
||||
* @param {SuccessCallback<SyncStatus>} [syncCallback] Optional callback to be called with the status of the sync operation.
|
||||
* The callback will be called only once, and the possible statuses are defined by the SyncStatus enum.
|
||||
* @param {SyncOptions} [syncOptions] Optional SyncOptions parameter configuring the behavior of the sync operation.
|
||||
* @param {SuccessCallback<DownloadProgress>} [downloadProgress] Optional callback invoked during the download process. It is called several times with one DownloadProgress parameter.
|
||||
*/
|
||||
sync(
|
||||
syncCallback?: SuccessCallback<SyncStatus>,
|
||||
syncOptions?: SyncOptions,
|
||||
downloadProgress?: SuccessCallback<DownloadProgress>
|
||||
): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the possible result statuses of the window.codePush.sync operation.
|
||||
*/
|
||||
export enum SyncStatus {
|
||||
/**
|
||||
* The application is up to date.
|
||||
*/
|
||||
UP_TO_DATE,
|
||||
|
||||
/**
|
||||
* An update is available, it has been downloaded, unzipped and copied to the deployment folder.
|
||||
* After the completion of the callback invoked with SyncStatus.UPDATE_INSTALLED, the application will be reloaded with the updated code and resources.
|
||||
*/
|
||||
UPDATE_INSTALLED,
|
||||
|
||||
/**
|
||||
* An optional update is available, but the user declined to install it. The update was not downloaded.
|
||||
*/
|
||||
UPDATE_IGNORED,
|
||||
|
||||
/**
|
||||
* An error happened during the sync operation. This might be an error while communicating with the server, downloading or unziping the update.
|
||||
* The console logs should contain more information about what happened. No update has been applied in this case.
|
||||
*/
|
||||
ERROR,
|
||||
|
||||
/**
|
||||
* There is an ongoing sync in progress, so this attempt to sync has been aborted.
|
||||
*/
|
||||
IN_PROGRESS,
|
||||
|
||||
/**
|
||||
* Intermediate status - the plugin is about to check for updates.
|
||||
*/
|
||||
CHECKING_FOR_UPDATE,
|
||||
|
||||
/**
|
||||
* Intermediate status - a user dialog is about to be displayed. This status will be reported only if user interaction is enabled.
|
||||
*/
|
||||
AWAITING_USER_ACTION,
|
||||
|
||||
/**
|
||||
* Intermediate status - the update package is about to be downloaded.
|
||||
*/
|
||||
DOWNLOADING_PACKAGE,
|
||||
|
||||
/**
|
||||
* Intermediate status - the update package is about to be installed.
|
||||
*/
|
||||
INSTALLING_UPDATE,
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the available install modes for updates.
|
||||
*/
|
||||
export enum InstallMode {
|
||||
/**
|
||||
* The update will be applied to the running application immediately. The application will be reloaded with the new content immediately.
|
||||
*/
|
||||
IMMEDIATE,
|
||||
|
||||
/**
|
||||
* The update is downloaded but not installed immediately. The new content will be available the next time the application is started.
|
||||
*/
|
||||
ON_NEXT_RESTART,
|
||||
|
||||
/**
|
||||
* The udpate is downloaded but not installed immediately. The new content will be available the next time the application is resumed or restarted, whichever event happends first.
|
||||
*/
|
||||
ON_NEXT_RESUME,
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the install operation options.
|
||||
*/
|
||||
export interface InstallOptions {
|
||||
/**
|
||||
* Used to specify the InstallMode used for the install operation. This is optional and defaults to InstallMode.ON_NEXT_RESTART.
|
||||
*/
|
||||
installMode?: InstallMode;
|
||||
|
||||
/**
|
||||
* If installMode === ON_NEXT_RESUME, the minimum amount of time (in seconds) which needs to pass with the app in the background before an update install occurs when the app is resumed.
|
||||
*/
|
||||
minimumBackgroundDuration?: number;
|
||||
|
||||
/**
|
||||
* Used to specify the InstallMode used for the install operation if the update is mandatory. This is optional and defaults to InstallMode.IMMEDIATE.
|
||||
*/
|
||||
mandatoryInstallMode?: InstallMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the sync operation options.
|
||||
*/
|
||||
export interface SyncOptions extends InstallOptions {
|
||||
/**
|
||||
* Optional boolean flag. If set, previous updates which were rolled back will be ignored. Defaults to true.
|
||||
*/
|
||||
ignoreFailedUpdates?: boolean;
|
||||
|
||||
/**
|
||||
* Used to enable, disable or customize the user interaction during sync.
|
||||
* If set to false, user interaction will be disabled. If set to true, the user will be alerted or asked to confirm new updates, based on whether the update is mandatory.
|
||||
* To customize the user dialog, this option can be set to a custom UpdateDialogOptions instance.
|
||||
*/
|
||||
updateDialog?: boolean | UpdateDialogOptions;
|
||||
|
||||
/**
|
||||
* Overrides the config.xml deployment key when checking for updates.
|
||||
*/
|
||||
deploymentKey?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the configuration options for the alert or confirmation dialog
|
||||
*/
|
||||
export interface UpdateDialogOptions {
|
||||
/**
|
||||
* If a mandatory update is available and this option is set, the message will be displayed to the user in an alert dialog before downloading and installing the update.
|
||||
* The user will not be able to cancel the operation, since the update is mandatory.
|
||||
*/
|
||||
mandatoryUpdateMessage?: string;
|
||||
|
||||
/**
|
||||
* If an optional update is available and this option is set, the message will be displayed to the user in a confirmation dialog.
|
||||
* If the user confirms the update, it will be downloaded and installed. Otherwise, the update update is not downloaded.
|
||||
*/
|
||||
optionalUpdateMessage?: string;
|
||||
|
||||
/**
|
||||
* The title of the dialog box used for interacting with the user in case of a mandatory or optional update.
|
||||
* This title will only be used if at least one of mandatoryUpdateMessage or optionalUpdateMessage options are set.
|
||||
*/
|
||||
updateTitle?: string;
|
||||
|
||||
/**
|
||||
* The label of the confirmation button in case of an optional update.
|
||||
*/
|
||||
optionalInstallButtonLabel?: string;
|
||||
|
||||
/**
|
||||
* The label of the cancel button in case of an optional update.
|
||||
*/
|
||||
optionalIgnoreButtonLabel?: string;
|
||||
|
||||
/**
|
||||
* The label of the continue button in case of a mandatory update.
|
||||
*/
|
||||
mandatoryContinueButtonLabel?: string;
|
||||
|
||||
/**
|
||||
* Flag indicating if the update description provided by the CodePush server should be displayed in the dialog box appended to the update message.
|
||||
*/
|
||||
appendReleaseDescription?: boolean;
|
||||
|
||||
/**
|
||||
* Optional prefix to add to the release description.
|
||||
*/
|
||||
descriptionPrefix?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the JSON format of the package diff manifest file.
|
||||
*/
|
||||
interface IDiffManifest {
|
||||
deletedFiles: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the format of the DownloadProgress object, used to send periodical update notifications on the progress of the update download.
|
||||
*/
|
||||
export interface DownloadProgress {
|
||||
totalBytes: number;
|
||||
receivedBytes: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Code Push
|
||||
* @description
|
||||
* CodePush plugin for Cordova by Microsoft that supports iOS and Android.
|
||||
*
|
||||
* For more info, please see https://github.com/Dellos7/example-cordova-code-push-plugin
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { CodePush } from '@awesome-cordova-plugins/code-push/ngx';
|
||||
*
|
||||
* constructor(private codePush: CodePush) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // note - mostly error & completed methods of observable will not fire
|
||||
* // as syncStatus will contain the current state of the update
|
||||
* this.codePush.sync().subscribe((syncStatus) => console.log(syncStatus));
|
||||
*
|
||||
* const downloadProgress = (progress) => { console.log(`Downloaded ${progress.receivedBytes} of ${progress.totalBytes}`); }
|
||||
* this.codePush.sync({}, downloadProgress).subscribe((syncStatus) => console.log(syncStatus));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'CodePush',
|
||||
plugin: 'cordova-plugin-code-push',
|
||||
pluginRef: 'codePush',
|
||||
repo: 'https://github.com/Microsoft/cordova-plugin-code-push',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class CodePush extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Get the current package information.
|
||||
*
|
||||
* @returns {Promise<ILocalPackage>}
|
||||
*/
|
||||
@Cordova()
|
||||
getCurrentPackage(): Promise<ILocalPackage> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pending package information, if any. A pending package is one that has been installed but the application still runs the old code.
|
||||
* This happens only after a package has been installed using ON_NEXT_RESTART or ON_NEXT_RESUME mode, but the application was not restarted/resumed yet.
|
||||
*
|
||||
* @returns {Promise<ILocalPackage>}
|
||||
*/
|
||||
@Cordova()
|
||||
getPendingPackage(): Promise<ILocalPackage> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks with the CodePush server if an update package is available for download.
|
||||
*
|
||||
* @param {string} [deploymentKey] Optional deployment key that overrides the config.xml setting.
|
||||
* @returns {Promise<IRemotePackage>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
checkForUpdate(deploymentKey?: string): Promise<IRemotePackage> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the plugin that the update operation succeeded and that the application is ready.
|
||||
* Calling this function is required on the first run after an update. On every subsequent application run, calling this function is a noop.
|
||||
* If using sync API, calling this function is not required since sync calls it internally.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
notifyApplicationReady(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the application. If there is a pending update package installed using ON_NEXT_RESTART or ON_NEXT_RESUME modes, the update
|
||||
* will be immediately visible to the user. Otherwise, calling this function will simply reload the current version of the application.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
restartApplication(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for installing updates in one method call.
|
||||
* This method is provided for simplicity, and its behavior can be replicated by using window.codePush.checkForUpdate(), RemotePackage's download() and LocalPackage's install() methods.
|
||||
*
|
||||
* The algorithm of this method is the following:
|
||||
* - Checks for an update on the CodePush server.
|
||||
* - If an update is available
|
||||
* - If the update is mandatory and the alertMessage is set in options, the user will be informed that the application will be updated to the latest version.
|
||||
* The update package will then be downloaded and applied.
|
||||
* - If the update is not mandatory and the confirmMessage is set in options, the user will be asked if they want to update to the latest version.
|
||||
* If they decline, the syncCallback will be invoked with SyncStatus.UPDATE_IGNORED.
|
||||
* - Otherwise, the update package will be downloaded and applied with no user interaction.
|
||||
* - If no update is available on the server, or if a previously rolled back update is available and the ignoreFailedUpdates is set to true, the syncCallback will be invoked with the SyncStatus.UP_TO_DATE.
|
||||
* - If an error occurs during checking for update, downloading or installing it, the syncCallback will be invoked with the SyncStatus.ERROR.
|
||||
*
|
||||
* @param {SyncOptions} [syncOptions] Optional SyncOptions parameter configuring the behavior of the sync operation.
|
||||
* @param {SuccessCallback<DownloadProgress>} [downloadProgress] Optional callback invoked during the download process. It is called several times with one DownloadProgress parameter.
|
||||
* @returns {Observable<SyncStatus>}
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
successIndex: 0,
|
||||
errorIndex: 3, // we don't need this, so we set it to a value higher than # of args
|
||||
})
|
||||
sync(syncOptions?: SyncOptions, downloadProgress?: SuccessCallback<DownloadProgress>): Observable<SyncStatus> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface CropOption {
|
||||
/** The resulting JPEG quality (ignored on Android). default: 100 */
|
||||
quality?: number;
|
||||
|
||||
/** The resulting JPEG picture width. default: -1 */
|
||||
targetWidth?: number;
|
||||
|
||||
/** The resulting JPEG picture height. default: -1 */
|
||||
targetHeight?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Crop Plugin Privacy
|
||||
* @description
|
||||
* This plugin does something
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { CropPluginPrivacy } from '@awesome-cordova-plugins/crop-plugin-privacy/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private cropPluginPrivacy: CropPluginPrivacy) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.cropPluginPrivacy.functionName('/path/to/image', { quality: 100, targetWidth: 1, targetHeight: 1 })
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'CropPluginPrivacy',
|
||||
plugin: 'cordova-plugin-crop-privacy',
|
||||
pluginRef: 'crop',
|
||||
repo: 'https://github.com/BaraAksayeth25/cordova-plugin-crop-privacy',
|
||||
platforms: ['Android']
|
||||
})
|
||||
@Injectable()
|
||||
export class CropPluginPrivacy extends AwesomeCordovaNativePlugin {
|
||||
|
||||
/**
|
||||
* This function does something
|
||||
* @param arg1 {string} path destination
|
||||
* @param arg2 {object} Cropping configuration
|
||||
* @return {Promise<any>} return the file path
|
||||
*/
|
||||
@Cordova()
|
||||
cropImage(arg1: string, arg2: CropOption): Promise<any> {
|
||||
return; // We add return; here to avoid any IDE / Compiler errors
|
||||
}
|
||||
|
||||
}
|
315
src/@awesome-cordova-plugins/plugins/custom-uisdk/index.ts
Executable file
315
src/@awesome-cordova-plugins/plugins/custom-uisdk/index.ts
Executable file
@ -0,0 +1,315 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
Plugin,
|
||||
Cordova,
|
||||
CordovaProperty,
|
||||
CordovaInstance,
|
||||
InstanceProperty,
|
||||
AwesomeCordovaNativePlugin,
|
||||
} from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name CustomUISDK
|
||||
* @description
|
||||
* This plugin is used to access Paytm's native CustomUISDK framework's apis.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { CustomUISDK } from '@awesome-cordova-plugins/custom-uisdk/ngx';
|
||||
*
|
||||
* constructor(private customuisdk: CustomUISDK) { }
|
||||
*
|
||||
* ...
|
||||
* this.customuisdk.functionName('Hello', 123)
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'cordova-paytm-customuisdk',
|
||||
plugin: 'cordova-paytm-customuisdk',
|
||||
pluginRef: 'paytm.customuisdk',
|
||||
repo: 'https://github.com/paytm/paytm-customuisdk-cordova',
|
||||
install: '',
|
||||
installVariables: [],
|
||||
platforms: ['Android, iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class CustomUISDK extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* This function show dialog to ask user permision to fetch authcode
|
||||
*
|
||||
* @param clientId {string} unique id give to each merchant
|
||||
* @param mid {string} merchant id
|
||||
* @returns {Promise<string>} Returns authcode
|
||||
*/
|
||||
@Cordova()
|
||||
fetchAuthCode(clientId: string, mid: string): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function check that paytm app is installed or not
|
||||
*
|
||||
* @returns {Promise<boolean>} Returns installed - true or not -false
|
||||
*/
|
||||
@Cordova()
|
||||
isPaytmAppInstalled(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mid {string} merchant id
|
||||
* @returns {Promise<boolean>} Returns if has payment methods - true or not -false
|
||||
*/
|
||||
@Cordova()
|
||||
checkHasInstrument(mid: string): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mid {string} merchant id
|
||||
* @param orderId {string} order id
|
||||
* @param txnToken {string} transaction token
|
||||
* @param amount {string} transaction amount
|
||||
* @param isStaging {boolean} staging or production
|
||||
* @param callbackUrl {string} callback url only required for custom url page
|
||||
*/
|
||||
@Cordova()
|
||||
initPaytmSDK(
|
||||
mid: string,
|
||||
orderId: string,
|
||||
txnToken: string,
|
||||
amount: string,
|
||||
isStaging: boolean,
|
||||
callbackUrl: string
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param paymentFlow {string} payment type NONE, ADDANDPAY
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
goForWalletTransaction(paymentFlow: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
appInvoke(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cardNumber {string} card number
|
||||
* @param cardExpiry {string} card expiry
|
||||
* @param cardCvv {string} card cvv
|
||||
* @param cardType {string} card type debit or credit
|
||||
* @param paymentFlow {string} payment type NONE, ADDANDPAY
|
||||
* @param channelCode {string} bank channel code
|
||||
* @param issuingBankCode {string} issuing bank code
|
||||
* @param emiChannelId {string} emi plan id
|
||||
* @param authMode {string} authentication mode 'otp' 'pin'
|
||||
* @param saveCard {boolean} save card for next time
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
goForNewCardTransaction(
|
||||
cardNumber: string,
|
||||
cardExpiry: string,
|
||||
cardCvv: string,
|
||||
cardType: string,
|
||||
paymentFlow: string,
|
||||
channelCode: string,
|
||||
issuingBankCode: string,
|
||||
emiChannelId: string,
|
||||
authMode: string,
|
||||
saveCard: boolean
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cardId {string} card id of saved card
|
||||
* @param cardCvv {string} card cvv
|
||||
* @param cardType {string} card type debit or credit
|
||||
* @param paymentFlow {string} payment type NONE, ADDANDPAY
|
||||
* @param channelCode {string} bank channel code
|
||||
* @param issuingBankCode {string} issuing bank code
|
||||
* @param emiChannelId {string} emi plan id
|
||||
* @param authMode {string} authentication mode 'otp' 'pin'
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
goForSavedCardTransaction(
|
||||
cardId: string,
|
||||
cardCvv: string,
|
||||
cardType: string,
|
||||
paymentFlow: string,
|
||||
channelCode: string,
|
||||
issuingBankCode: string,
|
||||
emiChannelId: string,
|
||||
authMode: string
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param netBankingCode {string} bank channel code
|
||||
* @param paymentFlow {string} payment type NONE, ADDANDPAY
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
goForNetBankingTransaction(netBankingCode: string, paymentFlow: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param upiCode {string} upi code
|
||||
* @param paymentFlow {string} payment type NONE, ADDANDPAY
|
||||
* @param saveVPA {boolean} save vpa for future transaction
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
goForUpiCollectTransaction(upiCode: string, paymentFlow: string, saveVPA: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<any>} Returns upi app list names
|
||||
*/
|
||||
@Cordova()
|
||||
getUpiIntentList(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param appName {string} upi app name
|
||||
* @param paymentFlow {string} payment type NONE, ADDANDPAY
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
goForUpiIntentTransaction(appName: string, paymentFlow: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vpaName {string} vpa name
|
||||
* @param paymentFlow {string} payment type NONE, ADDANDPAY
|
||||
* @param bankAccountJson {{}} bank account json object
|
||||
* @param merchantDetailsJson {{}} merchant detail json
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
goForUpiPushTransaction(
|
||||
paymentFlow: string,
|
||||
bankAccountJson: {},
|
||||
vpaName: string,
|
||||
merchantDetailsJson: {}
|
||||
): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vpaName {string} vpa name
|
||||
* @param bankAccountJson {{}} bank account json object
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
fetchUpiBalance(bankAccountJson: {}, vpaName: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vpaName {string} vpa name
|
||||
* @param bankAccountJson {{}} bank account json object
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
setUpiMpin(bankAccountJson: {}, vpaName: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cardSixDigit {string} card starting six digit
|
||||
* @param tokenType {string} token type ACCESS or TXN_TOKEN
|
||||
* @param token {string} token fetch from api
|
||||
* @param mid {string} merchant id
|
||||
* @param referenceId {string} reference id
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
getBin(cardSixDigit: string, tokenType: string, token: string, mid: string, referenceId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tokenType {string} token type ACCESS or TXN_TOKEN
|
||||
* @param token {string} token fetch from api
|
||||
* @param mid {string} merchant id
|
||||
* @param orderId {string} order id required only if token type is TXN_TOKEN
|
||||
* @param referenceId {string} reference id required only if token type is ACCESS
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
fetchNBList(tokenType: string, token: string, mid: string, orderId: string, referenceId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param channelCode {string} bank channel code
|
||||
* @param cardType {string} card type debit or credit
|
||||
* @returns {Promise<any>} Returns object of response
|
||||
*/
|
||||
@Cordova()
|
||||
fetchEmiDetails(channelCode: string, cardType: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<any>} Returns last successfully used net backing code
|
||||
*/
|
||||
|
||||
@Cordova()
|
||||
getLastNBSavedBank(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<any>} Returns last successfully used vpa code
|
||||
*/
|
||||
|
||||
@Cordova()
|
||||
getLastSavedVPA(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param clientId {string} unique id give to each merchant
|
||||
* @param authCode {string} fetched auth code
|
||||
* @returns {Promise<any>} Returns last successfully used vpa code
|
||||
*/
|
||||
@Cordova()
|
||||
isAuthCodeValid(clientId: string, authCode: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<any>} Returns current environment
|
||||
*/
|
||||
@Cordova()
|
||||
getEnvironment(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param environment {string} setting environment PRODUCTION or STAGING
|
||||
*/
|
||||
@Cordova()
|
||||
setEnvironment(environment: string): void {
|
||||
return;
|
||||
}
|
||||
}
|
137
src/@awesome-cordova-plugins/plugins/deeplinks/index.ts
Normal file
137
src/@awesome-cordova-plugins/plugins/deeplinks/index.ts
Normal file
@ -0,0 +1,137 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface DeeplinkMatch {
|
||||
/**
|
||||
* The route info for the matched route
|
||||
*/
|
||||
$route: any;
|
||||
|
||||
/**
|
||||
* Any arguments passed either through route parameters or GET parameters
|
||||
*/
|
||||
$args: any;
|
||||
|
||||
/**
|
||||
* The deeplink object processed from the plugin, along with any
|
||||
* any internal native data available as "extras" at the time
|
||||
* the route was matched (for example, Facebook sometimes adds extra data)
|
||||
*/
|
||||
$link: any;
|
||||
}
|
||||
|
||||
export interface DeeplinkOptions {
|
||||
/**
|
||||
* Set the matched route as root page using `navCtrl.setRoot()` method.
|
||||
*/
|
||||
root: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Deeplinks
|
||||
* @premier deeplinks
|
||||
* @description This plugin handles deeplinks on iOS and Android for both custom URL scheme links
|
||||
* and Universal App Links.
|
||||
*
|
||||
* Please read the [ionic plugin deeplinks docs](https://github.com/ionic-team/ionic-plugin-deeplinks) for iOS and Android integration.
|
||||
* You must add `universal-links` to your `config.xml` and set up Apple App Site Association (AASA) for iOS and Asset Links for Android.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Deeplinks } from '@awesome-cordova-plugins/deeplinks/ngx';
|
||||
*
|
||||
* constructor(private deeplinks: Deeplinks) { }
|
||||
*
|
||||
* this.deeplinks.route({
|
||||
* '/about-us': AboutPage,
|
||||
* '/universal-links-test': AboutPage,
|
||||
* '/products/:productId': ProductPage
|
||||
* }).subscribe(match => {
|
||||
* // match.$route - the route we matched, which is the matched entry from the arguments to route()
|
||||
* // match.$args - the args passed in the link
|
||||
* // match.$link - the full link data
|
||||
* console.log('Successfully matched route', match);
|
||||
* }, nomatch => {
|
||||
* // nomatch.$link - the full link data
|
||||
* console.error('Got a deeplink that didn\'t match', nomatch);
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* Alternatively, if you're using Ionic, there's a convenience method that takes a reference to a `NavController` and handles
|
||||
* the actual navigation for you:
|
||||
*
|
||||
* ```typescript
|
||||
* this.deeplinks.routeWithNavController(this.navController, {
|
||||
* '/about-us': AboutPage,
|
||||
* '/products/:productId': ProductPage
|
||||
* }).subscribe(match => {
|
||||
* // match.$route - the route we matched, which is the matched entry from the arguments to route()
|
||||
* // match.$args - the args passed in the link
|
||||
* // match.$link - the full link data
|
||||
* console.log('Successfully matched route', match);
|
||||
* }, nomatch => {
|
||||
* // nomatch.$link - the full link data
|
||||
* console.error('Got a deeplink that didn\'t match', nomatch);
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* See the [Ionic Deeplinks Demo](https://github.com/ionic-team/ionic2-deeplinks-demo/blob/master/app/app.ts) for an example of how to
|
||||
* retrieve the `NavController` reference at runtime.
|
||||
* @interfaces
|
||||
* DeeplinkMatch
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Deeplinks',
|
||||
plugin: 'ionic-plugin-deeplinks',
|
||||
pluginRef: 'IonicDeeplink',
|
||||
repo: 'https://github.com/ionic-team/ionic-plugin-deeplinks',
|
||||
install:
|
||||
'ionic cordova plugin add ionic-plugin-deeplinks --variable URL_SCHEME=myapp --variable DEEPLINK_SCHEME=https --variable DEEPLINK_HOST=example.com --variable ANDROID_PATH_PREFIX=/',
|
||||
installVariables: ['URL_SCHEME', 'DEEPLINK_SCHEME', 'DEEPLINK_HOST', 'ANDROID_PATH_PREFIX'],
|
||||
platforms: ['Android', 'Browser', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Deeplinks extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Define a set of paths to match against incoming deeplinks.
|
||||
*
|
||||
* @param {paths} 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 {Observable<DeeplinkMatch>} Returns an Observable that is called each time a deeplink comes through, and
|
||||
* errors if a deeplink comes through that does not match a given path.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
})
|
||||
route(paths: any): Observable<DeeplinkMatch> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This is a convenience version of `route` that takes a reference to a NavController
|
||||
* from Ionic, 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 {Nav} navController 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.
|
||||
* @param {Object} paths
|
||||
* @param {DeeplinkOptions} options
|
||||
* @returns {Observable<DeeplinkMatch>} Returns an Observable that resolves each time a deeplink comes through, and
|
||||
* errors if a deeplink comes through that does not match a given path.
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
})
|
||||
routeWithNavController(navController: any, paths: any, options?: DeeplinkOptions): Observable<DeeplinkMatch> {
|
||||
return;
|
||||
}
|
||||
}
|
105
src/@awesome-cordova-plugins/plugins/device-accounts/index.ts
Normal file
105
src/@awesome-cordova-plugins/plugins/device-accounts/index.ts
Normal file
@ -0,0 +1,105 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface AndroidAccount {
|
||||
/** Account creator */
|
||||
CREATOR: AndroidAccount;
|
||||
|
||||
/** Account name */
|
||||
name: string;
|
||||
|
||||
/** Account type */
|
||||
type: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Device Accounts
|
||||
* @description
|
||||
* Gets the Google accounts associated with the Android device
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { DeviceAccounts } from '@awesome-cordova-plugins/device-accounts/ngx';
|
||||
*
|
||||
* constructor(private deviceAccounts: DeviceAccounts) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.deviceAccounts.get()
|
||||
* .then(accounts => console.log(accounts))
|
||||
* .catch(error => console.error(error));
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* AndroidAccount
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'DeviceAccounts',
|
||||
plugin: 'cordova-device-accounts-v2',
|
||||
pluginRef: 'DeviceAccounts',
|
||||
repo: 'https://github.com/xUnholy/cordova-device-accounts-v2',
|
||||
platforms: ['Android'],
|
||||
})
|
||||
@Injectable()
|
||||
export class DeviceAccounts extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Gets all accounts registered on the Android Device
|
||||
*
|
||||
* @returns {Promise<AndroidAccount[]>}
|
||||
*/
|
||||
@Cordova()
|
||||
get(): Promise<AndroidAccount[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all accounts registered on Android device for requested type
|
||||
*
|
||||
* @param {string} type
|
||||
* @returns {Promise<AndroidAccount[]>}
|
||||
*/
|
||||
@Cordova()
|
||||
getByType(type: string): Promise<AndroidAccount[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all emails registered on Android device (accounts with 'com.google' type)
|
||||
*
|
||||
* @returns {Promise<string[]>}
|
||||
*/
|
||||
@Cordova()
|
||||
getEmails(): Promise<string[]> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first email registered on Android device
|
||||
*
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
@Cordova()
|
||||
getEmail(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get permissions for access to email registered on Android device 8.0+
|
||||
*
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
@Cordova()
|
||||
getPermissions(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get permissions for access to email registered on Android device 8.0+ for requested type
|
||||
*
|
||||
* @param {string} type
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
@Cordova()
|
||||
getPermissionsByType(type: string): Promise<string> {
|
||||
return;
|
||||
}
|
||||
}
|
108
src/@awesome-cordova-plugins/plugins/device-motion/index.ts
Normal file
108
src/@awesome-cordova-plugins/plugins/device-motion/index.ts
Normal file
@ -0,0 +1,108 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface DeviceMotionAccelerationData {
|
||||
/**
|
||||
* Amount of acceleration on the x-axis. (in m/s^2)
|
||||
*/
|
||||
x: number;
|
||||
|
||||
/**
|
||||
* Amount of acceleration on the y-axis. (in m/s^2)
|
||||
*/
|
||||
y: number;
|
||||
|
||||
/**
|
||||
* Amount of acceleration on the z-axis. (in m/s^2)
|
||||
*/
|
||||
z: number;
|
||||
|
||||
/**
|
||||
* Creation timestamp in milliseconds.
|
||||
*/
|
||||
timestamp: any;
|
||||
}
|
||||
|
||||
export interface DeviceMotionAccelerometerOptions {
|
||||
/**
|
||||
* Requested period of calls to accelerometerSuccess with acceleration data in Milliseconds. Default: 10000
|
||||
*/
|
||||
frequency?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Device Motion
|
||||
* @description
|
||||
* Requires Cordova plugin: `cordova-plugin-device-motion`. For more info, please see the [Device Motion docs](https://github.com/apache/cordova-plugin-device-motion).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { DeviceMotion, DeviceMotionAccelerationData } from '@awesome-cordova-plugins/device-motion/ngx';
|
||||
*
|
||||
* constructor(private deviceMotion: DeviceMotion) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Get the device current acceleration
|
||||
* this.deviceMotion.getCurrentAcceleration().then(
|
||||
* (acceleration: DeviceMotionAccelerationData) => console.log(acceleration),
|
||||
* (error: any) => console.log(error)
|
||||
* );
|
||||
*
|
||||
* // Watch device acceleration
|
||||
* var subscription = this.deviceMotion.watchAcceleration().subscribe((acceleration: DeviceMotionAccelerationData) => {
|
||||
* console.log(acceleration);
|
||||
* });
|
||||
*
|
||||
* // Stop watch
|
||||
* subscription.unsubscribe();
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* DeviceMotionAccelerationData
|
||||
* DeviceMotionAccelerometerOptions
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'DeviceMotion',
|
||||
plugin: 'cordova-plugin-device-motion',
|
||||
pluginRef: 'navigator.accelerometer',
|
||||
repo: 'https://github.com/apache/cordova-plugin-device-motion',
|
||||
platforms: [
|
||||
'Android',
|
||||
'BlackBerry 10',
|
||||
'Browser',
|
||||
'Firefox OS',
|
||||
'iOS',
|
||||
'Tizen',
|
||||
'Ubuntu',
|
||||
'Windows',
|
||||
'Windows Phone 8',
|
||||
],
|
||||
})
|
||||
@Injectable()
|
||||
export class DeviceMotion extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Get the current acceleration along the x, y, and z axes.
|
||||
*
|
||||
* @returns {Promise<DeviceMotionAccelerationData>} Returns object with x, y, z, and timestamp properties
|
||||
*/
|
||||
@Cordova()
|
||||
getCurrentAcceleration(): Promise<DeviceMotionAccelerationData> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Watch the device acceleration. Clear the watch by unsubscribing from the observable.
|
||||
*
|
||||
* @param {AccelerometerOptions} options list of options for the accelerometer.
|
||||
* @returns {Observable<DeviceMotionAccelerationData>} Observable returns an observable that you can subscribe to
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
observable: true,
|
||||
clearFunction: 'clearWatch',
|
||||
})
|
||||
watchAcceleration(options?: DeviceMotionAccelerometerOptions): Observable<DeviceMotionAccelerationData> {
|
||||
return;
|
||||
}
|
||||
}
|
116
src/@awesome-cordova-plugins/plugins/device-orientation/index.ts
Normal file
116
src/@awesome-cordova-plugins/plugins/device-orientation/index.ts
Normal file
@ -0,0 +1,116 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface DeviceOrientationCompassHeading {
|
||||
/**
|
||||
* The heading in degrees from 0-359.99 at a single moment in time. (Number)
|
||||
*/
|
||||
magneticHeading: number;
|
||||
|
||||
/**
|
||||
* The heading relative to the geographic North Pole in degrees 0-359.99 at a single moment in time. A negative value indicates that the true heading can't be determined. (Number)
|
||||
*/
|
||||
trueHeading: number;
|
||||
|
||||
/**
|
||||
* The deviation in degrees between the reported heading and the true heading. (Number)
|
||||
*/
|
||||
headingAccuracy: number;
|
||||
|
||||
/**
|
||||
* The time at which this heading was determined. (DOMTimeStamp)
|
||||
*/
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
export interface DeviceOrientationCompassOptions {
|
||||
/**
|
||||
* How often to retrieve the compass heading in milliseconds. (Number) (Default: 100)
|
||||
*/
|
||||
frequency?: number;
|
||||
|
||||
/**
|
||||
* The change in degrees required to initiate a watchHeading success callback. When this value is set, frequency is ignored. (Number)
|
||||
*/
|
||||
filter?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Device Orientation
|
||||
* @description
|
||||
* Requires Cordova plugin: `cordova-plugin-device-orientation`. For more info, please see the [Device Orientation docs](https://github.com/apache/cordova-plugin-device-orientation).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* // DeviceOrientationCompassHeading is an interface for compass
|
||||
* import { DeviceOrientation, DeviceOrientationCompassHeading } from '@awesome-cordova-plugins/device-orientation/ngx';
|
||||
*
|
||||
* constructor(private deviceOrientation: DeviceOrientation) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Get the device current compass heading
|
||||
* this.deviceOrientation.getCurrentHeading().then(
|
||||
* (data: DeviceOrientationCompassHeading) => console.log(data),
|
||||
* (error: any) => console.log(error)
|
||||
* );
|
||||
*
|
||||
* // Watch the device compass heading change
|
||||
* var subscription = this.deviceOrientation.watchHeading().subscribe(
|
||||
* (data: DeviceOrientationCompassHeading) => console.log(data)
|
||||
* );
|
||||
*
|
||||
* // Stop watching heading change
|
||||
* subscription.unsubscribe();
|
||||
* ```
|
||||
* @interfaces
|
||||
* DeviceOrientationCompassOptions
|
||||
* DeviceOrientationCompassHeading
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'DeviceOrientation',
|
||||
plugin: 'cordova-plugin-device-orientation',
|
||||
pluginRef: 'navigator.compass',
|
||||
repo: 'https://github.com/apache/cordova-plugin-device-orientation',
|
||||
platforms: [
|
||||
'Amazon Fire OS',
|
||||
'Android',
|
||||
'BlackBerry 10',
|
||||
'Browser',
|
||||
'Firefox OS',
|
||||
'iOS',
|
||||
'Tizen',
|
||||
'Ubuntu',
|
||||
'Windows',
|
||||
'Windows Phone',
|
||||
],
|
||||
})
|
||||
@Injectable()
|
||||
export class DeviceOrientation extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Get the current compass heading.
|
||||
*
|
||||
* @returns {Promise<DeviceOrientationCompassHeading>}
|
||||
*/
|
||||
@Cordova()
|
||||
getCurrentHeading(): Promise<DeviceOrientationCompassHeading> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the device current heading at a regular interval
|
||||
*
|
||||
* Stop the watch by unsubscribing from the observable
|
||||
*
|
||||
* @param {DeviceOrientationCompassOptions} [options] Options for compass. Frequency and Filter. Optional
|
||||
* @returns {Observable<DeviceOrientationCompassHeading>} Returns an observable that contains the compass heading
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
observable: true,
|
||||
clearFunction: 'clearWatch',
|
||||
})
|
||||
watchHeading(options?: DeviceOrientationCompassOptions): Observable<DeviceOrientationCompassHeading> {
|
||||
return;
|
||||
}
|
||||
}
|
73
src/@awesome-cordova-plugins/plugins/device/index.ts
Normal file
73
src/@awesome-cordova-plugins/plugins/device/index.ts
Normal file
@ -0,0 +1,73 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CordovaProperty, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
declare const window: any;
|
||||
|
||||
/**
|
||||
* @name Device
|
||||
* @premier device
|
||||
* @description
|
||||
* Access information about the underlying device and platform.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Device } from '@awesome-cordova-plugins/device/ngx';
|
||||
*
|
||||
* constructor(private device: Device) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* console.log('Device UUID is: ' + this.device.uuid);
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Device',
|
||||
plugin: 'cordova-plugin-device',
|
||||
pluginRef: 'device',
|
||||
repo: 'https://github.com/apache/cordova-plugin-device',
|
||||
platforms: ['Android', 'Browser', 'iOS', 'macOS', 'Windows'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Device extends AwesomeCordovaNativePlugin {
|
||||
/** Get the version of Cordova running on the device. */
|
||||
@CordovaProperty()
|
||||
cordova: string;
|
||||
|
||||
/**
|
||||
* The device.model returns the name of the device's model or product. The value is set
|
||||
* by the device manufacturer and may be different across versions of the same product.
|
||||
*/
|
||||
@CordovaProperty()
|
||||
model: string;
|
||||
|
||||
/** Get the device's operating system name. */
|
||||
@CordovaProperty()
|
||||
platform: string;
|
||||
|
||||
/** Get the device's Universally Unique Identifier (UUID). */
|
||||
@CordovaProperty()
|
||||
uuid: string;
|
||||
|
||||
/** Get the operating system version. */
|
||||
@CordovaProperty()
|
||||
version: string;
|
||||
|
||||
/** Get the device's manufacturer. */
|
||||
@CordovaProperty()
|
||||
manufacturer: string;
|
||||
|
||||
/** Whether the device is running on a simulator. */
|
||||
@CordovaProperty()
|
||||
isVirtual: boolean;
|
||||
|
||||
/** Get the device hardware serial number. */
|
||||
@CordovaProperty()
|
||||
serial: string;
|
||||
|
||||
/** Get the Android device's SDK version. (Android-only) */
|
||||
@CordovaProperty()
|
||||
sdkVersion?: string;
|
||||
|
||||
/** Detect if app is running on a macOS desktop with Apple Silicon. */
|
||||
@CordovaProperty()
|
||||
isiOSAppOnMac: string;
|
||||
}
|
66
src/@awesome-cordova-plugins/plugins/dfu-update/index.ts
Normal file
66
src/@awesome-cordova-plugins/plugins/dfu-update/index.ts
Normal file
@ -0,0 +1,66 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface UpdateOptions {
|
||||
/**
|
||||
* A string that contains the identifier for the Bluetooth LE device to update. It will either be a MAC address (on Android) or a UUID (on iOS).
|
||||
*/
|
||||
deviceId: string;
|
||||
|
||||
/**
|
||||
* A string that is the path to the file to use in the update. It can be either in either `cdvfile://` or `file://` format.
|
||||
*/
|
||||
fileUrl: string;
|
||||
|
||||
/**
|
||||
* The PacketReceiptNotificationsValue (Default to 10)
|
||||
*/
|
||||
packetReceiptNotificationsValue?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Dfu Update
|
||||
* @description
|
||||
* This plugin is a Wrapper to use Nordic Semiconductor's Device Firmware Update (DFU) service to update a Bluetooth LE device.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { DfuUpdate } from '@awesome-cordova-plugins/dfu-update/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private dfuUpdate: DfuUpdate) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.dfuUpdate.updateFirmware('fileURL', 'deviceIdentifier')
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'DfuUpdate',
|
||||
plugin: 'cordova-plugin-dfu-update',
|
||||
pluginRef: 'window.DfuUpdate',
|
||||
repo: 'https://github.com/EinfachHans/cordova-plugin-dfu-update',
|
||||
install: 'ionic cordova plugin add cordova-plugin-dfu-update --variable ANDROID_NORDIC_VERSION="1.11.0"',
|
||||
installVariables: ['ANDROID_NORDIC_VERSION'],
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class DfuUpdate extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Start the Firmware-Update-Process
|
||||
*
|
||||
* @param options - Options for the process
|
||||
* @returns {Observable<any>} Returns a Observable that emits when something happens
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
updateFirmware(options: UpdateOptions): Observable<any> {
|
||||
return;
|
||||
}
|
||||
}
|
1100
src/@awesome-cordova-plugins/plugins/diagnostic/index.ts
Normal file
1100
src/@awesome-cordova-plugins/plugins/diagnostic/index.ts
Normal file
File diff suppressed because it is too large
Load Diff
112
src/@awesome-cordova-plugins/plugins/dialogs/index.ts
Normal file
112
src/@awesome-cordova-plugins/plugins/dialogs/index.ts
Normal file
@ -0,0 +1,112 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface DialogsPromptCallback {
|
||||
/**
|
||||
* The index of the pressed button. (Number) Note that the index uses one-based indexing, so the value is 1, 2, 3, etc.
|
||||
*/
|
||||
buttonIndex: number;
|
||||
|
||||
/**
|
||||
* The text entered in the prompt dialog box. (String)
|
||||
*/
|
||||
input1: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Dialogs
|
||||
* @premier dialogs
|
||||
* @description
|
||||
* This plugin gives you ability to access and customize the device native dialogs.
|
||||
*
|
||||
* Requires Cordova plugin: `cordova-plugin-dialogs`. For more info, please see the [Dialogs plugin docs](https://github.com/apache/cordova-plugin-dialogs).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Dialogs } from '@awesome-cordova-plugins/dialogs/ngx';
|
||||
*
|
||||
* constructor(private dialogs: Dialogs) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.dialogs.alert('Hello world')
|
||||
* .then(() => console.log('Dialog dismissed'))
|
||||
* .catch(e => console.log('Error displaying dialog', e));
|
||||
*
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* DialogsPromptCallback
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Dialogs',
|
||||
plugin: 'cordova-plugin-dialogs',
|
||||
pluginRef: 'navigator.notification',
|
||||
repo: 'https://github.com/apache/cordova-plugin-dialogs',
|
||||
platforms: ['Amazon Fire OS', 'Android', 'Browser', 'iOS', 'Windows'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Dialogs extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Shows a custom alert or dialog box.
|
||||
*
|
||||
* @param {string} message Dialog message.
|
||||
* @param {string} [title] Dialog title. (Optional, defaults to Alert)
|
||||
* @param {string} [buttonName] Button name. (Optional, defaults to OK)
|
||||
* @returns {Promise<any>} Returns a blank promise once the user has dismissed the alert.
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 4,
|
||||
})
|
||||
alert(message: string, title?: string, buttonName?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a customizable confirmation dialog box.
|
||||
*
|
||||
* @param {string} message Dialog message.
|
||||
* @param {string} [title] Dialog title. (Optional, defaults to Confirm)
|
||||
* @param {string[]} [buttonLabels] Array of strings specifying button labels. (Optional, defaults to [OK,Cancel])
|
||||
* @returns {Promise<number>} Returns a promise that resolves the button index that was clicked, or 0 if the user has dismissed the dialog by clicking outside the dialog box. Note that the index use one-based indexing.
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 4,
|
||||
})
|
||||
confirm(message: string, title?: string, buttonLabels?: string[]): Promise<number> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a native dialog box that is more customizable than the browser's prompt function.
|
||||
*
|
||||
* @param {string} [message] Dialog message.
|
||||
* @param {string} [title] Dialog title. (Optional, defaults to Prompt)
|
||||
* @param {string[]} [buttonLabels] Array of strings specifying button labels. (Optional, defaults to ["OK","Cancel"])
|
||||
* @param {string} [defaultText] Default text box input value. (Optional, Default: empty string)
|
||||
* @returns {Promise<DialogsPromptCallback>} Returns a promise that resolves an object with the button index clicked and the text entered
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 5,
|
||||
})
|
||||
prompt(
|
||||
message?: string,
|
||||
title?: string,
|
||||
buttonLabels?: string[],
|
||||
defaultText?: string
|
||||
): Promise<DialogsPromptCallback> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The device plays a beep sound.
|
||||
*
|
||||
* @param {numbers} times The number of times to repeat the beep.
|
||||
*/
|
||||
@Cordova({
|
||||
sync: true,
|
||||
})
|
||||
beep(times: number): void {}
|
||||
}
|
42
src/@awesome-cordova-plugins/plugins/dns/index.ts
Normal file
42
src/@awesome-cordova-plugins/plugins/dns/index.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
/**
|
||||
* @name DNS
|
||||
* @description A plugin for Apache Cordova that enables applications to manually resolve hostnames into an underlying network address. This is mostly useful for determining whether there is a problem with the device's DNS server configuration.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { DNS } from '@awesome-cordova-plugins/dns/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private dns: DNS) { }
|
||||
*
|
||||
* ...
|
||||
* this.dns.resolve(hostname)
|
||||
* .then(
|
||||
* address => console.log('Resolved ' + hostname + ' to ' + address),
|
||||
* error => console.log('Failed to resolve ' + hostname + ': ' + error)
|
||||
* );
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'DNS',
|
||||
plugin: 'cordova-plugin-dns',
|
||||
pluginRef: 'cordova.plugins.dns',
|
||||
repo: 'https://bitbucket.org/zegeba/cordova-plugin-dns',
|
||||
platforms: ['Android'],
|
||||
})
|
||||
@Injectable()
|
||||
export class DNS extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Resolve hostnames into an underlying network address.
|
||||
*
|
||||
* @param hostname
|
||||
* @returns {Promise<string>} Returns a promise that resolves with the resolution.
|
||||
*/
|
||||
@Cordova()
|
||||
resolve(hostname: string): Promise<string> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name iOS DocumentPicker
|
||||
* @description
|
||||
*
|
||||
* Opens the file picker on iOS for the user to select a file, returns a file URI.
|
||||
* Allows the user to upload files from iCloud
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { DocumentPicker } from '@awesome-cordova-plugins/document-picker/ngx';
|
||||
*
|
||||
* constructor(private docPicker: DocumentPicker) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.docPicker.getFile('all')
|
||||
* .then(uri => console.log(uri))
|
||||
* .catch(e => console.log(e));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'IOSDocumentPicker',
|
||||
plugin: 'cordova-plugin-documentpicker.DocumentPicker',
|
||||
pluginRef: 'DocumentPicker',
|
||||
repo: 'https://github.com/iampossible/Cordova-DocPicker',
|
||||
platforms: ['iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class DocumentPicker extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Open a file
|
||||
*
|
||||
* @param {string} [option] files between 'image', 'pdf' or 'all'
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
@Cordova()
|
||||
getFile(option?: string): Promise<string> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export enum DocumentScannerSourceType {
|
||||
/**
|
||||
* Scan directly from device camera.
|
||||
* This is the default.
|
||||
*/
|
||||
CAMERA = 1,
|
||||
|
||||
/**
|
||||
* Scan from an image already stored on device.
|
||||
*/
|
||||
GALLERY = 0,
|
||||
}
|
||||
|
||||
export interface DocumentScannerOptions {
|
||||
/**
|
||||
* Choose to scan from camera or existing image file. Only valid for Android.
|
||||
*/
|
||||
sourceType?: DocumentScannerSourceType;
|
||||
|
||||
/**
|
||||
* Filename to save scanned image to (minus extension, which is always ".png").
|
||||
* Only valid for iOS. Caller is responsible for cleaning up any files created
|
||||
* if this parameter is set to anything other than the default value,
|
||||
* which is "image".
|
||||
*/
|
||||
fileName?: string;
|
||||
|
||||
/**
|
||||
* Quality to use when capturing the image, must be a float value
|
||||
* from 1.0(default - Highest quality) to 5.0(Lowest Quality). Any value
|
||||
* in between will be accepted. Any value not equal to or not between these values
|
||||
* will default to the highest quality of 1.0.
|
||||
*/
|
||||
quality?: number;
|
||||
|
||||
/**
|
||||
* If the image should be returned as a base64 encoding instead of as a file URL.
|
||||
* If true, the plugin will return the scanned image as base64. If false,
|
||||
* the plugin will return the image URL of the image.
|
||||
*/
|
||||
returnBase64?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Document Scanner
|
||||
* @description
|
||||
* This plugin processes images of documents, compensating for perspective.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { DocumentScanner, DocumentScannerOptions } from '@awesome-cordova-plugins/document-scanner/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private documentScanner: DocumentScanner) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* let opts: DocumentScannerOptions = {};
|
||||
* this.documentScanner.scanDocument(opts)
|
||||
* .then((res: string) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* DocumentScannerOptions
|
||||
* @enums
|
||||
* DocumentScannerSourceType
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'DocumentScanner',
|
||||
plugin: 'cordova-plugin-document-scanner',
|
||||
pluginRef: 'scan',
|
||||
repo: 'https://github.com/NeutrinosPlatform/cordova-plugin-document-scanner',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class DocumentScanner extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Scan a document
|
||||
*
|
||||
* @param opts {DocumentScannerOptions} optional parameter for controlling scanning
|
||||
* @returns {Promise<string>} file URL of scanned document image
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
scanDoc(opts?: DocumentScannerOptions): Promise<string> {
|
||||
return;
|
||||
}
|
||||
}
|
116
src/@awesome-cordova-plugins/plugins/document-viewer/index.ts
Normal file
116
src/@awesome-cordova-plugins/plugins/document-viewer/index.ts
Normal file
@ -0,0 +1,116 @@
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
export interface DocumentViewerOptions {
|
||||
title?: string;
|
||||
documentView?: {
|
||||
closeLabel: string;
|
||||
};
|
||||
navigationView?: {
|
||||
closeLabel: string;
|
||||
};
|
||||
email?: {
|
||||
enabled: boolean;
|
||||
};
|
||||
print?: {
|
||||
enabled: boolean;
|
||||
};
|
||||
openWith?: {
|
||||
enabled: boolean;
|
||||
};
|
||||
bookmarks?: {
|
||||
enabled: boolean;
|
||||
};
|
||||
search?: {
|
||||
enabled: boolean;
|
||||
};
|
||||
autoClose?: {
|
||||
onPause: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Document Viewer
|
||||
* @description
|
||||
* This plugin offers a slim API to view PDF files which are either stored in the apps assets folder (/www/*) or in any other file system directory available via the cordova file plugin.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { DocumentViewer } from '@awesome-cordova-plugins/document-viewer/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private document: DocumentViewer) { }
|
||||
*
|
||||
* ...
|
||||
* const options: DocumentViewerOptions = {
|
||||
* title: 'My PDF'
|
||||
* }
|
||||
*
|
||||
* this.document.viewDocument('assets/myFile.pdf', 'application/pdf', options)
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* DocumentViewerOptions
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Document Viewer',
|
||||
plugin: 'cordova-plugin-document-viewer',
|
||||
pluginRef: 'SitewaertsDocumentViewer',
|
||||
repo: 'https://github.com/sitewaerts/cordova-plugin-document-viewer',
|
||||
platforms: ['Android', 'iOS', 'Windows'],
|
||||
})
|
||||
@Injectable()
|
||||
export class DocumentViewer extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Displays the email composer pre-filled with data.
|
||||
*
|
||||
* @returns {Promise<any>} Resolves promise when the EmailComposer has been opened
|
||||
*/
|
||||
@Cordova()
|
||||
getSupportInfo(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the document can be shown
|
||||
*
|
||||
* @param url {string} Url to the file
|
||||
* @param contentType {string} Content type of the file
|
||||
* @param options {DocumentViewerOptions} options
|
||||
* @param [onPossible] {Function}
|
||||
* @param [onMissingApp] {Function}
|
||||
* @param [onImpossible] {Function}
|
||||
* @param [onError] {Function}
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
canViewDocument(
|
||||
url: string,
|
||||
contentType: string,
|
||||
options: DocumentViewerOptions,
|
||||
onPossible?: Function,
|
||||
onMissingApp?: Function,
|
||||
onImpossible?: Function,
|
||||
onError?: Function
|
||||
): void {}
|
||||
|
||||
/**
|
||||
* Opens the file
|
||||
*
|
||||
* @param url {string} Url to the file
|
||||
* @param contentType {string} Content type of the file
|
||||
* @param options {DocumentViewerOptions} options
|
||||
* @param [onShow] {Function}
|
||||
* @param [onClose] {Function}
|
||||
* @param [onMissingApp] {Function}
|
||||
* @param [onError] {Function}
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
viewDocument(
|
||||
url: string,
|
||||
contentType: string,
|
||||
options: DocumentViewerOptions,
|
||||
onShow?: Function,
|
||||
onClose?: Function,
|
||||
onMissingApp?: Function,
|
||||
onError?: Function
|
||||
): void {}
|
||||
}
|
209
src/@awesome-cordova-plugins/plugins/dynamsoft-barcode-scanner/index.ts
Executable file
209
src/@awesome-cordova-plugins/plugins/dynamsoft-barcode-scanner/index.ts
Executable file
@ -0,0 +1,209 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
Plugin,
|
||||
Cordova,
|
||||
CordovaProperty,
|
||||
CordovaInstance,
|
||||
InstanceProperty,
|
||||
AwesomeCordovaNativePlugin,
|
||||
} from '@awesome-cordova-plugins/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/**
|
||||
* dceLicense: License of Dynamsoft Camera Enhancer
|
||||
* resolution: use EnumResolution
|
||||
* rotate: convert frame to bitmap and rotate it
|
||||
*/
|
||||
export interface ScanOptions {
|
||||
dceLicense?: string;
|
||||
resolution?: number;
|
||||
rotate?: boolean;
|
||||
}
|
||||
|
||||
export interface FrameResult {
|
||||
frameWidth: number;
|
||||
frameHeight: number;
|
||||
frameRotation: number;
|
||||
results: BarcodeResult[];
|
||||
}
|
||||
|
||||
export interface BarcodeResult {
|
||||
barcodeText: string;
|
||||
barcodeFormat: string;
|
||||
barcodeBytesBase64?: string;
|
||||
x1: number;
|
||||
x2: number;
|
||||
x3: number;
|
||||
x4: number;
|
||||
y1: number;
|
||||
y2: number;
|
||||
y3: number;
|
||||
y4: number;
|
||||
}
|
||||
|
||||
export enum EnumResolution {
|
||||
RESOLUTION_AUTO = 0,
|
||||
RESOLUTION_480P = 1,
|
||||
RESOLUTION_720P = 2,
|
||||
RESOLUTION_1080P = 3,
|
||||
RESOLUTION_2K = 4,
|
||||
RESOLUTION_4K = 5,
|
||||
}
|
||||
|
||||
/**
|
||||
* @name dynamsoft-barcode-scanner
|
||||
* @description
|
||||
* This plugin scans barcodes using Dynamsoft Barcode Reader
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { dynamsoft-barcode-scanner } from '@awesome-cordova-plugins/dynamsoft-barcode-scanner';
|
||||
*
|
||||
*
|
||||
* constructor(private dynamsoft-barcode-scanner: dynamsoft-barcode-scanner) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* await this.dynamsoft-barcode-scanner.init("license");
|
||||
* this.dynamsoft-barcode-scanner.startScanning("license").subscribe(result => {
|
||||
console.log(result);
|
||||
});
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'dynamsoft-barcode-scanner',
|
||||
plugin: 'cordova-plugin-dynamsoft-barcode-reader',
|
||||
pluginRef: 'cordova.plugins.DBR',
|
||||
repo: 'https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader',
|
||||
install: '',
|
||||
installVariables: [],
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class BarcodeScanner extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Initialize Dynamsoft Barcode Reader
|
||||
* @param license {string}
|
||||
* @return {Promise<any>} Returns a promise that resolves when the initialization is done
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
init(license: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up runtime settings
|
||||
* @param settings {string} runtime settings template in JSON
|
||||
* @return {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
initRuntimeSettingsWithString(settings?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output runtime settings to JSON string
|
||||
* @return {Promise<String>} Returns a promise
|
||||
*/
|
||||
@Cordova({ successIndex: 1, errorIndex: 2 })
|
||||
outputSettingsToString(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* destroy Dynamsoft Barcode Reader
|
||||
* @return {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({ successIndex: 1, errorIndex: 2 })
|
||||
destroy(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* start the camera to scan barcodes
|
||||
* @param options {ScanOptions}
|
||||
* @return {Observable<FrameResult>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
observable: true,
|
||||
})
|
||||
startScanning(options?: ScanOptions): Observable<FrameResult> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* stop scanning
|
||||
* @return {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({ successIndex: 1, errorIndex: 2 })
|
||||
stopScanning(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* resume scanning
|
||||
* @return {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({ successIndex: 1, errorIndex: 2 })
|
||||
resumeScanning(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* pause scanning
|
||||
* @return {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({ successIndex: 1, errorIndex: 2 })
|
||||
pauseScanning(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* get resolution like: 1280x720
|
||||
* @return {Promise<string>} Returns a promise
|
||||
*/
|
||||
@Cordova({ successIndex: 1, errorIndex: 2 })
|
||||
getResolution(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* switch torch
|
||||
* @param desiredStatus {string} on or off
|
||||
* @return {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({ successIndex: 1, errorIndex: 2 })
|
||||
switchTorch(desiredStatus: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* set zoom
|
||||
* @param factor {number} zoom factor
|
||||
* @return {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({ successIndex: 1, errorIndex: 2 })
|
||||
setZoom(factor: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* set focus
|
||||
* @param point focus point
|
||||
* @return {Promise<any>} Returns a promise
|
||||
*/
|
||||
@Cordova({ successIndex: 1, errorIndex: 2 })
|
||||
setFocus(point: { x: number; y: number }): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
258
src/@awesome-cordova-plugins/plugins/email-composer/index.ts
Normal file
258
src/@awesome-cordova-plugins/plugins/email-composer/index.ts
Normal file
@ -0,0 +1,258 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, CordovaCheck, AwesomeCordovaNativePlugin, Plugin, getPromise } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface EmailComposerOptions {
|
||||
/**
|
||||
* App to send the email with
|
||||
*/
|
||||
app?: string;
|
||||
|
||||
/**
|
||||
* Email address(es) for To field
|
||||
*/
|
||||
to?: string | string[];
|
||||
|
||||
/**
|
||||
* Email address(es) for CC field
|
||||
*/
|
||||
cc?: string | string[];
|
||||
|
||||
/**
|
||||
* Email address(es) for BCC field
|
||||
*/
|
||||
bcc?: string | string[];
|
||||
|
||||
/**
|
||||
* File paths or base64 data streams
|
||||
*/
|
||||
attachments?: string[];
|
||||
|
||||
/**
|
||||
* Subject of the email
|
||||
*/
|
||||
subject?: string;
|
||||
|
||||
/**
|
||||
* Email body (for HTML, set isHtml to true)
|
||||
*/
|
||||
body?: string;
|
||||
|
||||
/**
|
||||
* Indicates if the body is HTML or plain text
|
||||
*/
|
||||
isHtml?: boolean;
|
||||
|
||||
/**
|
||||
* Content type of the email (Android only)
|
||||
*/
|
||||
type?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Email Composer
|
||||
* @premier email-composer
|
||||
* @description
|
||||
*
|
||||
* Requires Cordova plugin: cordova-plugin-email-composer. For more info, please see the [Email Composer plugin docs](https://github.com/hypery2k/cordova-email-plugin).
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { EmailComposer } from '@awesome-cordova-plugins/email-composer/ngx';
|
||||
*
|
||||
* constructor(private emailComposer: EmailComposer) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.emailComposer.getClients().then((apps: []) => {
|
||||
* // Returns an array of configured email clients for the device
|
||||
* });
|
||||
*
|
||||
* this.emailComposer.hasClient(app).then((isValid: boolean) => {
|
||||
* if (isValid) {
|
||||
* // Now we know we have a valid email client configured
|
||||
* // Not specifying an app will return true if at least one email client is configured
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* this.emailComposer.hasAccount().then((isValid: boolean) => {
|
||||
* if (isValid) {
|
||||
* // Now we know we have a valid email account configured
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* this.emailComposer.isAvailable(app).then((available: boolean) => {
|
||||
* if(available) {
|
||||
* // Now we know we can send an email, calls hasClient and hasAccount
|
||||
* // Not specifying an app will return true if at least one email client is configured
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* let email = {
|
||||
* to: 'max@mustermann.de',
|
||||
* cc: 'erika@mustermann.de',
|
||||
* bcc: ['john@doe.com', 'jane@doe.com'],
|
||||
* attachments: [
|
||||
* 'file://img/logo.png',
|
||||
* 'res://icon.png',
|
||||
* 'base64:icon.png//iVBORw0KGgoAAAANSUhEUg...',
|
||||
* 'file://README.pdf'
|
||||
* ],
|
||||
* subject: 'Cordova Icons',
|
||||
* body: 'How are you? Nice greetings from Leipzig',
|
||||
* isHtml: true
|
||||
* }
|
||||
*
|
||||
* // Send a text message using default options
|
||||
* this.emailComposer.open(email);
|
||||
* ```
|
||||
*
|
||||
* You can also assign aliases to email apps
|
||||
* ```ts
|
||||
* // add alias
|
||||
* this.email.addAlias('gmail', 'com.google.android.gm');
|
||||
*
|
||||
* // then use alias when sending email
|
||||
* this.email.open({
|
||||
* app: 'gmail',
|
||||
* ...
|
||||
* });
|
||||
* ```
|
||||
* @interfaces
|
||||
* EmailComposerOptions
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'EmailComposer',
|
||||
plugin: 'cordova-plugin-email-composer',
|
||||
pluginRef: 'cordova.plugins.email',
|
||||
repo: 'https://github.com/katzer/cordova-plugin-email-composer',
|
||||
platforms: ['Amazon Fire OS', 'Android', 'Browser', 'iOS', 'Windows', 'macOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class EmailComposer extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Checks if the app has a permission to access email accounts information
|
||||
*
|
||||
* @returns {Promise<boolean>} returns a promise that resolves with a boolean that indicates if the permission was granted
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 0,
|
||||
errorIndex: 2,
|
||||
})
|
||||
hasPermission(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request permission to access email accounts information
|
||||
*
|
||||
* @returns {Promise<boolean>} returns a promise that resolves with a boolean that indicates if the permission was granted
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 0,
|
||||
errorIndex: 2,
|
||||
})
|
||||
requestPermission(): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if an email account is configured on the device.
|
||||
*
|
||||
* @returns {Promise<any>} Resolves if available, rejects if not available
|
||||
*/
|
||||
@CordovaCheck()
|
||||
hasAccount(): Promise<any> {
|
||||
return getPromise<boolean>((resolve) => {
|
||||
EmailComposer.getPlugin().hasAccount((result: boolean) => {
|
||||
if (result) {
|
||||
resolve(true);
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if a specific email client is installed on the device.
|
||||
*
|
||||
* @param {string} [app] App id or uri scheme.
|
||||
* @returns {Promise<any>} Resolves if available, rejects if not available
|
||||
*/
|
||||
|
||||
@CordovaCheck()
|
||||
hasClient(app?: string): Promise<any> {
|
||||
return getPromise<boolean>((resolve) => {
|
||||
if (app) {
|
||||
EmailComposer.getPlugin().hasClient(app, (result: boolean) => {
|
||||
if (result) {
|
||||
resolve(true);
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
EmailComposer.getPlugin().getClients((apps: string[]) => {
|
||||
resolve(apps && apps.length > 0);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of email clients installed on the device.
|
||||
*
|
||||
* @returns {Promise<string[]>} Resolves if available, rejects if not available
|
||||
*/
|
||||
@CordovaCheck()
|
||||
@Cordova({ platforms: ['Android'] })
|
||||
getClients(): Promise<string[]> {
|
||||
return getPromise<string[]>((resolve) => {
|
||||
EmailComposer.getPlugin().getClients((apps: any) => {
|
||||
if (Object.prototype.toString.call(apps) === '[object String]') {
|
||||
apps = [apps];
|
||||
}
|
||||
resolve(apps);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if sending emails is supported on the device.
|
||||
*
|
||||
* @param {string} [app] App id or uri scheme.
|
||||
* @returns {Promise<any>} Resolves if available, rejects if not available
|
||||
*/
|
||||
@CordovaCheck()
|
||||
isAvailable(app?: string): Promise<any> {
|
||||
return getPromise<boolean>((resolve) => {
|
||||
Promise.all([this.hasAccount, this.hasClient(app)]).then((results) => {
|
||||
return resolve(results.length === 2 && results[0] && results[1]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the email composer pre-filled with data.
|
||||
*
|
||||
* @param {EmailComposerOptions} options Email
|
||||
* @param {any} [scope] Scope for the promise
|
||||
* @returns {Promise<any>} Resolves promise when the EmailComposer has been opened
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 3,
|
||||
})
|
||||
open(options: EmailComposerOptions, scope?: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new mail app alias.
|
||||
*
|
||||
* @param {string} alias The alias name
|
||||
* @param {string} packageName The package name
|
||||
*/
|
||||
@Cordova()
|
||||
addAlias(alias: string, packageName: string): void {}
|
||||
}
|
441
src/@awesome-cordova-plugins/plugins/fabric/index.ts
Normal file
441
src/@awesome-cordova-plugins/plugins/fabric/index.ts
Normal file
@ -0,0 +1,441 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface Attributes {
|
||||
[index: string]: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Crashlytics
|
||||
* @description
|
||||
* API for interacting with the Crashlytics kit.
|
||||
*
|
||||
* https://docs.fabric.io/crashlytics/index.html
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Crashlytics } from '@awesome-cordova-plugins/fabric/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private crashlytics: Crashlytics) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* try {
|
||||
* await this.loadData();
|
||||
* } catch (e) {
|
||||
* this.crashlytics.addLog("Error while loading data");
|
||||
* this.crashlytics.sendNonFatalCrash(e.message || e);
|
||||
* }
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Crashlytics',
|
||||
plugin: 'cordova-fabric-plugin',
|
||||
pluginRef: 'window.fabric.Crashlytics',
|
||||
repo: 'https://www.npmjs.com/package/cordova-fabric-plugin',
|
||||
install:
|
||||
'ionic cordova plugin add cordova-fabric-plugin --variable FABRIC_API_KEY=XXX --variable FABRIC_API_SECRET=xxx',
|
||||
installVariables: ['FABRIC_API_KEY', 'FABRIC_API_SECRET'],
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Crashlytics extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Add logging that will be sent with your crash data. This logging will not show up
|
||||
* in the system.log and will only be visible in your Crashlytics dashboard.
|
||||
*
|
||||
* @param message {string}
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
addLog(message: string): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to simulate a native platform crash (useful for testing Crashlytics logging).
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendCrash(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to log a non-fatal error message (Android only).
|
||||
*
|
||||
* @param message
|
||||
* @param stacktrace
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendNonFatalCrash(message: string, stacktrace?: any): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to record a non-fatal error message (iOS only).
|
||||
*
|
||||
* @param message
|
||||
* @param code
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
recordError(message: string, code: number): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user's identifier for logging to Crashlytics backend.
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setUserIdentifier(userId: string): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user's name for logging to Crashlytics backend.
|
||||
*
|
||||
* @param userName
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setUserName(userName: string): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user's email address for logging to Crashlytics backend.
|
||||
*
|
||||
* @param email
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setUserEmail(email: string): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a custom key/value pair for logging to Crashlytics backend.
|
||||
*
|
||||
* @param value
|
||||
* @param key
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setStringValueForKey(value: string, key: string): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a custom key/value pair for logging to Crashlytics backend.
|
||||
*
|
||||
* @param value
|
||||
* @param key
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setIntValueForKey(value: number, key: string): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a custom key/value pair for logging to Crashlytics backend.
|
||||
*
|
||||
* @param value
|
||||
* @param key
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setBoolValueForKey(value: boolean, key: string): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a custom key/value pair for logging to Crashlytics backend.
|
||||
*
|
||||
* @param value
|
||||
* @param key
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
setFloatValueForKey(value: number, key: string): void {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Answers
|
||||
* @description
|
||||
* API for interacting with the Answers kit.
|
||||
*
|
||||
* https://docs.fabric.io/crashlytics/index.html
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Answers } from '@awesome-cordova-plugins/fabric/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private answers: Answers) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.answers.sendCustomEvent('SomeCustomEvent', { some: "attributes" })
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Answers',
|
||||
plugin: 'cordova-fabric-plugin',
|
||||
pluginRef: 'window.fabric.Answers',
|
||||
repo: 'https://www.npmjs.com/package/cordova-fabric-plugin',
|
||||
install:
|
||||
'ionic cordova plugin add cordova-fabric-plugin --variable FABRIC_API_KEY=XXX --variable FABRIC_API_SECRET=xxx',
|
||||
installVariables: ['FABRIC_API_KEY', 'FABRIC_API_SECRET'],
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Answers extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Sends the Purchase tracking event.
|
||||
*
|
||||
* All parameters are optional.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#purchase
|
||||
*
|
||||
* @param itemPrice The item's amount in the currency specified.
|
||||
* @param currency The ISO4217 currency code.
|
||||
* @param success Was the purchase completed succesfully?
|
||||
* @param itemName The human-readable name for the item.
|
||||
* @param itemType The category the item falls under.
|
||||
* @param itemId A unique identifier used to track the item.
|
||||
* @param attributes Any additional user-defined attributes to be logged.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendPurchase(
|
||||
itemPrice?: number,
|
||||
currency?: string,
|
||||
success?: boolean,
|
||||
itemName?: string,
|
||||
itemType?: string,
|
||||
itemId?: string,
|
||||
attributes?: Attributes
|
||||
): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the Add To Cart tracking event.
|
||||
*
|
||||
* All parameters are optional.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#add-to-cart
|
||||
*
|
||||
* @param itemPrice The item's amount in the currency specified.
|
||||
* @param currency The ISO4217 currency code.
|
||||
* @param itemName The human-readable name for the item.
|
||||
* @param itemType The category the item falls under.
|
||||
* @param itemId A unique identifier used to track the item.
|
||||
* @param attributes Any additional user-defined attributes to be logged.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendAddToCart(
|
||||
itemPrice?: number,
|
||||
currency?: string,
|
||||
itemName?: string,
|
||||
itemType?: string,
|
||||
itemId?: string,
|
||||
attributes?: Attributes
|
||||
): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the Start Checkout tracking event.
|
||||
*
|
||||
* All parameters are optional.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#start-checkout
|
||||
*
|
||||
* @param totalPrice The total price of all items in cart in the currency specified.
|
||||
* @param currency The ISO4217 currency code.
|
||||
* @param itemCount The count of items in cart.
|
||||
* @param attributes Any additional user-defined attributes to be logged.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendStartCheckout(totalPrice?: number, currency?: string, itemCount?: number, attributes?: Attributes): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the Search tracking event.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#search
|
||||
*
|
||||
* @param query What the user is searching for.
|
||||
* @param attributes Any additional user-defined attributes to be logged.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendSearch(query: string, attributes?: Attributes): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the Share tracking event.
|
||||
*
|
||||
* All parameters are optional.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#share
|
||||
*
|
||||
* @param method The method used to share content.
|
||||
* @param contentName The description of the content.
|
||||
* @param contentType The type or genre of content.
|
||||
* @param contentId A unique key identifying the content.
|
||||
* @param attributes Any additional user-defined attributes to be logged.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendShare(
|
||||
method?: string,
|
||||
contentName?: string,
|
||||
contentType?: string,
|
||||
contentId?: string,
|
||||
attributes?: Attributes
|
||||
): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the Rated Content tracking event.
|
||||
*
|
||||
* All parameters are optional.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#rated-content
|
||||
*
|
||||
* @param rating An integer rating of the content.
|
||||
* @param contentName The human-readable name of content.
|
||||
* @param contentType The category your item falls under.
|
||||
* @param contentId A unique identifier used to track the item.
|
||||
* @param attributes Any additional user-defined attributes to be logged.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendRatedContent(
|
||||
rating?: number,
|
||||
contentName?: string,
|
||||
contentType?: string,
|
||||
contentId?: string,
|
||||
attributes?: Attributes
|
||||
): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the Sign Up tracking event.
|
||||
*
|
||||
* All parameters are optional.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#sign-up
|
||||
*
|
||||
* @param method An optional description of the sign up method (Twitter, Facebook, etc.); defaults to "Direct".
|
||||
* @param success An optional flag that indicates sign up success; defaults to true.
|
||||
* @param attributes Any additional user-defined attributes to be logged.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendSignUp(method?: string, success?: boolean, attributes?: Attributes): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the Log In tracking event.
|
||||
*
|
||||
* All parameters are optional.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#log-in
|
||||
*
|
||||
* @param method An optional description of the sign in method (Twitter, Facebook, etc.); defaults to "Direct".
|
||||
* @param success An optional flag that indicates sign in success; defaults to true.
|
||||
* @param attributes Any additional user-defined attributes to be logged.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendLogIn(method?: string, success?: boolean, attributes?: Attributes): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the Invite tracking event.
|
||||
*
|
||||
* All parameters are optional.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#invite
|
||||
*
|
||||
* @param method An optional description of the sign in method (Twitter, Facebook, etc.); defaults to "Direct".
|
||||
* @param attributes Any additional user-defined attributes to be logged.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendInvite(method?: string, attributes?: Attributes): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the Level Start tracking event.
|
||||
*
|
||||
* All parameters are optional.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#level-start
|
||||
*
|
||||
* @param levelName String key describing the level.
|
||||
* @param attributes Any additional user-defined attributes to be logged.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendLevelStart(levelName?: string, attributes?: Attributes): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the Level End tracking event.
|
||||
*
|
||||
* All parameters are optional.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#level-end
|
||||
*
|
||||
* @param levelName String key describing the level.
|
||||
* @param score The score for this level.
|
||||
* @param success Completed the level or failed trying.
|
||||
* @param attributes Any additional user-defined attributes to be logged.
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendLevelEnd(levelName?: string, score?: number, success?: boolean, attributes?: Attributes): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the Content View tracking event.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#content-view
|
||||
*
|
||||
* @param name
|
||||
* @param type
|
||||
* @param id
|
||||
* @param attributes
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendContentView(name: string, type?: string, id?: string, attributes?: Attributes): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for sendContentView(...) using type of "Screen".
|
||||
*
|
||||
* @param name
|
||||
* @param id
|
||||
* @param attributes
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendScreenView(name: string, id: string, attributes?: Attributes): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a custom tracking event with the given name.
|
||||
*
|
||||
* https://docs.fabric.io/android/answers/answers-events.html#custom-event
|
||||
*
|
||||
* @param name
|
||||
* @param attributes
|
||||
*/
|
||||
@Cordova({ sync: true })
|
||||
sendCustomEvent(name: string, attributes?: Attributes): void {
|
||||
return;
|
||||
}
|
||||
}
|
479
src/@awesome-cordova-plugins/plugins/facebook/index.ts
Normal file
479
src/@awesome-cordova-plugins/plugins/facebook/index.ts
Normal file
@ -0,0 +1,479 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface FacebookLoginResponse {
|
||||
status: string;
|
||||
|
||||
authResponse: {
|
||||
accessToken: string;
|
||||
|
||||
data_access_expiration_time: string;
|
||||
|
||||
expiresIn: number;
|
||||
|
||||
userID: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Facebook
|
||||
* @description
|
||||
* Use the Facebook Connect plugin to obtain access to the native FB application on iOS and Android.
|
||||
*
|
||||
* Requires Cordova plugin: `cordova-plugin-facebook-connect`. For more info, please see the [Facebook Connect](https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect).
|
||||
*
|
||||
* #### Installation
|
||||
*
|
||||
* To use the FB plugin, you first have to create a new Facebook App inside of the Facebook developer portal at [https://developers.facebook.com/apps](https://developers.facebook.com/apps).
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
* Retrieve the `App ID` and `App Name`.
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
* Then type in the following command in your Terminal, where APP_ID and APP_NAME are the values from the Facebook Developer portal.
|
||||
*
|
||||
* ```bash
|
||||
* ionic cordova plugin add cordova-plugin-facebook-connect --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:
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
* Click `'Add Platform'`.
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
* At this point you'll need to open your project's [`config.xml`](https://cordova.apache.org/docs/en/latest/config_ref/index.html) file, found in the root directory of your project.
|
||||
*
|
||||
* Take note of the `id` for the next step:
|
||||
* ```xml
|
||||
* <widget id="com.mycompany.testapp" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||
* ```
|
||||
*
|
||||
* You can also edit the `id` to whatever you'd like it to be.
|
||||
*
|
||||
* #### iOS Install
|
||||
* Under 'Bundle ID', add the `id` from your `config.xml` file:
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
*
|
||||
* #### Android Install
|
||||
* Under 'Google Play Package Name', add the `id` from your `config.xml` file:
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
*
|
||||
* And that's it! You can now make calls to Facebook using the plugin.
|
||||
*
|
||||
* ## Events
|
||||
*
|
||||
* App events allow you to understand the makeup of users engaging with your app, measure the performance of your Facebook mobile app ads, and reach specific sets of your users with Facebook mobile app ads.
|
||||
*
|
||||
* - [iOS] [https://developers.facebook.com/docs/ios/app-events](https://developers.facebook.com/docs/ios/app-events)
|
||||
* - [Android] [https://developers.facebook.com/docs/android/app-events](https://developers.facebook.com/docs/android/app-events)
|
||||
* - [JS] Does not have an Events API, so the plugin functions are empty and will return an automatic success
|
||||
*
|
||||
* Activation events are automatically tracked for you in the plugin.
|
||||
*
|
||||
* Events are listed on the [insights page](https://www.facebook.com/insights/).
|
||||
*
|
||||
* For tracking events, see `logEvent` and `logPurchase`.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Facebook, FacebookLoginResponse } from '@awesome-cordova-plugins/facebook/ngx';
|
||||
*
|
||||
* constructor(private fb: Facebook) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.fb.login(['public_profile', 'user_friends', 'email'])
|
||||
* .then((res: FacebookLoginResponse) => console.log('Logged into Facebook!', res))
|
||||
* .catch(e => console.log('Error logging into Facebook', e));
|
||||
*
|
||||
*
|
||||
* this.fb.logEvent(this.fb.EVENTS.EVENT_NAME_ADDED_TO_CART);
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Facebook',
|
||||
plugin: 'cordova-plugin-facebook-connect',
|
||||
pluginRef: 'facebookConnectPlugin',
|
||||
repo: 'https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect',
|
||||
install:
|
||||
'ionic cordova plugin add cordova-plugin-facebook-connect --variable APP_ID="123456789" --variable APP_NAME="myApplication"',
|
||||
installVariables: ['APP_ID', 'APP_NAME'],
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Facebook extends AwesomeCordovaNativePlugin {
|
||||
EVENTS = {
|
||||
EVENT_NAME_ACTIVATED_APP: 'fb_mobile_activate_app',
|
||||
EVENT_NAME_DEACTIVATED_APP: 'fb_mobile_deactivate_app',
|
||||
EVENT_NAME_SESSION_INTERRUPTIONS: 'fb_mobile_app_interruptions',
|
||||
EVENT_NAME_TIME_BETWEEN_SESSIONS: 'fb_mobile_time_between_sessions',
|
||||
EVENT_NAME_COMPLETED_REGISTRATION: 'fb_mobile_complete_registration',
|
||||
EVENT_NAME_VIEWED_CONTENT: 'fb_mobile_content_view',
|
||||
EVENT_NAME_SEARCHED: 'fb_mobile_search',
|
||||
EVENT_NAME_RATED: 'fb_mobile_rate',
|
||||
EVENT_NAME_COMPLETED_TUTORIAL: 'fb_mobile_tutorial_completion',
|
||||
EVENT_NAME_PUSH_TOKEN_OBTAINED: 'fb_mobile_obtain_push_token',
|
||||
EVENT_NAME_ADDED_TO_CART: 'fb_mobile_add_to_cart',
|
||||
EVENT_NAME_ADDED_TO_WISHLIST: 'fb_mobile_add_to_wishlist',
|
||||
EVENT_NAME_INITIATED_CHECKOUT: 'fb_mobile_initiated_checkout',
|
||||
EVENT_NAME_ADDED_PAYMENT_INFO: 'fb_mobile_add_payment_info',
|
||||
EVENT_NAME_PURCHASED: 'fb_mobile_purchase',
|
||||
EVENT_NAME_ACHIEVED_LEVEL: 'fb_mobile_level_achieved',
|
||||
EVENT_NAME_UNLOCKED_ACHIEVEMENT: 'fb_mobile_achievement_unlocked',
|
||||
EVENT_NAME_SPENT_CREDITS: 'fb_mobile_spent_credits',
|
||||
EVENT_PARAM_CURRENCY: 'fb_currency',
|
||||
EVENT_PARAM_REGISTRATION_METHOD: 'fb_registration_method',
|
||||
EVENT_PARAM_CONTENT_TYPE: 'fb_content_type',
|
||||
EVENT_PARAM_CONTENT_ID: 'fb_content_id',
|
||||
EVENT_PARAM_SEARCH_STRING: 'fb_search_string',
|
||||
EVENT_PARAM_SUCCESS: 'fb_success',
|
||||
EVENT_PARAM_MAX_RATING_VALUE: 'fb_max_rating_value',
|
||||
EVENT_PARAM_PAYMENT_INFO_AVAILABLE: 'fb_payment_info_available',
|
||||
EVENT_PARAM_NUM_ITEMS: 'fb_num_items',
|
||||
EVENT_PARAM_LEVEL: 'fb_level',
|
||||
EVENT_PARAM_DESCRIPTION: 'fb_description',
|
||||
EVENT_PARAM_SOURCE_APPLICATION: 'fb_mobile_launch_source',
|
||||
EVENT_PARAM_VALUE_YES: '1',
|
||||
EVENT_PARAM_VALUE_NO: '0',
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current application ID
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with the current application ID
|
||||
*/
|
||||
@Cordova()
|
||||
getApplicationId(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the application ID
|
||||
*
|
||||
* @param {string} id application ID
|
||||
*/
|
||||
@Cordova()
|
||||
setApplicationId(id: string): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current application name
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with the current application name
|
||||
*/
|
||||
@Cordova()
|
||||
getApplicationName(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the application name
|
||||
*
|
||||
* @param {string} name application name
|
||||
*/
|
||||
@Cordova()
|
||||
setApplicationName(name: string): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login to Facebook to authenticate this app.
|
||||
*
|
||||
* ```typescript
|
||||
* {
|
||||
* status: 'connected',
|
||||
* authResponse: {
|
||||
* accessToken: 'kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn',
|
||||
* data_access_expiration_time: '1623680244',
|
||||
* expiresIn: 5183979,
|
||||
* userID: '634565435'
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* @param {string[]} permissions List of [permissions](https://developers.facebook.com/docs/facebook-login/permissions) this app has upon logging in.
|
||||
* @returns {Promise<FacebookLoginResponse>} Returns a Promise that resolves with a status object if login succeeds, and rejects if login fails.
|
||||
*/
|
||||
@Cordova()
|
||||
login(permissions: string[]): Promise<FacebookLoginResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login to Facebook using Limited Login (iOS Only)
|
||||
*
|
||||
* ```typescript
|
||||
* {
|
||||
* status: 'connected',
|
||||
* authResponse: {
|
||||
* authenticationToken: 'kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn',
|
||||
* nonce: 'foo',
|
||||
* userID: '634565435'
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* @param {string[]} permissions List of [permissions](https://developers.facebook.com/docs/facebook-login/limited-login/permissions) this app has upon logging in.
|
||||
* @returns {Promise<FacebookLoginResponse>} Returns a Promise that resolves with a status object if login succeeds, and rejects if login fails.
|
||||
*/
|
||||
@Cordova()
|
||||
loginWithLimitedTracking(permissions: string[]): Promise<FacebookLoginResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user has approved all necessary permissions
|
||||
*
|
||||
* @param {string[]} permissions List of [permissions](https://developers.facebook.com/docs/facebook-login/permissions) to check for
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with a success string if all passed permissions are granted, or an error string if any permissions are not granted
|
||||
*/
|
||||
@Cordova()
|
||||
checkHasCorrectPermissions(permissions: string[]): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if data access has expired for the user
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with a success string if data access is expired, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
isDataAccessExpired(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reauthorize data access after it has expired
|
||||
*
|
||||
* @returns {Promise<FacebookLoginResponse>} Returns a Promise that resolves with a status object if login succeeds, and rejects if login fails.
|
||||
*/
|
||||
@Cordova()
|
||||
reauthorizeDataAccess(): Promise<FacebookLoginResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout of Facebook.
|
||||
*
|
||||
* For more info see the [Facebook docs](https://developers.facebook.com/docs/reference/javascript/FB.logout)
|
||||
*
|
||||
* @returns {Promise<any>} Returns a Promise that resolves on a successful logout, and rejects if logout fails.
|
||||
*/
|
||||
@Cordova()
|
||||
logout(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a user is logged in to Facebook and has authenticated your app. There are three possible states for a user:
|
||||
*
|
||||
* 1) the user is logged into Facebook and has authenticated your application (connected)
|
||||
* 2) the user is logged into Facebook but has not authenticated your application (not_authorized)
|
||||
* 3) the user is either not logged into Facebook or explicitly logged out of your application so it doesn't attempt to connect to Facebook and thus, we don't know if they've authenticated your application or not (unknown)
|
||||
*
|
||||
* Resolves with a response like:
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* authResponse: {
|
||||
* userID: '12345678912345',
|
||||
* accessToken: 'kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn',
|
||||
* data_access_expiration_time: '1623680244',
|
||||
* expiresIn: '5183738'
|
||||
* },
|
||||
* status: 'connected'
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* For more information see the [Facebook docs](https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus)
|
||||
*
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with a status, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
getLoginStatus(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Facebook access token for using Facebook services.
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with an access token, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
getAccessToken(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile information for the currently logged in user
|
||||
*
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with success data, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
getCurrentProfile(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show one of various Facebook dialogs. Example of options for a Share dialog:
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* method: 'share',
|
||||
* href: 'http://example.com'
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* For more options see the [Cordova plugin docs](https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect#show-a-dialog) and the [Facebook docs](https://developers.facebook.com/docs/javascript/reference/FB.ui)
|
||||
*
|
||||
* @param {Object} options The dialog options
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with success data, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
showDialog(options: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a call to Facebook Graph API. Can take additional permissions beyond those granted on login.
|
||||
*
|
||||
* For more information see:
|
||||
*
|
||||
* Calling the Graph API - https://developers.facebook.com/docs/javascript/reference/FB.api
|
||||
* Graph Explorer - https://developers.facebook.com/tools/explorer
|
||||
* Graph API - https://developers.facebook.com/docs/graph-api
|
||||
*
|
||||
* @param {string} requestPath Graph API endpoint you want to call
|
||||
* @param {string[]} permissions List of [permissions](https://developers.facebook.com/docs/facebook-login/permissions) for this request.
|
||||
* @param {string} httpMethod HTTP method for the request, one of "GET", "POST", or "DELETE" (default is "GET")
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with the result of the request, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
api(requestPath: string, permissions: string[], httpMethod?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Data Processing Options for App events. For more information see [Facebook docs](https://developers.facebook.com/docs/app-events/guides/ccpa)
|
||||
*
|
||||
* @param {string[]} options List of options, i.e. ["LDU"]
|
||||
* @param {number} country The numeric identifier for the country
|
||||
* @param {number} state The numeric identifier for the state
|
||||
*/
|
||||
@Cordova()
|
||||
setDataProcessingOptions(options: string[], country?: number, state?: number): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set user data for Advanced Matching. For more information see [Facebook docs](https://developers.facebook.com/docs/app-events/advanced-matching/)
|
||||
*
|
||||
* @param {Object} userData An object containing data about the user
|
||||
*/
|
||||
@Cordova()
|
||||
setUserData(userData: Object): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear user data. For more information see [Facebook docs](https://developers.facebook.com/docs/app-events/advanced-matching/)
|
||||
*/
|
||||
@Cordova()
|
||||
clearUserData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an event. For more information see the Events section above.
|
||||
*
|
||||
* @param {string} name Name of the event
|
||||
* @param {Object} [params] An object containing extra data to log with the event
|
||||
* @param {number} [valueToSum] any value to be added to added to a sum on each event
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 3,
|
||||
errorIndex: 4,
|
||||
})
|
||||
logEvent(name: string, params?: Object, valueToSum?: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable the auto log app event feature - https://developers.facebook.com/docs/app-events/gdpr-compliance/
|
||||
*
|
||||
* @param {boolean} enabled value to be set
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
setAutoLogAppEventsEnabled(enabled: boolean): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable collection of advertiser-id
|
||||
*
|
||||
* @param {boolean} enabled value to be set
|
||||
*/
|
||||
@Cordova()
|
||||
setAdvertiserIDCollectionEnabled(enabled: boolean): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable advertiser tracking (iOS Only)
|
||||
*
|
||||
* @param {boolean} enabled value to be set
|
||||
*/
|
||||
@Cordova()
|
||||
setAdvertiserTrackingEnabled(enabled: boolean): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a purchase. For more information see the Events section above.
|
||||
*
|
||||
* @param {number} value Value of the purchase.
|
||||
* @param {string} currency The currency, as an [ISO 4217 currency code](http://en.wikipedia.org/wiki/ISO_4217)
|
||||
* @param {Object} params An object containing extra data to log with the event
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
logPurchase(value: number, currency: string, params?: Object): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the deferred app link
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with the deep link
|
||||
*/
|
||||
@Cordova()
|
||||
getDeferredApplink(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually log activation events
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
activateApp(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
484
src/@awesome-cordova-plugins/plugins/fbsdk/index.ts
Normal file
484
src/@awesome-cordova-plugins/plugins/fbsdk/index.ts
Normal file
@ -0,0 +1,484 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface FbSdkLoginResponse {
|
||||
status: string;
|
||||
|
||||
authResponse: {
|
||||
accessToken: string;
|
||||
|
||||
data_access_expiration_time: string;
|
||||
|
||||
expiresIn: number;
|
||||
|
||||
userID: string;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @name FbSdk
|
||||
* @description
|
||||
* Use the Facebook SDK plugin to obtain access to the native FB application on iOS and Android.
|
||||
*
|
||||
* Requires Cordova plugin: `cordova-plugin-fbsdk`. For more info, please see the [Facebook SDK](https://github.com/MaximBelov/cordova-plugin-fbsdk).
|
||||
*
|
||||
* #### Installation
|
||||
*
|
||||
* To use the FB plugin, you first have to create a new Facebook App inside of the Facebook developer portal at [https://developers.facebook.com/apps](https://developers.facebook.com/apps).
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
* Retrieve the `App ID` and `App Name`.
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
* Then type in the following command in your Terminal, where APP_ID and APP_NAME are the values from the Facebook Developer portal.
|
||||
*
|
||||
* ```bash
|
||||
* ionic cordova plugin add cordova-plugin-fbsdk --variable APP_ID="123456789" --variable APP_NAME="myApplication" --variable CLIENT_TOKEN="abcd1234"
|
||||
* ```
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
* Click `'Add Platform'`.
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
* At this point you'll need to open your project's [`config.xml`](https://cordova.apache.org/docs/en/latest/config_ref/index.html) file, found in the root directory of your project.
|
||||
*
|
||||
* Take note of the `id` for the next step:
|
||||
* ```
|
||||
* <widget id="com.mycompany.testapp" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||
* ```
|
||||
*
|
||||
* You can also edit the `id` to whatever you'd like it to be.
|
||||
*
|
||||
* #### Client Access Tokens
|
||||
*
|
||||
* [](https://developers.facebook.com/docs/facebook-login/guides/access-tokens#clienttokens)
|
||||
*
|
||||
*
|
||||
* #### iOS Install
|
||||
* Under 'Bundle ID', add the `id` from your `config.xml` file:
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
*
|
||||
* #### Android Install
|
||||
* Under 'Google Play Package Name', add the `id` from your `config.xml` file:
|
||||
*
|
||||
* [](https://developers.facebook.com/apps/)
|
||||
*
|
||||
*
|
||||
* And that's it! You can now make calls to Facebook using the plugin.
|
||||
*
|
||||
* ## Events
|
||||
*
|
||||
* App events allow you to understand the makeup of users engaging with your app, measure the performance of your Facebook mobile app ads, and reach specific sets of your users with Facebook mobile app ads.
|
||||
*
|
||||
* - [iOS] [https://developers.facebook.com/docs/ios/app-events](https://developers.facebook.com/docs/ios/app-events)
|
||||
* - [Android] [https://developers.facebook.com/docs/android/app-events](https://developers.facebook.com/docs/android/app-events)
|
||||
* - [JS] Does not have an Events API, so the plugin functions are empty and will return an automatic success
|
||||
*
|
||||
* Activation events are automatically tracked for you in the plugin.
|
||||
*
|
||||
* Events are listed on the [insights page](https://www.facebook.com/insights/).
|
||||
*
|
||||
* For tracking events, see `logEvent` and `logPurchase`.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { FbSdk, FbSdkLoginResponse } from '@awesome-cordova-plugins/fbsdk/ngx';
|
||||
*
|
||||
* constructor(private fbSdk: FbSdk) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.fbSdk.login(['public_profile', 'user_friends', 'email'])
|
||||
* .then((res: FbSdkLoginResponse) => console.log('Logged into Facebook!', res))
|
||||
* .catch(e => console.log('Error logging into Facebook', e));
|
||||
*
|
||||
*
|
||||
* this.fb.logEvent(this.fb.EVENTS.EVENT_NAME_ADDED_TO_CART);
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Facebook',
|
||||
plugin: 'cordova-plugin-fbsdk',
|
||||
pluginRef: 'facebookConnectPlugin',
|
||||
repo: 'https://github.com/MaximBelov/cordova-plugin-fbsdk',
|
||||
install:
|
||||
'ionic cordova plugin add cordova-plugin-fbsdk --variable APP_ID="123456789" --variable APP_NAME="myApplication" --variable CLIENT_TOKEN="abcd1234"',
|
||||
installVariables: ['APP_ID', 'APP_NAME', 'CLIENT_TOKEN'],
|
||||
platforms: ['Android', 'iOS', 'Browser'],
|
||||
})
|
||||
@Injectable()
|
||||
export class FbSdk extends AwesomeCordovaNativePlugin {
|
||||
EVENTS = {
|
||||
EVENT_NAME_ACTIVATED_APP: 'fb_mobile_activate_app',
|
||||
EVENT_NAME_DEACTIVATED_APP: 'fb_mobile_deactivate_app',
|
||||
EVENT_NAME_SESSION_INTERRUPTIONS: 'fb_mobile_app_interruptions',
|
||||
EVENT_NAME_TIME_BETWEEN_SESSIONS: 'fb_mobile_time_between_sessions',
|
||||
EVENT_NAME_COMPLETED_REGISTRATION: 'fb_mobile_complete_registration',
|
||||
EVENT_NAME_VIEWED_CONTENT: 'fb_mobile_content_view',
|
||||
EVENT_NAME_SEARCHED: 'fb_mobile_search',
|
||||
EVENT_NAME_RATED: 'fb_mobile_rate',
|
||||
EVENT_NAME_COMPLETED_TUTORIAL: 'fb_mobile_tutorial_completion',
|
||||
EVENT_NAME_PUSH_TOKEN_OBTAINED: 'fb_mobile_obtain_push_token',
|
||||
EVENT_NAME_ADDED_TO_CART: 'fb_mobile_add_to_cart',
|
||||
EVENT_NAME_ADDED_TO_WISHLIST: 'fb_mobile_add_to_wishlist',
|
||||
EVENT_NAME_INITIATED_CHECKOUT: 'fb_mobile_initiated_checkout',
|
||||
EVENT_NAME_ADDED_PAYMENT_INFO: 'fb_mobile_add_payment_info',
|
||||
EVENT_NAME_PURCHASED: 'fb_mobile_purchase',
|
||||
EVENT_NAME_ACHIEVED_LEVEL: 'fb_mobile_level_achieved',
|
||||
EVENT_NAME_UNLOCKED_ACHIEVEMENT: 'fb_mobile_achievement_unlocked',
|
||||
EVENT_NAME_SPENT_CREDITS: 'fb_mobile_spent_credits',
|
||||
EVENT_PARAM_CURRENCY: 'fb_currency',
|
||||
EVENT_PARAM_REGISTRATION_METHOD: 'fb_registration_method',
|
||||
EVENT_PARAM_CONTENT_TYPE: 'fb_content_type',
|
||||
EVENT_PARAM_CONTENT_ID: 'fb_content_id',
|
||||
EVENT_PARAM_SEARCH_STRING: 'fb_search_string',
|
||||
EVENT_PARAM_SUCCESS: 'fb_success',
|
||||
EVENT_PARAM_MAX_RATING_VALUE: 'fb_max_rating_value',
|
||||
EVENT_PARAM_PAYMENT_INFO_AVAILABLE: 'fb_payment_info_available',
|
||||
EVENT_PARAM_NUM_ITEMS: 'fb_num_items',
|
||||
EVENT_PARAM_LEVEL: 'fb_level',
|
||||
EVENT_PARAM_DESCRIPTION: 'fb_description',
|
||||
EVENT_PARAM_SOURCE_APPLICATION: 'fb_mobile_launch_source',
|
||||
EVENT_PARAM_VALUE_YES: '1',
|
||||
EVENT_PARAM_VALUE_NO: '0',
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current application ID
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with the current application ID
|
||||
*/
|
||||
@Cordova()
|
||||
getApplicationId(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the application ID
|
||||
*
|
||||
* @param {string} id application ID
|
||||
*/
|
||||
@Cordova()
|
||||
setApplicationId(id: string): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current application name
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with the current application name
|
||||
*/
|
||||
@Cordova()
|
||||
getApplicationName(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the application name
|
||||
*
|
||||
* @param {string} name application name
|
||||
*/
|
||||
@Cordova()
|
||||
setApplicationName(name: string): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login to Facebook to authenticate this app.
|
||||
*
|
||||
* ```typescript
|
||||
* {
|
||||
* status: 'connected',
|
||||
* authResponse: {
|
||||
* accessToken: 'kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn',
|
||||
* data_access_expiration_time: '1623680244',
|
||||
* expiresIn: 5183979,
|
||||
* userID: '634565435'
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* @param {string[]} permissions List of [permissions](https://developers.facebook.com/docs/facebook-login/permissions) this app has upon logging in.
|
||||
* @returns {Promise<FbSdkLoginResponse>} Returns a Promise that resolves with a status object if login succeeds, and rejects if login fails.
|
||||
*/
|
||||
@Cordova()
|
||||
login(permissions: string[]): Promise<FbSdkLoginResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login to Facebook using Limited Login (iOS Only)
|
||||
*
|
||||
* ```typescript
|
||||
* {
|
||||
* status: 'connected',
|
||||
* authResponse: {
|
||||
* authenticationToken: 'kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn',
|
||||
* nonce: 'foo',
|
||||
* userID: '634565435'
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* @param {string[]} permissions List of [permissions](https://developers.facebook.com/docs/facebook-login/limited-login/permissions) this app has upon logging in.
|
||||
* @returns {Promise<FbSdkLoginResponse>} Returns a Promise that resolves with a status object if login succeeds, and rejects if login fails.
|
||||
*/
|
||||
@Cordova()
|
||||
loginWithLimitedTracking(permissions: string[]): Promise<FbSdkLoginResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user has approved all necessary permissions
|
||||
*
|
||||
* @param {string[]} permissions List of [permissions](https://developers.facebook.com/docs/facebook-login/permissions) to check for
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with a success string if all passed permissions are granted, or an error string if any permissions are not granted
|
||||
*/
|
||||
@Cordova()
|
||||
checkHasCorrectPermissions(permissions: string[]): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if data access has expired for the user
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with a success string if data access is expired, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
isDataAccessExpired(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reauthorize data access after it has expired
|
||||
*
|
||||
* @returns {Promise<FbSdkLoginResponse>} Returns a Promise that resolves with a status object if login succeeds, and rejects if login fails.
|
||||
*/
|
||||
@Cordova()
|
||||
reauthorizeDataAccess(): Promise<FbSdkLoginResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout of Facebook.
|
||||
*
|
||||
* For more info see the [Facebook docs](https://developers.facebook.com/docs/reference/javascript/FB.logout)
|
||||
*
|
||||
* @returns {Promise<any>} Returns a Promise that resolves on a successful logout, and rejects if logout fails.
|
||||
*/
|
||||
@Cordova()
|
||||
logout(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a user is logged in to Facebook and has authenticated your app. There are three possible states for a user:
|
||||
*
|
||||
* 1) the user is logged into Facebook and has authenticated your application (connected)
|
||||
* 2) the user is logged into Facebook but has not authenticated your application (not_authorized)
|
||||
* 3) the user is either not logged into Facebook or explicitly logged out of your application so it doesn't attempt to connect to Facebook and thus, we don't know if they've authenticated your application or not (unknown)
|
||||
*
|
||||
* Resolves with a response like:
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* authResponse: {
|
||||
* userID: '12345678912345',
|
||||
* accessToken: 'kgkh3g42kh4g23kh4g2kh34g2kg4k2h4gkh3g4k2h4gk23h4gk2h34gk234gk2h34AndSoOn',
|
||||
* data_access_expiration_time: '1623680244',
|
||||
* expiresIn: '5183738'
|
||||
* },
|
||||
* status: 'connected'
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* For more information see the [Facebook docs](https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus)
|
||||
*
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with a status, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
getLoginStatus(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Facebook access token for using Facebook services.
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with an access token, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
getAccessToken(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile information for the currently logged in user
|
||||
*
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with success data, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
getCurrentProfile(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show one of various Facebook dialogs. Example of options for a Share dialog:
|
||||
*
|
||||
* ```
|
||||
* {
|
||||
* method: 'share',
|
||||
* href: 'http://example.com'
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* For more options see the [Cordova plugin docs](https://github.com/MaximBelov/cordova-plugin-fbsdk#show-a-dialog) and the [Facebook docs](https://developers.facebook.com/docs/javascript/reference/FB.ui)
|
||||
*
|
||||
* @param {Object} options The dialog options
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with success data, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
showDialog(options: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a call to Facebook Graph API. Can take additional permissions beyond those granted on login.
|
||||
*
|
||||
* For more information see:
|
||||
*
|
||||
* Calling the Graph API - https://developers.facebook.com/docs/javascript/reference/FB.api
|
||||
* Graph Explorer - https://developers.facebook.com/tools/explorer
|
||||
* Graph API - https://developers.facebook.com/docs/graph-api
|
||||
*
|
||||
* @param {string} requestPath Graph API endpoint you want to call
|
||||
* @param {string[]} permissions List of [permissions](https://developers.facebook.com/docs/facebook-login/permissions) for this request.
|
||||
* @param {string} httpMethod HTTP method for the request, one of "GET", "POST", or "DELETE" (default is "GET")
|
||||
* @returns {Promise<any>} Returns a Promise that resolves with the result of the request, or rejects with an error
|
||||
*/
|
||||
@Cordova()
|
||||
api(requestPath: string, permissions: string[], httpMethod?: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Data Processing Options for App events. For more information see [Facebook docs](https://developers.facebook.com/docs/app-events/guides/ccpa)
|
||||
*
|
||||
* @param {string[]} options List of options, i.e. ["LDU"]
|
||||
* @param {number} country The numeric identifier for the country
|
||||
* @param {number} state The numeric identifier for the state
|
||||
*/
|
||||
@Cordova()
|
||||
setDataProcessingOptions(options: string[], country?: number, state?: number): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set user data for Advanced Matching. For more information see [Facebook docs](https://developers.facebook.com/docs/app-events/advanced-matching/)
|
||||
*
|
||||
* @param {Object} userData An object containing data about the user
|
||||
*/
|
||||
@Cordova()
|
||||
setUserData(userData: Object): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear user data. For more information see [Facebook docs](https://developers.facebook.com/docs/app-events/advanced-matching/)
|
||||
*/
|
||||
@Cordova()
|
||||
clearUserData(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an event. For more information see the Events section above.
|
||||
*
|
||||
* @param {string} name Name of the event
|
||||
* @param {Object} [params] An object containing extra data to log with the event
|
||||
* @param {number} [valueToSum] any value to be added to added to a sum on each event
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 3,
|
||||
errorIndex: 4,
|
||||
})
|
||||
logEvent(name: string, params?: Object, valueToSum?: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable the auto log app event feature - https://developers.facebook.com/docs/app-events/gdpr-compliance/
|
||||
*
|
||||
* @param {boolean} enabled value to be set
|
||||
*/
|
||||
@Cordova({
|
||||
successIndex: 1,
|
||||
errorIndex: 2,
|
||||
})
|
||||
setAutoLogAppEventsEnabled(enabled: boolean): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable collection of advertiser-id
|
||||
*
|
||||
* @param {boolean} enabled value to be set
|
||||
*/
|
||||
@Cordova()
|
||||
setAdvertiserIDCollectionEnabled(enabled: boolean): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable advertiser tracking (iOS Only)
|
||||
*
|
||||
* @param {boolean} enabled value to be set
|
||||
*/
|
||||
@Cordova()
|
||||
setAdvertiserTrackingEnabled(enabled: boolean): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a purchase. For more information see the Events section above.
|
||||
*
|
||||
* @param {number} value Value of the purchase.
|
||||
* @param {string} currency The currency, as an [ISO 4217 currency code](http://en.wikipedia.org/wiki/ISO_4217)
|
||||
* @param {Object} params An object containing extra data to log with the event
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
logPurchase(value: number, currency: string, params?: Object): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the deferred app link
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with the deep link
|
||||
*/
|
||||
@Cordova()
|
||||
getDeferredApplink(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually log activation events
|
||||
*
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova()
|
||||
activateApp(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
245
src/@awesome-cordova-plugins/plugins/fcm/index.ts
Normal file
245
src/@awesome-cordova-plugins/plugins/fcm/index.ts
Normal file
@ -0,0 +1,245 @@
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
export interface NotificationData {
|
||||
/**
|
||||
* Determines whether the notification was pressed or not
|
||||
*/
|
||||
|
||||
wasTapped: boolean;
|
||||
|
||||
/**
|
||||
* Notification data hash item
|
||||
*/
|
||||
|
||||
[name: string]: any;
|
||||
}
|
||||
|
||||
export interface IRequestPushPermissionIOSOptions {
|
||||
/**
|
||||
* Options exclusive for iOS 9 support
|
||||
*/
|
||||
ios9Support?: {
|
||||
/**
|
||||
* How long it will wait for a decision from the user before returning `false`, defaults to 10
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* How long between each permission verification, defaults to 0.3
|
||||
*/
|
||||
interval?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IChannelConfiguration {
|
||||
/**
|
||||
* Channel id, used in the android_channel_id push payload key
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Channel name, visible for the user
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Channel description, visible for the user
|
||||
*/
|
||||
description?: string;
|
||||
/**
|
||||
* Importance for notifications of this channel
|
||||
* https://developer.android.com/guide/topics/ui/notifiers/notifications#importance
|
||||
*/
|
||||
importance?: 'none' | 'min' | 'low' | 'default' | 'high';
|
||||
/**
|
||||
* Visibility for notifications of this channel
|
||||
* https://developer.android.com/training/notify-user/build-notification#lockscreenNotification
|
||||
*/
|
||||
visibility?: 'public' | 'private' | 'secret';
|
||||
/**
|
||||
* Default sound resource for notifications of this channel
|
||||
* The file should located as resources/raw/[resource name].mp3
|
||||
*/
|
||||
sound?: string;
|
||||
/**
|
||||
* Enable lights for notifications of this channel
|
||||
*/
|
||||
lights?: boolean;
|
||||
/**
|
||||
* Enable vibration for notifications of this channel
|
||||
*/
|
||||
vibration?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name FCM
|
||||
* @capacitorincompatible true
|
||||
* @description
|
||||
* Provides basic functionality for Firebase Cloud Messaging
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { FCM } from '@awesome-cordova-plugins/fcm/ngx';
|
||||
*
|
||||
* constructor(private fcm: FCM) {}
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.fcm.subscribeToTopic('marketing');
|
||||
*
|
||||
* this.fcm.getToken().then(token => {
|
||||
* backend.registerToken(token);
|
||||
* });
|
||||
*
|
||||
* this.fcm.onNotification().subscribe(data => {
|
||||
* if(data.wasTapped){
|
||||
* console.log("Received in background");
|
||||
* } else {
|
||||
* console.log("Received in foreground");
|
||||
* };
|
||||
* });
|
||||
*
|
||||
* this.fcm.onTokenRefresh().subscribe(token => {
|
||||
* backend.registerToken(token);
|
||||
* });
|
||||
*
|
||||
* this.fcm.hasPermission().then(hasPermission => {
|
||||
* if (hasPermission) {
|
||||
* console.log("Has permission!");
|
||||
* }
|
||||
* })
|
||||
*
|
||||
* this.fcm.clearAllNotifications();
|
||||
*
|
||||
* this.fcm.unsubscribeFromTopic('marketing');
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* NotificationData
|
||||
* IRequestPushPermissionIOSOptions
|
||||
* IChannelConfiguration
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'FCM',
|
||||
plugin: 'cordova-plugin-fcm-with-dependecy-updated',
|
||||
pluginRef: 'FCMPlugin',
|
||||
repo: 'https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class FCM extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Gets ios device's current APNS token
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with the APNS token
|
||||
*/
|
||||
@Cordova()
|
||||
getAPNSToken(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets device's current registration id
|
||||
*
|
||||
* @returns {Promise<string>} Returns a Promise that resolves with the registration id token
|
||||
*/
|
||||
@Cordova()
|
||||
getToken(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event firing on the token refresh
|
||||
*
|
||||
* @returns {Observable<string>} Returns an Observable that notifies with the change of device's registration id
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
})
|
||||
onTokenRefresh(): Observable<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes you to a [topic](https://firebase.google.com/docs/notifications/android/console-topics)
|
||||
*
|
||||
* @param {string} topic Topic to be subscribed to
|
||||
* @returns {Promise<any>} Returns a promise resolving in result of subscribing to a topic
|
||||
*/
|
||||
@Cordova()
|
||||
subscribeToTopic(topic: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribes you from a [topic](https://firebase.google.com/docs/notifications/android/console-topics)
|
||||
*
|
||||
* @param {string} topic Topic to be unsubscribed from
|
||||
* @returns {Promise<any>} Returns a promise resolving in result of unsubscribing from a topic
|
||||
*/
|
||||
@Cordova()
|
||||
unsubscribeFromTopic(topic: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking for permissions on iOS. On android, it always returns `true`.
|
||||
*
|
||||
* @returns {Promise<boolean | null>} Returns a Promise:
|
||||
* - true: push was allowed (or platform is android)
|
||||
* - false: push will not be available
|
||||
* - null: still not answered, recommended checking again later.
|
||||
*/
|
||||
@Cordova()
|
||||
hasPermission(): Promise<boolean | null> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Watch for incoming notifications
|
||||
*
|
||||
* @returns {Observable<any>} returns an object with data from the notification
|
||||
*/
|
||||
@Cordova({
|
||||
observable: true,
|
||||
successIndex: 0,
|
||||
errorIndex: 2,
|
||||
})
|
||||
onNotification(): Observable<NotificationData> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes existing push notifications from the notifications center
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
clearAllNotifications(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request push notification permission, alerting the user if it not have yet decided
|
||||
*
|
||||
* @param {IRequestPushPermissionIOSOptions} options Options for push request
|
||||
* @returns {Promise<boolean>} Returns a Promise that resolves with the permission status
|
||||
*/
|
||||
@Cordova()
|
||||
requestPushPermissionIOS(options?: IRequestPushPermissionIOSOptions): Promise<boolean> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Android, some notification properties are only defined programmatically.
|
||||
*
|
||||
* Channel can define the default behavior for notifications on Android 8.0+.
|
||||
*
|
||||
* Once a channel is created, it stays unchangeable until the user uninstalls the app.
|
||||
*
|
||||
* @param channelConfig
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@Cordova()
|
||||
createNotificationChannelAndroid(channelConfig: IChannelConfiguration): void {
|
||||
return;
|
||||
}
|
||||
}
|
74
src/@awesome-cordova-plugins/plugins/ffmpeg/index.ts
Normal file
74
src/@awesome-cordova-plugins/plugins/ffmpeg/index.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
export interface VideoInformation {
|
||||
format: {
|
||||
bit_rate: string;
|
||||
duration: string;
|
||||
filename: string;
|
||||
format_name: string;
|
||||
nb_programs: string;
|
||||
nb_streams: string;
|
||||
probe_score: string;
|
||||
size: string;
|
||||
start_time: string;
|
||||
};
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name FFMpeg
|
||||
* @description
|
||||
* Simple plugin that binds mobile ffmpeg to execute ffmpeg commands
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { FFMpeg } from '@awesome-cordova-plugins/ffmpeg/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private ffMpeg: FFMpeg) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.fFMpeg.exec('-i someinput.mp4 -vn -c:a copy out.mp3')
|
||||
* .then((res: any) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
*
|
||||
* this.fFMpeg.probe('somefile.mp4"')
|
||||
* .then((res: VideoInformation) => console.log(res))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'FFMpeg',
|
||||
plugin: 'cordova-plugin-ffmpeg',
|
||||
pluginRef: 'ffmpeg',
|
||||
repo: 'https://github.com/MaximBelov/cordova-plugin-ffmpeg',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class FFMpeg extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Execute ffmpeg command
|
||||
* @param cmd {string} command
|
||||
* @return {Promise<any>} Returns a promise that resolves when execute finished
|
||||
*/
|
||||
@Cordova()
|
||||
exec(cmd: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts media information for the file specified with path
|
||||
* @param filePath {string} file path
|
||||
* @return {Promise<VideoInformation>} Returns a promise that resolves when media information received
|
||||
*/
|
||||
@Cordova()
|
||||
probe(filePath: string): Promise<VideoInformation> {
|
||||
return;
|
||||
}
|
||||
}
|
47
src/@awesome-cordova-plugins/plugins/file-chooser/index.ts
Normal file
47
src/@awesome-cordova-plugins/plugins/file-chooser/index.ts
Normal file
@ -0,0 +1,47 @@
|
||||
/* eslint-disable jsdoc/require-returns-check */
|
||||
/* eslint-disable jsdoc/check-tag-names */
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name FileChooser Plugin
|
||||
* @description
|
||||
* Cordova FileChooser Plugin
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { FileChooser } from '@awesome-cordova-plugins/file-chooser/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private fileChooser: FileChooser) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.fileChooser.open()
|
||||
* .then(() => console.log('Success'))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'FileChooser',
|
||||
plugin: 'cordova-plugin-filechooser',
|
||||
pluginRef: 'fileChooser',
|
||||
repo: 'https://github.com/ihadeed/cordova-filechooser',
|
||||
platforms: ['Android'],
|
||||
})
|
||||
@Injectable()
|
||||
export class FileChooser extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Launches a chooser dialog. The filter param allows filtering a the mime type
|
||||
* { "mime": "application/pdf" }
|
||||
*
|
||||
* @param {string} [filter] Filter allowing filter by a mime type (text/plain, image/png, image/jpeg, audio/wav etc.)
|
||||
* @returns {Promise<string>} URI of the selected file
|
||||
*/
|
||||
@Cordova()
|
||||
open(filter?: string): Promise<string> {
|
||||
return;
|
||||
}
|
||||
}
|
43
src/@awesome-cordova-plugins/plugins/file-md5/index.ts
Normal file
43
src/@awesome-cordova-plugins/plugins/file-md5/index.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name File MD5
|
||||
* @description
|
||||
* This plugin reads large files in chunks and build the md5sum incrementally.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { FileMD5 } from '@awesome-cordova-plugins/file-md5/nx';
|
||||
*
|
||||
*
|
||||
* constructor(private fileMD5: FileMD5) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* this.fileMD5.file(fileEntry)
|
||||
* .then((md5sum: string) => console.log(md5sum))
|
||||
* .catch((error: any) => console.error(error));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'FileMD5',
|
||||
plugin: 'cordova-plugin-file-md5',
|
||||
pluginRef: 'md5chksum',
|
||||
repo: 'https://github.com/mramonlopez/cordova-plugin-file-md5',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class FileMD5 extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Get MD5 checksum from a file
|
||||
*
|
||||
* @param fileEntry {FileEntry} File entry is a org.apache.cordova.file.FileEntry
|
||||
* @returns {Promise<any>} Promise with md5sum
|
||||
*/
|
||||
@Cordova()
|
||||
file(fileEntry: any): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
96
src/@awesome-cordova-plugins/plugins/file-opener/index.ts
Normal file
96
src/@awesome-cordova-plugins/plugins/file-opener/index.ts
Normal file
@ -0,0 +1,96 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
/**
|
||||
* @name File Opener
|
||||
* @description
|
||||
* This plugin will open a file on your device file system with its default application.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||
*
|
||||
* constructor(private fileOpener: FileOpener) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.fileOpener.open('path/to/file.pdf', 'application/pdf')
|
||||
* .then(() => console.log('File is opened'))
|
||||
* .catch(e => console.log('Error opening file', e));
|
||||
*
|
||||
* this.fileOpener.showOpenWithDialog('path/to/file.pdf', 'application/pdf')
|
||||
* .then(() => console.log('File is opened'))
|
||||
* .catch(e => console.log('Error opening file', e));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'FileOpener',
|
||||
plugin: 'cordova-plugin-file-opener2',
|
||||
pluginRef: 'cordova.plugins.fileOpener2',
|
||||
repo: 'https://github.com/pwlin/cordova-plugin-file-opener2',
|
||||
platforms: ['Android', 'iOS', 'Windows', 'Windows Phone 8'],
|
||||
})
|
||||
@Injectable()
|
||||
export class FileOpener extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Open an file
|
||||
*
|
||||
* @param {string} filePath File Path
|
||||
* @param {string} fileMIMEType File MIME Type
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackStyle: 'object',
|
||||
successName: 'success',
|
||||
errorName: 'error',
|
||||
})
|
||||
open(filePath: string, fileMIMEType: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstalls a package
|
||||
*
|
||||
* @param {string} packageId Package ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackStyle: 'object',
|
||||
successName: 'success',
|
||||
errorName: 'error',
|
||||
})
|
||||
uninstall(packageId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an app is already installed
|
||||
*
|
||||
* @param {string} packageId Package ID
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackStyle: 'object',
|
||||
successName: 'success',
|
||||
errorName: 'error',
|
||||
})
|
||||
appIsInstalled(packageId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens with system modal to open file with an already installed app.
|
||||
*
|
||||
* @param {string} filePath File Path
|
||||
* @param {string} fileMIMEType File MIME Type
|
||||
* @returns {Promise<any>}
|
||||
*/
|
||||
@Cordova({
|
||||
callbackStyle: 'object',
|
||||
successName: 'success',
|
||||
errorName: 'error',
|
||||
})
|
||||
showOpenWithDialog(filePath: string, fileMIMEType: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
45
src/@awesome-cordova-plugins/plugins/file-path/index.ts
Normal file
45
src/@awesome-cordova-plugins/plugins/file-path/index.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
declare const window: any;
|
||||
|
||||
/**
|
||||
* @name File Path
|
||||
* @premier filesystem
|
||||
* @description
|
||||
*
|
||||
* This plugin allows you to resolve the native filesystem path for Android content URIs and is based on code in the aFileChooser library.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { FilePath } from '@awesome-cordova-plugins/file-path/ngx';
|
||||
*
|
||||
* constructor(private filePath: FilePath) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.filePath.resolveNativePath(path)
|
||||
* .then(filePath => console.log(filePath))
|
||||
* .catch(err => console.log(err));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'FilePath',
|
||||
plugin: 'cordova-plugin-filepath',
|
||||
pluginRef: 'window.FilePath',
|
||||
repo: 'https://github.com/hiddentao/cordova-plugin-filepath',
|
||||
platforms: ['Android'],
|
||||
})
|
||||
@Injectable()
|
||||
export class FilePath extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Resolve native path for given content URL/path.
|
||||
*
|
||||
* @param {string} path Content URL/path.
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
@Cordova()
|
||||
resolveNativePath(path: string): Promise<string> {
|
||||
return;
|
||||
}
|
||||
}
|
281
src/@awesome-cordova-plugins/plugins/file-transfer/index.ts
Normal file
281
src/@awesome-cordova-plugins/plugins/file-transfer/index.ts
Normal file
@ -0,0 +1,281 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
CordovaInstance,
|
||||
InstanceCheck,
|
||||
AwesomeCordovaNativePlugin,
|
||||
Plugin,
|
||||
checkAvailability,
|
||||
} from '@awesome-cordova-plugins/core';
|
||||
|
||||
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 File Transfer
|
||||
* @description
|
||||
* This plugin allows you to upload and download files.
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { FileTransfer, FileUploadOptions, FileTransferObject } from '@awesome-cordova-plugins/file-transfer/ngx';
|
||||
* import { File } from '@awesome-cordova-plugins/file';
|
||||
*
|
||||
* constructor(private transfer: FileTransfer, private file: File) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* const fileTransfer: FileTransferObject = this.transfer.create();
|
||||
*
|
||||
* // Upload a file:
|
||||
* fileTransfer.upload(..).then(..).catch(..);
|
||||
*
|
||||
* // Download a file:
|
||||
* fileTransfer.download(..).then(..).catch(..);
|
||||
*
|
||||
* // Abort active transfer:
|
||||
* fileTransfer.abort();
|
||||
*
|
||||
* // full example
|
||||
* upload() {
|
||||
* let options: FileUploadOptions = {
|
||||
* fileKey: 'file',
|
||||
* fileName: 'name.jpg',
|
||||
* headers: {}
|
||||
* .....
|
||||
* }
|
||||
*
|
||||
* fileTransfer.upload('<file path>', '<api endpoint>', options)
|
||||
* .then((data) => {
|
||||
* // success
|
||||
* }, (err) => {
|
||||
* // error
|
||||
* })
|
||||
* }
|
||||
*
|
||||
* download() {
|
||||
* const url = 'http://www.example.com/file.pdf';
|
||||
* fileTransfer.download(url, this.file.dataDirectory + 'file.pdf').then((entry) => {
|
||||
* console.log('download complete: ' + entry.toURL());
|
||||
* }, (error) => {
|
||||
* // handle error
|
||||
* });
|
||||
* }
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* To store files in a different/publicly accessible directory, please refer to the following link
|
||||
* https://github.com/apache/cordova-plugin-file#where-to-store-files
|
||||
* @interfaces
|
||||
* FileUploadOptions
|
||||
* FileUploadResult
|
||||
* FileTransferError
|
||||
* @classes
|
||||
* FileTransferObject
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'FileTransfer',
|
||||
plugin: 'cordova-plugin-file-transfer',
|
||||
pluginRef: 'FileTransfer',
|
||||
repo: 'https://github.com/apache/cordova-plugin-file-transfer',
|
||||
platforms: ['Amazon Fire OS', 'Android', 'Browser', 'iOS', 'Ubuntu', 'Windows', 'Windows Phone'],
|
||||
})
|
||||
@Injectable()
|
||||
export class FileTransfer extends AwesomeCordovaNativePlugin {
|
||||
/**
|
||||
* Error code rejected from upload with FileTransferError
|
||||
* Defined in FileTransferError.
|
||||
* FILE_NOT_FOUND_ERR: 1 Return when file was not found
|
||||
* INVALID_URL_ERR: 2, Return when url was invalid
|
||||
* CONNECTION_ERR: 3, Return on connection error
|
||||
* ABORT_ERR: 4, Return on aborting
|
||||
* NOT_MODIFIED_ERR: 5 Return on '304 Not Modified' HTTP response
|
||||
*
|
||||
* @enum {number}
|
||||
*/
|
||||
FileTransferErrorCode = {
|
||||
FILE_NOT_FOUND_ERR: 1,
|
||||
INVALID_URL_ERR: 2,
|
||||
CONNECTION_ERR: 3,
|
||||
ABORT_ERR: 4,
|
||||
NOT_MODIFIED_ERR: 5,
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new FileTransfer object
|
||||
*
|
||||
* @returns {FileTransferObject}
|
||||
*/
|
||||
create(): FileTransferObject {
|
||||
return new FileTransferObject();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
@Plugin({
|
||||
plugin: 'cordova-plugin-file-transfer',
|
||||
pluginName: 'FileTransfer',
|
||||
})
|
||||
export class FileTransferObject {
|
||||
private _objectInstance: any;
|
||||
|
||||
constructor() {
|
||||
if (checkAvailability(FileTransfer.getPluginRef(), null, FileTransfer.getPluginName()) === true) {
|
||||
this._objectInstance = new (FileTransfer.getPlugin())();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @returns {Promise<FileUploadResult>} 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 {string} 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).
|
||||
* @returns {Promise<any>} 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 Listener that takes a progress event.
|
||||
*/
|
||||
@InstanceCheck({ sync: true })
|
||||
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 {}
|
||||
}
|
1539
src/@awesome-cordova-plugins/plugins/file/index.ts
Normal file
1539
src/@awesome-cordova-plugins/plugins/file/index.ts
Normal file
File diff suppressed because it is too large
Load Diff
266
src/@awesome-cordova-plugins/plugins/fingerprint-aio/index.ts
Normal file
266
src/@awesome-cordova-plugins/plugins/fingerprint-aio/index.ts
Normal file
@ -0,0 +1,266 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, AwesomeCordovaNativePlugin, Plugin } from '@awesome-cordova-plugins/core';
|
||||
|
||||
// Biometric type
|
||||
export type BIOMETRIC_TYPE = 'finger' | 'face' | 'biometric';
|
||||
|
||||
export enum BIOMETRIC_ERRORS {
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_UNKNOWN_ERROR = -100,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_UNAVAILABLE = -101,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_AUTHENTICATION_FAILED = -102,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_SDK_NOT_SUPPORTED = -103,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_HARDWARE_NOT_SUPPORTED = -104,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_PERMISSION_NOT_GRANTED = -105,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_NOT_ENROLLED = -106,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_INTERNAL_PLUGIN_ERROR = -107,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_DISMISSED = -108,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_PIN_OR_PATTERN_DISMISSED = -109,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_SCREEN_GUARD_UNSECURED = -110,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_LOCKED_OUT = -111,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_LOCKED_OUT_PERMANENT = -112,
|
||||
/**
|
||||
* Convenience constant
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
BIOMETRIC_SECRET_NOT_FOUND = -113
|
||||
}
|
||||
|
||||
export interface FingerprintOptions {
|
||||
/**
|
||||
* Title in biometric prompt (android only)
|
||||
*
|
||||
* @default {APP_NAME} Biometric Sign On
|
||||
*/
|
||||
title?: string;
|
||||
|
||||
/**
|
||||
* Subtitle in biometric Prompt (android only)
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
subtitle?: string;
|
||||
|
||||
/**
|
||||
* Description in biometric Prompt
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* Title of fallback button.
|
||||
*
|
||||
* @default "Use Pin"
|
||||
*/
|
||||
fallbackButtonTitle?: string;
|
||||
|
||||
/**
|
||||
* Title for cancel button on Android
|
||||
*
|
||||
* @default "Cancel"
|
||||
*/
|
||||
cancelButtonTitle?: string;
|
||||
|
||||
/**
|
||||
* Disable 'use backup' option.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
disableBackup?: boolean;
|
||||
|
||||
/**
|
||||
* (Android): If false user confirmation is NOT required after a biometric has been authenticated.
|
||||
*
|
||||
* @default true.
|
||||
* See https://developer.android.com/training/sign-in/biometric-auth#no-explicit-user-action
|
||||
*/
|
||||
confirmationRequired?: boolean;
|
||||
}
|
||||
|
||||
export interface FingerprintSecretOptions extends FingerprintOptions {
|
||||
/**
|
||||
* String secret to encrypt and save, use simple strings matching the regex [a-zA-Z0-9\-]+
|
||||
*/
|
||||
secret: string;
|
||||
|
||||
/**
|
||||
* If `true` secret will be deleted when biometry items are deleted or enrolled
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
invalidateOnEnrollment?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Fingerprint AIO
|
||||
* @description
|
||||
* Use simple fingerprint authentication on Android and iOS.
|
||||
* Requires Cordova plugin: cordova-plugin-fingerprint-aio. For more info about plugin, vist: https://github.com/NiklasMerz/cordova-plugin-fingerprint-aio
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { FingerprintAIO } from '@awesome-cordova-plugins/fingerprint-aio/ngx';
|
||||
*
|
||||
* constructor(private faio: FingerprintAIO) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.faio.show().then((result: any) => console.log(result)).catch((error: any) => console.log(error));
|
||||
*
|
||||
* OR with options...
|
||||
*
|
||||
* this.faio.show({
|
||||
* title: 'Biometric Authentication', // (Android Only) | optional | Default: "<APP_NAME> Biometric Sign On"
|
||||
* subtitle: 'Coolest Plugin ever' // (Android Only) | optional | Default: null
|
||||
* description: 'Please authenticate' // optional | Default: null
|
||||
* fallbackButtonTitle: 'Use Backup', // optional | When disableBackup is false defaults to "Use Pin".
|
||||
* // When disableBackup is true defaults to "Cancel"
|
||||
* disableBackup:true, // optional | default: false
|
||||
* })
|
||||
* .then((result: any) => console.log(result))
|
||||
* .catch((error: any) => console.log(error));
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.faio.registerBiometricSecret({
|
||||
* description: "Some biometric description", // optional | Default: null
|
||||
* secret: "my-super-secret", // mandatory
|
||||
* invalidateOnEnrollment: true, // optional | Default: false
|
||||
* disableBackup: true, // (Android Only) | optional | always `true` on Android
|
||||
* })
|
||||
* .then((result: any) => console.log(result))
|
||||
* .catch((error: any) => console.log(error));
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* this.faio.loadBiometricSecret({
|
||||
* description: "Some biometric description", // optional | Default: null
|
||||
* disableBackup: true, // always disabled on Android
|
||||
* })
|
||||
* .then((result: string) => console.log(result))
|
||||
* .catch((error: any) => console.log(error));
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* FingerprintOptions
|
||||
* FingerprintSecretOptions
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'FingerprintAIO',
|
||||
plugin: 'cordova-plugin-fingerprint-aio',
|
||||
pluginRef: 'Fingerprint',
|
||||
repo: 'https://github.com/NiklasMerz/cordova-plugin-fingerprint-aio',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class FingerprintAIO extends AwesomeCordovaNativePlugin {
|
||||
|
||||
/**
|
||||
* Check if fingerprint authentication is available
|
||||
*
|
||||
* @returns {Promise<BIOMETRIC_TYPE>} Returns a promise with result which depends on device and os.
|
||||
* iPhone X will return 'face' other Android or iOS devices will return 'finger' Android P+ will return 'biometric'
|
||||
*/
|
||||
@Cordova()
|
||||
isAvailable(): Promise<BIOMETRIC_TYPE> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show authentication dialogue and register secret
|
||||
*
|
||||
* @param {FingerprintSecretOptions} options Options for platform specific fingerprint API
|
||||
* @returns {Promise<void>} Returns a promise that resolves when authentication was successful
|
||||
*/
|
||||
@Cordova()
|
||||
registerBiometricSecret(options: FingerprintSecretOptions): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show authentication dialogue and load secret
|
||||
*
|
||||
* @param {FingerprintOptions} options Options for platform specific fingerprint API
|
||||
* @returns {Promise<string>} Returns a promise that resolves when authentication was successful
|
||||
*/
|
||||
@Cordova()
|
||||
loadBiometricSecret(options: FingerprintOptions): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show authentication dialogue
|
||||
*
|
||||
* @param {FingerprintOptions} options Options for platform specific fingerprint API
|
||||
* @returns {Promise<void>} Returns a promise that resolves when authentication was successful
|
||||
*/
|
||||
@Cordova()
|
||||
show(options: FingerprintOptions): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user