Giter Site home page Giter Site logo

react-native-dbr's Introduction

Barcode Detection Module for React Native

How to Run the Example

cd Example
npm install
react-native run-android or react-native run-ios

Screenshots

Barcode Detection for React Native Barcode Detection for React Native

How to Use the Module

In Android

  1. Create a new React Native project:

    react-native init NewProject
  2. Add the local module to dependencies in package.json:

    "dependencies": {
    	"react": "16.0.0-alpha.6",
    	"react-native": "0.43.3",
    	"react-native-dbr":"file:../"
    },
  3. Link dependencies:

    react-native link
  4. Use flatDir to define library path in android/build.gradle:

    flatDir {
        dirs "$rootDir/../node_modules/react-native-dbr/android/lib"
    }
    
  5. Use the module in index.android.js:

    import BarcodeReaderManager from 'react-native-dbr';
    
    BarcodeReaderManager.readBarcode('your license key', (msg) => {
        this.setState({result: msg});
        }, 
        (err) => {
        console.log(err);
    });

In iOS

  1. Create a new React Native project:

    react-native init NewProject --version 0.44.3
  2. Add the local module to dependencies in NewProject/package.json:

    "dependencies": {
        "react": "16.0.0-alpha.6",
        "react-native": "0.43.3",
        "react-native-dbr":"file:../"
    }
  3. Remove node_moudules and install:

    sudo rm -rf node_moudules 
    npm install or yarn
  4. Add BarcodeReaderManager.xcodeproj to your project libraries :

  5. Use the module in index.ios.js:

    import BarcodeReaderManager from 'react-native-dbr';
    BarcodeReaderManager.readBarcode('your license here').then((msg) =>{
        this.setState({result: msg});
    }).catch((err) => {
        console.log(err);
    });
    
  6. In AppDelegate.m (In order to achieve navigation from react-native to viewController):

    #import "../../../ios/BarcodeReaderManagerViewController.h"
    #import "../../../ios/DbrManager.h"
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    //  self.window.rootViewController = rootViewController;
        _nav = [[UINavigationController alloc] initWithRootViewController:_rootViewController];
        self.window.rootViewController = _nav;
        _nav.navigationBarHidden = YES;
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doNotification:) name:@"readBarcode" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backToJs:) name:@"backToJs" object:nil];
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    -(void)doNotification:(NSNotification *)notification{
        BarcodeReaderManagerViewController* dbrMangerController = [[BarcodeReaderManagerViewController alloc] init];
        dbrMangerController.dbrManager = [[DbrManager alloc] initWithLicense:notification.userInfo[@"inputValue"]];
        [self.nav pushViewController:dbrMangerController animated:YES];
    }
    
    -(void)backToJs:(NSNotification *)notification{
        [self.nav popToViewController:self.rootViewController animated:YES];
    }
    

If you do not have a valid license, please contact [email protected]. With invalid license, the SDK can work but will not return a full result. Invalid license

Blog

Android Barcode Detection Component for React Native

react-native-dbr's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.