npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

beta-react-native-capture

v0.8.5

Published

Socket Mobile Capture SDK for React Native (Beta version)

Downloads

24

Readme

react-native-capture BETA

This is a BETA version of react native Capture.

This react native module allows a React Native application to use and control Socket Mobile wireless barcode scanners, NFC Reader/Writer, and Camera (iOS only) to capture and deliver data capture to such application.

Getting started

To install this module to your app environment using NPM: $ npm install beta-react-native-capture --save

using YARN: $ yarn add beta-react-native-capture

Usage


import React, { useState } from 'react';
import {CaptureRn, CaptureEventIds, SktErrors} from 'beta-react-native-capture';

export default class App extends Component<{}> {
  constructor(props) {
    super(props);
    this.state = {
      status: 'starting',
      message: '--',
    };
    this.onCaptureEvent = this.onCaptureEvent.bind(this);
    this.capture = new CaptureRn();
    this.device = new CaptureRn();
  }

  componentDidMount() {
    const appInfo = {
      appId: 'web:com.socketmobile.reactjs.native.example.example',
      developerId: 'bb57d8e1-f911-47ba-b510-693be162686a',
      appKey:
        'MC0CFQC85w0MsxDng4wHBICX7+iCOiSqfAIUdSerA4/MJ2kYBGAGgIG/YHemNr8=',
    };
    console.log('componentDidMount about to open Capture');
    this.capture
      .open(appInfo, this.onCaptureEvent)
      .then((message) => {
        console.log('captureJS open returns: ', message);
        if (message !== SktErrors.ESKT_NOERROR) {
          message = `Error opening Capture: ${message}`;
        } else {
          message = 'Open capture successful';
        }
        this.setState({
          status: 'Open Capture has returned with: ',
          message,
        });
      })
      .catch((err) => {
        console.error(err);
      });
  }

  onCaptureEvent(e) {
    // case when we receive an empty event (should be fixed in the coming release)
    if (!e) {
      return;
    }
    this.setState({
      status: 'Receive a notification:',
      message: JSON.stringify(e),
    });
    switch (e.id) {
      // when a device is connected to the host
      case CaptureEventIds.DeviceArrival:
        this.device
          .openDevice(e.value.guid, this.capture)
          .then((result) => {
            this.setState({
              status: 'Opening a device:',
              message: `result of opening a device: ${result}`,
            });
          })
          .catch((err) => {
            console.error(err);
          });
        break;
      // when a device is disconnecting from the host
      case CaptureEventIds.DeviceRemoval:
        this.device
          .close()
          .then((result) => {
            this.setState({
              status: 'Closing a device:',
              message: `result of closing a device: ${result}`,
            });
          })
          .catch((err) => {
            console.error(`error closing a device: ${err.message}`);
          });
        break;
      case CaptureEventIds.DecodedData:
        this.setState({
          status: 'Received Decoded Data:',
          message: `source: ${e.value.dataSource.name} length:${e.value.value.length} data: ${e.value.value}`,
        });
        
        break;
    }
  }

...
};

Documentation

More documentation available at Socket online documentation.