Socket
Socket
Sign inDemoInstall

nativescript-advanced-permissions

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nativescript-advanced-permissions

Permissions for both Android and IOS.


Version published
Weekly downloads
14
decreased by-51.72%
Maintainers
1
Install size
67.5 kB
Created
Weekly downloads
 

Readme

Source

nativescript-advanced-permissions

npm version

Build Status

This Plugin is a wrap around Nathanael's nativescript-permissions plugin, while providing IOS Permissions with a matching API.

Installation

Describe your plugin installation steps. Ideally it would be something like:

tns plugin add nativescript-advanced-permissions

Usage

Right now to request the Camera Permissions, we use it like this

    
    import { hasCameraPermission, requestCameraPermission } from 'nativescript-advanced-permissions/camera';

    // also supports 'nativescript-advanced-permissions/files';
    // also supports 'nativescript-advanced-permissions/calendar';
    // also supports 'nativescript-advanced-permissions/location';


    if( !hasCameraPermission() ) {
        requestCameraPermission().then((hasPermission) => {
            if( hasPermission ) {
                // do something cool
            } else {
                // don't do something
            }
        });
    }

API

this plugin has been split into smaller 'sub-modules', which when use give access to the specified permissions.

the sub-modules that we currently include are : files, calendar, location, camera

and for each sub-module we follow the same naming convention: requestXPermission/hasXPermission where x is the capitalised sub-module name.

Camera Module

Usage
    import { hasCameraPermission, requestCameraPermission } from 'nativescript-advanced-permissions/camera';

    if( !hasCameraPermission() ) {
        requestCameraPermission().then((hasPermission) => {
            if( hasPermission ) {
                // do something cool
            } else {
                // don't do something
            }
        });
    }
API
FunctionReturn TypeDescription
hasCameraPermission()booleanreturns whether or not the application has the permissions to use the camera
requestCameraPermission()Promiserequests the user to allow Camera Permissions, returns a truthy promise if they do, and returns falsy if they don't

Location Module

Usage
    import { goToAppSettings } from 'nativescript-advanced-permissions/core';
    import { hasLocationPermission, requestLocationPermission, isLocationEnabled } from 'nativescript-advanced-permissions/location';

    if ( isLocationEnabled() ) {

        if( !hasCameraPermission() ) {
            requestCameraPermission().then((hasPermission) => {
                if( hasPermission ) {
                    // do something cool
                } else {
                    // don't do something
                }
            });
        }

    } else {
        // tell the user to enable Location Services.
        alert('Please Enable Location Settings...').then(() => goToAppSettings());
    }
API
FunctionReturn TypeDescription
hasLocationPermission()booleanreturns whether or not the application has the permissions to use the Location Services
requestLocationPermission()Promiserequests the user to allow Location Permissions, returns a truthy promise if they do, and returns falsy if they don't
isLocationEnabled()booleanreturns whether or not the location services are enabled on device.

Calendar Module

Usage
    import { hasCalendarPermission, requestCalendarPermission } from 'nativescript-advanced-permissions/calendar';
        if( !hasCalendarPermission() ) {
            requestCalendarPermission().then((hasPermission) => {
                if( hasPermission ) {
                    // do something cool
                } else {
                    // don't do something
                }
            });
        }
API
FunctionReturn TypeDescription
hasCalendarPermission()booleanreturns whether or not the application has the permissions to use the Calendar
requestCalendarPermission()Promiserequests the user to allow Calendar Permissions, returns a truthy promise if they do, and returns falsy if they don't

License

Apache License Version 2.0, January 2004

Special Thanks!

Thanks to the genius Nathaniel Anderson for the Android Permissions Plugin, which i make use of in this plugin Nativescript-Permissions

Keywords

FAQs

Last updated on 28 Aug 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc