Package | com.distriqt.extension.location |
Class | public class LocationRequest |
Inheritance | LocationRequest ![]() |
Defines options for location monitoring requests for the different platforms, such as intervals, accuracy and priority.
Property | Defined By | ||
---|---|---|---|
accuracy : String = nearestTenMeters
The desired accuracy level to use when monitoring the device location. | LocationRequest | ||
duration : int = -1
Sets the duration (in milliseconds) this request will continue before being automatically removed
Defaults to -1, which represents an unlimited duration. | LocationRequest | ||
fastestInterval : int = -1 Deprecated: No longer supported
Explicitly set the fastest interval for location updates, in milliseconds. | LocationRequest | ||
interval : int = 5000
Set the desired interval for active location updates, in milliseconds. | LocationRequest | ||
maxWaitTime : int = -1 Deprecated: No longer supported
Sets the maximum wait time in milliseconds for location updates. | LocationRequest | ||
persistInBackground : Boolean [read-only]
Since Android O, in order to receive consistent updates while your application
is in the background a foreground service and corresponding notification must
be used. | LocationRequest | ||
persistInBackgroundNotificationText : String [read-only]
Notification text for the foreground service notification
| LocationRequest | ||
priority : int = 1
Set the priority of the request. | LocationRequest | ||
updateData : String
Additional data that will be sent with every update to the updataUrl. | LocationRequest | ||
updateMinimumInterval : int = 0
The minimum interval between updates to the server in milliseconds. | LocationRequest | ||
updateUrl : String
This is a url that the extension will attempt to send the location information
to whenever a location update is received. | LocationRequest |
Method | Defined By | ||
---|---|---|---|
Constructor
| LocationRequest | ||
setAccuracy(accuracy:String):LocationRequest | LocationRequest | ||
setDuration(duration:int):LocationRequest | LocationRequest | ||
setFastestInterval(fastestInterval:int):LocationRequest | LocationRequest | ||
setInterval(interval:int):LocationRequest | LocationRequest | ||
setMaxWaitTime(maxWaitTime:int):LocationRequest | LocationRequest | ||
setPersistInBackground(persistInBackground:Boolean = true, notificationText:String = null):LocationRequest
Sets the value of persistInBackground
| LocationRequest | ||
setPriority(priority:int):LocationRequest | LocationRequest | ||
setServerUpdate(url:String, data:String, minimumInterval:int):LocationRequest | LocationRequest |
Constant | Defined By | ||
---|---|---|---|
ACCURACY_BEST : String = best [static]
| LocationRequest | ||
ACCURACY_BEST_FOR_NAVIGATION : String = bestForNavigation [static]
| LocationRequest | ||
ACCURACY_HUNDRED_METERS : String = hundredMeters [static]
| LocationRequest | ||
ACCURACY_KILOMETER : String = kilometer [static]
| LocationRequest | ||
ACCURACY_NEAREST_TEN_METERS : String = nearestTenMeters [static]
| LocationRequest | ||
ACCURACY_THREE_KILOMETERS : String = threeKilometers [static]
| LocationRequest | ||
PRIORITY_BALANCED_POWER_ACCURACY : int = 1 [static]
To request "block" level accuracy. | LocationRequest | ||
PRIORITY_HIGH_ACCURACY : int = 0 [static]
To request the most accurate locations available. | LocationRequest | ||
PRIORITY_LOW_POWER : int = 2 [static]
To request "city" level accuracy. | LocationRequest | ||
PRIORITY_NO_POWER : int = 3 [static]
To request the best accuracy possible with zero additional power consumption. | LocationRequest |
accuracy | property |
public var accuracy:String = nearestTenMeters
The desired accuracy level to use when monitoring the device location.
Use with an accuracy constant such as ACCURACY_BEST_FOR_NAVIGATION
. No other values are accepted.
The location service will try its best to achieve your desired accuracy. However, it is not guaranteed. To optimize power performance, be sure to specify an appropriate accuracy for your usage scenario (eg, use a large accuracy value when only a coarse location is needed). More precise locations generally require higher battery usage.
Support: iOS only
duration | property |
public var duration:int = -1
Sets the duration (in milliseconds) this request will continue before being automatically removed
Defaults to -1
, which represents an unlimited duration.
Support: Android only
fastestInterval | property |
public var fastestInterval:int = -1
Explicitly set the fastest interval for location updates, in milliseconds.
This controls the fastest rate at which your application will
receive location updates, which might be faster than interval
in some situations (for example, if other applications are triggering location updates).
This allows your application to passively acquire locations at a rate faster than it actively acquires locations, saving power.
Unlike interval
, this parameter is exact.
Your application will never receive updates faster than this value.
If you don't set this value, a fastest interval will be selected for you. It will be a value faster than your active interval.
An interval of 0 is allowed, but not recommended, since location updates may be extremely fast on future implementations.
Support: Android only
interval | property |
public var interval:int = 5000
Set the desired interval for active location updates, in milliseconds.
The location client will actively try to obtain location updates for your application at this interval, so it has a direct influence on the amount of power used by your application. Choose your interval wisely.
This interval is inexact.
You may not receive updates at all (if no location sources are available),
or you may receive them slower than requested.
You may also receive them faster than requested
(if other applications are requesting location at a faster interval).
The fastest rate that that you will receive updates can be
controlled with fastestInterval
.
By default this fastest rate is 6x the interval frequency.
Applications with only the coarse location permission may have their interval silently throttled.
An interval of 0 is allowed, but not recommended, since location updates may be extremely fast on future implementations.
Support: Android only
maxWaitTime | property |
public var maxWaitTime:int = -1
Sets the maximum wait time in milliseconds for location updates.
If you pass a value at least 2x larger than the interval specified
with interval
, then location delivery may be delayed and
multiple locations can be delivered at once.
Locations are determined at the interval
rate, but can
be delivered in batch after the interval you set in this method.
This can consume less battery and give more accurate locations,
depending on the device's hardware capabilities.
You should set this value to be as large as possible for your
needs if you don't need immediate location delivery.
Support: Android only
persistInBackground | property |
persistInBackground:Boolean
[read-only]
Since Android O, in order to receive consistent updates while your application
is in the background a foreground service and corresponding notification must
be used. When this is true
the extension will use a foreground service
to perform location monitoring and updates and handle display of the required notification
(required by Android for foreground services).
If you require consistent updates to the location while your application is in the background
you must set this to true
using the setPersistInBackground()
function.
If this is false then your applications location updates may be throttled when in the background and batched together at least frequent intervals ignoring any options specified in this request.
Android only, ignored on iOS public function get persistInBackground():Boolean
See also
persistInBackgroundNotificationText | property |
persistInBackgroundNotificationText:String
[read-only] Notification text for the foreground service notification
public function get persistInBackgroundNotificationText():String
priority | property |
public var priority:int = 1
Set the priority of the request.
Use with a priority constant such as PRIORITY_HIGH_ACCURACY
. No other values are accepted.
The priority of the request is a strong hint for which location sources to use.
For example, PRIORITY_HIGH_ACCURACY
is more likely to use GPS,
and PRIORITY_BALANCED_POWER_ACCURACY
is more likely to use WIFI and
Cell tower positioning, but it also depends on many other factors
(such as which sources are available) and is implementation dependent.
On iOS these values control whether the location services use the significant location updates or the standard and significant locations updates.
PRIORITY_NO_POWER
or PRIORITY_LOW_POWER
:
ALWAYS
permission: will use significant updatesIN_USE
permission: will use standard updatesPRIORITY_BALANCED_POWER_ACCURACY
or PRIORITY_HIGH_ACCURACY
:
ALWAYS
permission: will use significant + standard updatesIN_USE
permission: will use standard updatesSupport:
PRIORITY_
values in this class for details.updateData | property |
public var updateData:String
Additional data that will be sent with every update to the updataUrl
.
This can be used to identify this device or user in your server code.
updateMinimumInterval | property |
public var updateMinimumInterval:int = 0
The minimum interval between updates to the server in milliseconds.
This allows you to limit the request frequency to your server. It is not a guaranteed interval but the minimum interval that will be between sequential updates from a device. This interval may be longer if the device does not receive a location update during that interval.
If 0
, then every location update will be sent.
updateUrl | property |
public var updateUrl:String
This is a url that the extension will attempt to send the location information to whenever a location update is received.
This can be useful in situations where the application is running in the background (or even terminated on Android) the update url will still be contacted where AS3 code may not run.
The payload sent to the url takes the following form:
{ "location": { "altitude": 0.00, "latitude": 0.00, "longitude": 0.00, "timestamp": 000000000 }, "data": "YOUR_CUSTOM_DATA_STRING" }
LocationRequest | () | Constructor |
public function LocationRequest()
Constructor
setAccuracy | () | method |
public function setAccuracy(accuracy:String):LocationRequest
Parameters
accuracy:String |
LocationRequest — LocationRequest instance for chaining calls
|
See also
setDuration | () | method |
public function setDuration(duration:int):LocationRequest
Parameters
duration:int |
LocationRequest — LocationRequest instance for chaining calls
|
See also
setFastestInterval | () | method |
public function setFastestInterval(fastestInterval:int):LocationRequest
Parameters
fastestInterval:int |
LocationRequest — LocationRequest instance for chaining calls
|
See also
setInterval | () | method |
public function setInterval(interval:int):LocationRequest
Parameters
interval:int |
LocationRequest — LocationRequest instance for chaining calls
|
See also
setMaxWaitTime | () | method |
public function setMaxWaitTime(maxWaitTime:int):LocationRequest
Parameters
maxWaitTime:int |
LocationRequest — LocationRequest instance for chaining calls
|
See also
setPersistInBackground | () | method |
public function setPersistInBackground(persistInBackground:Boolean = true, notificationText:String = null):LocationRequest
Sets the value of persistInBackground
Parameters
persistInBackground:Boolean (default = true ) — Whether to persist location updates in the background
| |
notificationText:String (default = null ) — The text displayed in the notification
|
LocationRequest — LocationRequest instance for chaining calls
|
See also
setPriority | () | method |
public function setPriority(priority:int):LocationRequest
Parameters
priority:int |
LocationRequest — LocationRequest instance for chaining calls
|
See also
setServerUpdate | () | method |
public function setServerUpdate(url:String, data:String, minimumInterval:int):LocationRequest
Parameters
url:String | |
data:String | |
minimumInterval:int |
LocationRequest — LocationRequest instance for chaining calls
|
See also
ACCURACY_BEST | Constant |
public static const ACCURACY_BEST:String = best
ACCURACY_BEST_FOR_NAVIGATION | Constant |
public static const ACCURACY_BEST_FOR_NAVIGATION:String = bestForNavigation
ACCURACY_HUNDRED_METERS | Constant |
public static const ACCURACY_HUNDRED_METERS:String = hundredMeters
ACCURACY_KILOMETER | Constant |
public static const ACCURACY_KILOMETER:String = kilometer
ACCURACY_NEAREST_TEN_METERS | Constant |
public static const ACCURACY_NEAREST_TEN_METERS:String = nearestTenMeters
ACCURACY_THREE_KILOMETERS | Constant |
public static const ACCURACY_THREE_KILOMETERS:String = threeKilometers
PRIORITY_BALANCED_POWER_ACCURACY | Constant |
public static const PRIORITY_BALANCED_POWER_ACCURACY:int = 1
To request "block" level accuracy.
Block level accuracy is considered to be about 100 meter accuracy. Using a coarse accuracy such as this often consumes less power.
On iOS this will use both standard and significant update modes. If you only have the "in-use" permission then you will not get significant updates but only the standard updates.
PRIORITY_HIGH_ACCURACY | Constant |
public static const PRIORITY_HIGH_ACCURACY:int = 0
To request the most accurate locations available.
This will return the finest location available.
On iOS this will use both standard and significant update modes. If you only have the "in-use" permission then you will not get significant updates but only the standard updates.
PRIORITY_LOW_POWER | Constant |
public static const PRIORITY_LOW_POWER:int = 2
To request "city" level accuracy.
City level accuracy is considered to be about 10km accuracy. Using a coarse accuracy such as this often consumes less power.
On iOS this will use the significant update mode only if you have the always permission otherwise it will use the standard updates.
PRIORITY_NO_POWER | Constant |
public static const PRIORITY_NO_POWER:int = 3
To request the best accuracy possible with zero additional power consumption.
No locations will be returned unless a different client has requested location updates in which case this request will act as a passive listener to those locations.
On iOS this will use the significant update mode only if you have the always permission otherwise it will use the standard updates.