Options
All
  • Public
  • Public/Protected
  • All
Menu

@okhi/react-native-core

Core package for the OkHi react native suite of libraries

Installation

npm install @okhi/react-native-core

Usage

import {
  isGooglePlayServicesAvailable,
  isLocationPermissionGranted,
  isLocationServicesEnabled,
  requestEnableGooglePlayServices,
  requestEnableLocationServices,
  requestLocationPermission,
  isBackgroundLocationPermissionGranted,
  requestBackgroundLocationPermission,
} from '@okhi/react-native-core';

async function checkPermissions() {
  if (!(await isGooglePlayServicesAvailable())) {
    await requestEnableGooglePlayServices(); // resolves true | false
  }

  if (!(await isLocationPermissionGranted())) {
    await requestLocationPermission(); // resolves true | false
  }

  if (!(await isLocationServicesEnabled())) {
    await requestEnableLocationServices(); // resolves true | false
  }

  if (!(await isBackgroundLocationPermissionGranted())) {
    await requestBackgroundLocationPermission(); // resolves true | false
  }
}

Documentation

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Index

Variables

Const OkHiMode

OkHiMode: { PROD: string; SANDBOX: string } = Object.freeze({SANDBOX: 'sandbox',PROD: 'prod',})

Sets the current mode that you'd like to use OkHi's services.

Type declaration

  • PROD: string
  • SANDBOX: string

Functions

Const isBackgroundLocationPermissionGranted

  • isBackgroundLocationPermissionGranted(): Promise<boolean>
  • Checks whether background location permission is granted.

    Returns Promise<boolean>

    A promise that resolves to a boolean value indicating whether or not the permission is granted.

Const isGooglePlayServicesAvailable

  • isGooglePlayServicesAvailable(): Promise<boolean>
  • Checks whether Google Play Service is available and turned on.

    Returns Promise<boolean>

    A promise that resolves to a boolean value indicating whether or not the the service is available.

Const isLocationPermissionGranted

  • isLocationPermissionGranted(): Promise<boolean>
  • Checks whether foreground location permission is granted.

    Returns Promise<boolean>

    A promise that resolves to a boolean value indicating whether or not the permission is granted.

Const isLocationServicesEnabled

  • isLocationServicesEnabled(): Promise<boolean>
  • Checks whether location services are available and turned on.

    Returns Promise<boolean>

    A promise that resolves to a boolean value indicating whether or not the the service is available.

Const openLocationServicesSettings

  • openLocationServicesSettings(): Promise<void>
  • Launches the user's devices location settings, enabling them to turn on location services.

    Returns Promise<void>

Const requestBackgroundLocationPermission

  • requestBackgroundLocationPermission(): Promise<boolean>
  • Requests background location permission from the user.

    Returns Promise<boolean>

    A promise that resolves to a boolean value indicating whether or not the the permission is granted.

Const requestEnableGooglePlayServices

  • requestEnableGooglePlayServices(): Promise<boolean>
  • Launches the device's Google Play Services settings, prompting the user to enable the service.

    Returns Promise<boolean>

    A promise that resolves to a boolean value indicating whether or not the the service is available.

Const requestEnableLocationServices

  • requestEnableLocationServices(): Promise<boolean>
  • Displays an in app native modal, that prompts the user to enable location services.

    Returns Promise<boolean>

    A promise that resolves to a boolean value indicating whether or not the the service is available.

Const requestLocationPermission

  • requestLocationPermission(): Promise<boolean>
  • Requests foreground location permission from the user.

    Returns Promise<boolean>

    A promise that resolves to a boolean value indicating whether or not the the permission is granted.

Legend

  • Constructor
  • Property
  • Property
  • Inherited property
  • Static property

Generated using TypeDoc