UNPKG

3.89 kBJavaScriptView Raw
1"use strict";
2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6 return c > 3 && r && Object.defineProperty(target, key, r), r;
7};
8var plugin_1 = require('./plugin');
9/**
10 * @name LocationAccuracy
11 * @description
12 * This Cordova/Phonegap plugin for Android and iOS to request enabling/changing of Location Services by triggering a native dialog from within the app, avoiding the need for the user to leave your app to change location settings manually.
13 *
14 * @usage
15 * ```
16 * import { LocationAccuracy } from 'ionic-native';
17 *
18 * LocationAccuracy.canRequest().then((canRequest: boolean) => {
19 *
20 * if(canRequest) {
21 * // the accuracy option will be ignored by iOS
22 * LocationAccuracy.request(LocationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY).then(
23 * () => console.log('Request successful'),
24 * error => console.log('Error requesting location permissions', error)
25 * );
26 * }
27 *
28 * });
29 *
30 * ```
31 */
32var LocationAccuracy = (function () {
33 function LocationAccuracy() {
34 }
35 /**
36 * Indicates if you can request accurate location
37 * @returns {Promise<boolean>} Returns a promise that resovles with a boolean that indicates if you can request accurate location
38 */
39 LocationAccuracy.canRequest = function () { return; };
40 /**
41 * Indicates if a request is currently in progress
42 * @returns {Promise<boolean>} Returns a promise that resolves with a boolean that indicates if a request is currently in progress
43 */
44 LocationAccuracy.isRequesting = function () { return; };
45 /**
46 * Requests accurate location
47 * @param accuracy {number} Accuracy, from 0 to 4. You can use the static properties of this class that start with REQUEST_PRIORITY_
48 * @returns {Promise<any>} Returns a promise that resolves on success and rejects if an error occurred
49 */
50 LocationAccuracy.request = function (accuracy) { return; };
51 LocationAccuracy.REQUEST_PRIORITY_NO_POWER = 0;
52 LocationAccuracy.REQUEST_PRIORITY_LOW_POWER = 1;
53 LocationAccuracy.REQUEST_PRIORITY_BALANCED_POWER_ACCURACY = 2;
54 LocationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY = 3;
55 LocationAccuracy.SUCCESS_SETTINGS_SATISFIED = 0;
56 LocationAccuracy.SUCCESS_USER_AGREED = 1;
57 LocationAccuracy.ERROR_ALREADY_REQUESTING = -1;
58 LocationAccuracy.ERROR_INVALID_ACTION = 0;
59 LocationAccuracy.ERROR_INVALID_ACCURACY = 1;
60 LocationAccuracy.ERROR_EXCEPTION = 1;
61 LocationAccuracy.ERROR_CANNOT_CHANGE_ACCURACY = 3;
62 LocationAccuracy.ERROR_USER_DISAGREED = 4;
63 LocationAccuracy.ERROR_GOOGLE_API_CONNECTION_FAILED = 4;
64 __decorate([
65 plugin_1.Cordova()
66 ], LocationAccuracy, "canRequest", null);
67 __decorate([
68 plugin_1.Cordova()
69 ], LocationAccuracy, "isRequesting", null);
70 __decorate([
71 plugin_1.Cordova({ callbackOrder: 'reverse' })
72 ], LocationAccuracy, "request", null);
73 LocationAccuracy = __decorate([
74 plugin_1.Plugin({
75 pluginName: 'LocationAccuracy',
76 plugin: 'cordova-plugin-request-location-accuracy',
77 pluginRef: 'cordova.plugins.locationAccuracy',
78 repo: 'https://github.com/dpa99c/cordova-plugin-request-location-accuracy'
79 })
80 ], LocationAccuracy);
81 return LocationAccuracy;
82}());
83exports.LocationAccuracy = LocationAccuracy;
84//# sourceMappingURL=location-accuracy.js.map
\No newline at end of file