Interface ILocation<TEvent, TMobile>

Since

0.1

Device.Location allows capturing location change events on the device. In Android, ACCESS_FINE_LOCATION permission must be taken on run time for 23 api level and above.

Example

import Timer    from '@smartface/native/timer';
import Location from '@smartface/native/device/location';

Location.start(Location.Android.Priority.HIGH_ACCURACY);
Location.onLocationChanged = function(event) {
console.log("Location latitude: " + event.latitude + " Longitude: " + event.longitude);
};

Timer.setTimeout({
delay: 30000,
task: function() { Location.stop() }
});

Type Parameters

Hierarchy

Properties

_nativeObject: any
iOS: { AuthorizationStatus: typeof PermissionIOSAuthorizationStatus }

Type declaration

Android: { Priority: typeof LocationAndroidPriority }

Type declaration

Accessors

  • get nativeObject(): any
  • Returns any

  • set nativeObject(value: any): void
  • Parameters

    • value: any

    Returns void

  • get ios(): TProps["ios"]
  • Returns TProps["ios"]

  • get android(): TProps["android"]
  • Returns TProps["android"]

Methods

  • Executed before everything. This should return nativeObject since it will be assinged directly to nativeObject.

    Parameters

    • Optional params: Partial<Record<string, any>>

    Returns any

  • Parameters

    • Optional params: Partial<Record<string, any>>

    Returns void

  • Parameters

    • props: Partial<{ [key: string]: any }>

    Returns void

  • Parameters

    • props: Partial<{ [key: string]: any }>

    Returns void

  • Starts capturing.For Android, need to define interval & priority which need to be decided wisely; HIGH_ACCURACY, LOW_POWER , NO_POWER or BALANCED. iOS will ignore this priority.

    Method

    start

    Android

    Ios

    Static

    Since

    0.1

    Parameters

    • Optional priority: "HIGH_ACCURACY" | "BALANCED" | "LOW_POWER" | "NO_POWER"
    • Optional interval: number

    Returns void

  • Stops capturing.

    Method

    stop

    Android

    Ios

    Static

    Since

    0.1

    Returns void

  • Gets last known location. The onFailure function will be triggered if no location data has ever been retrieved or unexpected error occurred.

    Method

    getLastKnownLocation

    Android

    Ios

    Static

    Since

    4.0.2

    Parameters

    • onSuccess: ((e: { latitude: number; longitude: number }) => void)
        • (e: { latitude: number; longitude: number }): void
        • Parameters

          • e: { latitude: number; longitude: number }
            • latitude: number
            • longitude: number

          Returns void

    • onFailure: (() => void)
        • (): void
        • Returns void

    Returns void

  • Gets location latitude and longitude. Handles permissions by itself.

    Returns

    It either returns the permission result if permission is denied. If successful, it will return

    See

    Example

    import Location from '@smartface/native/device/location';

    Location.getLocation()
    .then(location => {
    let requestOptions = {
    'url': 'http://maps.googleapis.com/maps/api/geocode/json?latlng=' + location.latitude + ',' + location.longitude + '&sensor=true',
    'method': 'GET'
    };
    })
    .catch(e => {
    // e is in the type of PermissionResult
    console.log("Location cannot be retrieved");
    });

    Parameters

    • Optional shouldRequestPreciseLocation: boolean

      Android only. When set to true, it will request for precise location. When set to false, it will request for approximate location only

    • Optional priority: "HIGH_ACCURACY" | "BALANCED" | "LOW_POWER" | "NO_POWER"

      Sets the priority of the location request. Defaults to BALANCED

    Returns Promise<GetCurrentLocationArgs>

  • Parameters

    • eventName: "locationChanged"
    • callback: ((e: { latitude: number; longitude: number }) => void)
        • (e: { latitude: number; longitude: number }): void
        • Parameters

          • e: { latitude: number; longitude: number }
            • latitude: number
            • longitude: number

          Returns void

    Returns (() => void)

      • (): void
      • Returns void

  • Parameters

    • eventName: "locationChanged"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns (() => void)

      • (): void
      • Returns void

  • Parameters

    • eventName: "locationChanged"
    • callback: ((e: { latitude: number; longitude: number }) => void)
        • (e: { latitude: number; longitude: number }): void
        • Parameters

          • e: { latitude: number; longitude: number }
            • latitude: number
            • longitude: number

          Returns void

    Returns void

  • Parameters

    • eventName: "locationChanged"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

  • Parameters

    • eventName: "locationChanged"
    • e: { latitude: number; longitude: number }
      • latitude: number
      • longitude: number

    Returns void

  • Parameters

    • eventName: "locationChanged"
    • Rest ...args: any[]

    Returns void

  • Parameters

    • eventName: "locationChanged"
    • callback: ((e: { latitude: number; longitude: number }) => void)
        • (e: { latitude: number; longitude: number }): void
        • Parameters

          • e: { latitude: number; longitude: number }
            • latitude: number
            • longitude: number

          Returns void

    Returns (() => void)

      • (): void
      • Returns void

  • Parameters

    • eventName: "locationChanged"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns (() => void)

      • (): void
      • Returns void

  • Parameters

    • eventName: "locationChanged"
    • callback: ((e: { latitude: number; longitude: number }) => void)
        • (e: { latitude: number; longitude: number }): void
        • Parameters

          • e: { latitude: number; longitude: number }
            • latitude: number
            • longitude: number

          Returns void

    Returns void

  • Parameters

    • eventName: "locationChanged"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

  • Parameters

    • eventName: "locationChanged"
    • callback: ((e: { latitude: number; longitude: number }) => void)
        • (e: { latitude: number; longitude: number }): void
        • Parameters

          • e: { latitude: number; longitude: number }
            • latitude: number
            • longitude: number

          Returns void

    Returns void

  • Parameters

    • eventName: "locationChanged"
    • callback: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

Events

onLocationChanged: ((e: { latitude: number; longitude: number }) => void)

Type declaration

    • (e: { latitude: number; longitude: number }): void
    • Callback to capture location events.

      onLocationChanged

      Deprecated

      Android

      Ios

      Since

      0.1

      Example

      import Location from '@smartface/native/device/location';

      Location.on(Location.Events.LocationChanged, (params) => {
      console.info('onLocationChanged', params);
      });

      Parameters

      • e: { latitude: number; longitude: number }
        • latitude: number
        • longitude: number

      Returns void

Generated using TypeDoc