UNPKG

14.9 kBTypeScriptView Raw
1import { Observable } from 'rxjs/Observable';
2export interface EstimoteBeaconRegion {
3 state?: string;
4 major: number;
5 minor: number;
6 identifier?: string;
7 uuid: string;
8}
9/**
10 * @name EstimoteBeacons
11 *
12 * @description
13 * This plugin enables communication between a phone and Estimote Beacons peripherals.
14 *
15 * @interfaces
16 * EstimoteBeaconRegion
17 */
18export declare class EstimoteBeacons {
19 /** Proximity value */
20 static ProximityUnknown: number;
21 /** Proximity value */
22 static ProximityImmediate: number;
23 /** Proximity value */
24 static ProximityNear: number;
25 /** Proximity value */
26 static ProximityFar: number;
27 /** Beacon colour */
28 static BeaconColorUnknown: number;
29 /** Beacon colour */
30 static BeaconColorMintCocktail: number;
31 /** Beacon colour */
32 static BeaconColorIcyMarshmallow: number;
33 /** Beacon colour */
34 static BeaconColorBlueberryPie: number;
35 /**
36 * Beacon colour.
37 */
38 static BeaconColorSweetBeetroot: number;
39 /** Beacon colour */
40 static BeaconColorCandyFloss: number;
41 /** Beacon colour */
42 static BeaconColorLemonTart: number;
43 /** Beacon colour */
44 static BeaconColorVanillaJello: number;
45 /** Beacon colour */
46 static BeaconColorLiquoriceSwirl: number;
47 /** Beacon colour */
48 static BeaconColorWhite: number;
49 /** Beacon colour */
50 static BeaconColorTransparent: number;
51 /** Region state */
52 static RegionStateUnknown: string;
53 /** Region state */
54 static RegionStateOutside: string;
55 /** Region state */
56 static RegionStateInside: string;
57 /**
58 * Ask the user for permission to use location services
59 * while the app is in the foreground.
60 * You need to call this function or requestAlwaysAuthorization
61 * on iOS 8+.
62 * Does nothing on other platforms.
63 *
64 * @usage
65 * ```
66 * EstimoteBeacons.requestWhenInUseAuthorization().then(
67 * () => { console.log('on success'); },
68 * () => { console.log('on error'); }
69 * );
70 * ```
71 *
72 * @see {@link https://community.estimote.com/hc/en-us/articles/203393036-Estimote-SDK-and-iOS-8-Location-Services|Estimote SDK and iOS 8 Location Services}
73 * @returns {Promise<any>}
74 */
75 static requestWhenInUseAuthorization(): Promise<any>;
76 /**
77 * Ask the user for permission to use location services
78 * whenever the app is running.
79 * You need to call this function or requestWhenInUseAuthorization
80 * on iOS 8+.
81 * Does nothing on other platforms.
82 *
83 * @usage
84 * ```
85 * EstimoteBeacons.requestAlwaysAuthorization().then(
86 * () => { console.log('on success'); },
87 * () => { console.log('on error'); }
88 * );
89 * ```
90 *
91 * @see {@link https://community.estimote.com/hc/en-us/articles/203393036-Estimote-SDK-and-iOS-8-Location-Services|Estimote SDK and iOS 8 Location Services}
92 * @returns {Promise<any>}
93 */
94 static requestAlwaysAuthorization(): Promise<any>;
95 /**
96 * Get the current location authorization status.
97 * Implemented on iOS 8+.
98 * Does nothing on other platforms.
99 *
100 * @usage
101 * ```
102 * EstimoteBeacons.authorizationStatus().then(
103 * (result) => { console.log('Location authorization status: ' + result); },
104 * (errorMessage) => { console.log('Error: ' + errorMessage); }
105 * );
106 * ```
107 *
108 * @see {@link https://community.estimote.com/hc/en-us/articles/203393036-Estimote-SDK-and-iOS-8-Location-Services|Estimote SDK and iOS 8 Location Services}
109 * @returns {Promise<any>}
110 */
111 static authorizationStatus(): Promise<any>;
112 /**
113 * Start advertising as a beacon.
114 *
115 * @usage
116 * ```
117 * EstimoteBeacons.startAdvertisingAsBeacon('B9407F30-F5F8-466E-AFF9-25556B57FE6D', 1, 1, 'MyRegion')
118 * .then(() => { console.log('Beacon started'); });
119 * setTimeout(() => {
120 * EstimoteBeacons.stopAdvertisingAsBeacon().then((result) => { console.log('Beacon stopped'); });
121 * }, 5000);
122 * ```
123 * @param uuid {string} UUID string the beacon should advertise (mandatory).
124 * @param major {number} Major value to advertise (mandatory).
125 * @param minor {number} Minor value to advertise (mandatory).
126 * @param regionId {string} Identifier of the region used to advertise (mandatory).
127 * @returns {Promise<any>}
128 */
129 static startAdvertisingAsBeacon(uuid: string, major: number, minor: number, regionId: string): Promise<any>;
130 /**
131 * Stop advertising as a beacon.
132 *
133 * @usage
134 * ```
135 * EstimoteBeacons.startAdvertisingAsBeacon('B9407F30-F5F8-466E-AFF9-25556B57FE6D', 1, 1, 'MyRegion')
136 * .then(() => { console.log('Beacon started'); });
137 * setTimeout(() => {
138 * EstimoteBeacons.stopAdvertisingAsBeacon().then((result) => { console.log('Beacon stopped'); });
139 * }, 5000);
140 * ```
141 * @returns {Promise<any>}
142 */
143 static stopAdvertisingAsBeacon(): Promise<any>;
144 /**
145 * Enable analytics.
146 *
147 * @see {@link http://estimote.github.io/iOS-SDK/Classes/ESTConfig.html|Further details}
148 *
149 * @usage
150 * ```
151 * EstimoteBeacons.enableAnalytics(true).then(() => { console.log('Analytics enabled'); });
152 * ```
153 * @param enable {number} Boolean value to turn analytics on or off (mandatory).
154 * @returns {Promise<any>}
155 */
156 static enableAnalytics(enable: boolean): Promise<any>;
157 /**
158 * Test if analytics is enabled.
159 *
160 * @see {@link http://estimote.github.io/iOS-SDK/Classes/ESTConfig.html|Further details}
161 *
162 * @usage
163 * ```
164 * EstimoteBeacons.isAnalyticsEnabled().then((enabled) => { console.log('Analytics enabled: ' + enabled); });
165 * ```
166 * @returns {Promise<any>}
167 */
168 static isAnalyticsEnabled(): Promise<any>;
169 /**
170 * Test if App ID and App Token is set.
171 *
172 * @see {@link http://estimote.github.io/iOS-SDK/Classes/ESTConfig.html|Further details}
173 *
174 * @usage
175 * ```
176 * EstimoteBeacons.isAuthorized().then((isAuthorized) => { console.log('App ID and App Token is set: ' + isAuthorized); });
177 * ```
178 * @returns {Promise<any>}
179 */
180 static isAuthorized(): Promise<any>;
181 /**
182 * Set App ID and App Token.
183 *
184 * @see {@link http://estimote.github.io/iOS-SDK/Classes/ESTConfig.html|Further details}
185 *
186 * @usage
187 * ```
188 * EstimoteBeacons.setupAppIDAndAppToken('MyAppID', 'MyAppToken').then(() => { console.log('AppID and AppToken configured!'); });
189 * ```
190 * @param appID {string} The App ID (mandatory).
191 * @param appToken {string} The App Token (mandatory).
192 * @returns {Promise<any>}
193 */
194 static setupAppIDAndAppToken(appID: string, appToken: string): Promise<any>;
195 /**
196 * Start scanning for all nearby beacons using CoreBluetooth (no region object is used).
197 * Available on iOS.
198 *
199 * @usage
200 * ```
201 * EstimoteBeacons.startEstimoteBeaconDiscovery().subscribe(beacons => {
202 * console.log(JSON.stringify(beacons));
203 * });
204 * setTimeout(() => {
205 * EstimoteBeacons.stopEstimoteBeaconDiscovery().then(() => { console.log('scan stopped'); });
206 * }, 5000);
207 * ```
208 * @returns {Observable<any>} Returns an Observable that notifies of each beacon discovered.
209 */
210 static startEstimoteBeaconDiscovery(): Observable<any>;
211 /**
212 * Stop CoreBluetooth scan. Available on iOS.
213 *
214 * @usage
215 * ```
216 * EstimoteBeacons.startEstimoteBeaconDiscovery().subscribe(beacons => {
217 * console.log(JSON.stringify(beacons));
218 * });
219 * setTimeout(() => {
220 * EstimoteBeacons.stopEstimoteBeaconDiscovery().then(() => { console.log('scan stopped'); });
221 * }, 5000);
222 * ```
223 * @returns {Promise<any>}
224 */
225 static stopEstimoteBeaconDiscovery(): Promise<any>;
226 /**
227 * Start ranging beacons. Available on iOS and Android.
228 *
229 * @usage
230 * ```
231 * let region: EstimoteBeaconRegion = {} // Empty region matches all beacons.
232 * EstimoteBeacons.startRangingBeaconsInRegion(region).subscribe(info => {
233 * console.log(JSON.stringify(info));
234 * });
235 * setTimeout(() => {
236 * EstimoteBeacons.stopRangingBeaconsInRegion(region).then(() => { console.log('scan stopped'); });
237 * }, 5000);
238 * ```
239 * @param region {EstimoteBeaconRegion} Dictionary with region properties (mandatory).
240 * @returns {Observable<any>} Returns an Observable that notifies of each beacon discovered.
241 */
242 static startRangingBeaconsInRegion(region: EstimoteBeaconRegion): Observable<any>;
243 /**
244 * Stop ranging beacons. Available on iOS and Android.
245 *
246 * @usage
247 * ```
248 * let region: EstimoteBeaconRegion = {} // Empty region matches all beacons.
249 * EstimoteBeacons.startRangingBeaconsInRegion(region).subscribe(info => {
250 * console.log(JSON.stringify(info));
251 * });
252 * setTimeout(() => {
253 * EstimoteBeacons.stopRangingBeaconsInRegion(region).then(() => { console.log('scan stopped'); });
254 * }, 5000);
255 * ```
256 * @param region {EstimoteBeaconRegion} Dictionary with region properties (mandatory).
257 * @returns {Promise<any>}
258 */
259 static stopRangingBeaconsInRegion(region: EstimoteBeaconRegion): Promise<any>;
260 /**
261 * Start ranging secure beacons. Available on iOS.
262 * This function has the same parameters/behaviour as
263 * {@link EstimoteBeacons.startRangingBeaconsInRegion}.
264 * To use secure beacons set the App ID and App Token using
265 * {@link EstimoteBeacons.setupAppIDAndAppToken}.
266 * @returns {Observable<any>}
267 */
268 static startRangingSecureBeaconsInRegion(region: EstimoteBeaconRegion): Observable<any>;
269 /**
270 * Stop ranging secure beacons. Available on iOS.
271 * This function has the same parameters/behaviour as
272 * {@link EstimoteBeacons.stopRangingBeaconsInRegion}.
273 * @returns {Promise<any>}
274 */
275 static stopRangingSecureBeaconsInRegion(region: EstimoteBeaconRegion): Promise<any>;
276 /**
277 * Start monitoring beacons. Available on iOS and Android.
278 *
279 * @usage
280 * ```
281 * let region: EstimoteBeaconRegion = {} // Empty region matches all beacons.
282 * EstimoteBeacons.startMonitoringForRegion(region).subscribe(state => {
283 * console.log('Region state: ' + JSON.stringify(state));
284 * });
285 * ```
286 * @param region {EstimoteBeaconRegion} Dictionary with region properties (mandatory).
287 * @param [notifyEntryStateOnDisplay=false] {boolean} Set to true to detect if you
288 * are inside a region when the user turns display on, see
289 * {@link https://developer.apple.com/library/prerelease/ios/documentation/CoreLocation/Reference/CLBeaconRegion_class/index.html#//apple_ref/occ/instp/CLBeaconRegion/notifyEntryStateOnDisplay|iOS documentation}
290 * for further details (optional, defaults to false, iOS only).
291 * @returns {Observable<any>} Returns an Observable that notifies of each region state discovered.
292 */
293 static startMonitoringForRegion(region: EstimoteBeaconRegion, notifyEntryStateOnDisplay: boolean): Observable<any>;
294 /**
295 * Stop monitoring beacons. Available on iOS and Android.
296 *
297 * @usage
298 * ```
299 * let region: EstimoteBeaconRegion = {} // Empty region matches all beacons.
300 * EstimoteBeacons.stopMonitoringForRegion(region).then(() => { console.log('monitoring is stopped'); });
301 * ```
302 * @param region {EstimoteBeaconRegion} Dictionary with region properties (mandatory).
303 * @returns {Promise<any>}
304 */
305 static stopMonitoringForRegion(region: EstimoteBeaconRegion): Promise<any>;
306 /**
307 * Start monitoring secure beacons. Available on iOS.
308 * This function has the same parameters/behaviour as
309 * EstimoteBeacons.startMonitoringForRegion.
310 * To use secure beacons set the App ID and App Token using
311 * {@link EstimoteBeacons.setupAppIDAndAppToken}.
312 * @see {@link EstimoteBeacons.startMonitoringForRegion}
313 * @param region {EstimoteBeaconRegion} Region
314 * @param notifyEntryStateOnDisplay {boolean}
315 * @returns {Observable<any>}
316 */
317 static startSecureMonitoringForRegion(region: EstimoteBeaconRegion, notifyEntryStateOnDisplay: boolean): Observable<any>;
318 /**
319 * Stop monitoring secure beacons. Available on iOS.
320 * This function has the same parameters/behaviour as
321 * {@link EstimoteBeacons.stopMonitoringForRegion}.
322 * @param region {EstimoteBeaconRegion} Region
323 * @returns {Promise<any>}
324 */
325 static stopSecureMonitoringForRegion(region: EstimoteBeaconRegion): Promise<any>;
326 /**
327 * Connect to Estimote Beacon. Available on Android.
328 *
329 * @usage
330 * ```
331 * EstimoteBeacons.connectToBeacon(FF:0F:F0:00:F0:00);
332 * ```
333 * ```
334 * EstimoteBeacons.connectToBeacon({
335 * proximityUUID: '000000FF-F00F-0FF0-F000-000FF0F00000',
336 * major: 1,
337 * minor: 1
338 * });
339 * ```
340 * @param beacon {Beacon} Beacon to connect to.
341 * @returns {Promise<any>}
342 */
343 static connectToBeacon(beacon: any): Promise<any>;
344 /**
345 * Disconnect from connected Estimote Beacon. Available on Android.
346 *
347 * @usage
348 * ```
349 * EstimoteBeacons.disconnectConnectedBeacon();
350 * ```
351 * @returns {Promise<any>}
352 */
353 static disconnectConnectedBeacon(): Promise<any>;
354 /**
355 * Write proximity UUID to connected Estimote Beacon. Available on Android.
356 *
357 * @usage
358 * ```
359 * // Example that writes constant ESTIMOTE_PROXIMITY_UUID
360 * EstimoteBeacons.writeConnectedProximityUUID(ESTIMOTE_PROXIMITY_UUID);
361 *
362 * @param uuid {string} String to write as new UUID
363 * @returns {Promise<any>}
364 */
365 static writeConnectedProximityUUID(uuid: any): Promise<any>;
366 /**
367 * Write major to connected Estimote Beacon. Available on Android.
368 *
369 * @usage
370 * ```
371 * // Example that writes 1
372 * EstimoteBeacons.writeConnectedMajor(1);
373 *
374 * @param major {number} number to write as new major
375 * @returns {Promise<any>}
376 */
377 static writeConnectedMajor(major: number): Promise<any>;
378 /**
379 * Write minor to connected Estimote Beacon. Available on Android.
380 *
381 * @usage
382 * ```
383 * // Example that writes 1
384 * EstimoteBeacons.writeConnectedMinor(1);
385 *
386 * @param minor {number} number to write as new minor
387 * @returns {Promise<any>}
388 */
389 static writeConnectedMinor(minor: number): Promise<any>;
390}