Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-imagepicker

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-imagepicker

A plugin for the NativeScript framework implementing multiple image picker

  • 3.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
50
decreased by-45.05%
Maintainers
2
Weekly downloads
 
Created
Source

NativeScript Image Picker apple android

npm npm Build Status

Imagepicker plugin supporting both single and multiple selection.
Plugin supports iOS8+ and uses Photos Framework.
For Android it uses Intents to open the stock images or file pickers. For Android 6 (API 23) and above the permissions to read file storage should be explicitly required. See demo for implementation details.

Installation

In Command prompt / Terminal navigate to your application root folder and run:

tns plugin add nativescript-imagepicker

Usage

The best way to explore the usage of the plugin is to inspect both demo apps in the plugin repository. In demo folder you can find the usage of the plugin for TypeScript non-Angular application. Refer to demo/app/main-page.ts. In demo-angular is the usage in an Angular app. Refer to demo-angular/app/app.component.ts.

In addition to the plugin usage, both apps are webpack configured.

In short here are the steps:

Import the plugin

TypeScript

import * as imagepicker from "nativescript-imagepicker";

Javascript

var imagepicker = require("nativescript-imagepicker");

Create imagepicker

Create imagepicker in single or multiple mode to specifiy if the imagepicker will be used for single or multiple selection of images

TypeScript

let context = imagepicker.create({
    mode: "single" // use "multiple" for multiple selection
});

Javascript

var context = imagepicker.create({ mode: "single" }); // use "multiple" for multiple selection

Request permissions, show the images list and process the selection

context
    .authorize()
    .then(function() {
        return context.present();
    })
    .then(function(selection) {
        selection.forEach(function(selected) {
            // process the selected image
        });
        list.items = selection;
    }).catch(function (e) {
        // process error
    });

NOTE: To request permissions for Android 6+ (API 23+) we use nativescript-permissions.

API

Methods

  • create(options) - creates instance of the imagepicker. Possible options are:
OptionPlatformDefaultDescription
modebothmultipleThe mode if the imagepicker. Possible values are single for single selection and multiple for multiple selection.
doneTextiOSDoneThe text of the "Done" button on top right.
cancelTextiOSCancelThe text of the "Cancel" button on top left.
albumsTextiOSAlbumsThe title of the "Albums" screen from where the selection of album and images can be done.
newestFirstiOSfalseSet to true to sort the images in an album by newest first.
  • authorize() - request iOS specific permissions.
  • present() - show the albums to present the user the ability to select images. Returns an array of the selected images.
  • cancel() - cancel selection. iOS only.
  • done() - confirm the selection is ready. iOS only.

Properties

PropertyDefaultDescription
selectionnullAn array of selected image assets.
albumsnullAlbums from where the images are picked.

License

2015, Telerik AD

Keywords

FAQs

Package last updated on 21 Aug 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc