Giter VIP home page Giter VIP logo

react-native-uuid-generator's Introduction

react-native-uuid-generator

npm version downloads

A simple wrapper around the native iOS and Android UUID classes. Exposes a single method, getRandomUUID.

Example App Screen Capture

Getting started

$ npm install react-native-uuid-generator --save

$ react-native link react-native-uuid-generator

Usage

This library supports both callback and promise interfaces.

import UUIDGenerator from 'react-native-uuid-generator';

// Callback interface
UUIDGenerator.getRandomUUID((uuid) => {
  console.log(uuid);
});
// => "42A8A87A-F71C-446B-B81D-0CD16A709625"

// Promise interface
UUIDGenerator.getRandomUUID().then((uuid) => {
  console.log(uuid);
});
// => "BD6120BD-3612-4D56-8957-99F5D6F02C52"

Manual installation

If the react-native link command doesn't work, you can also install the native components of this library manually.

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-uuid-generator and add RNUUIDGenerator.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNUUIDGenerator.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import io.github.traviskn.rnuuidgenerator.RNUUIDGeneratorPackage; to the imports at the top of the file
  • Add new RNUUIDGeneratorPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
  include ':react-native-uuid-generator'
  project(':react-native-uuid-generator').projectDir = new File(rootProject.projectDir,   '../node_modules/react-native-uuid-generator/android')
  1. Insert the following lines inside the dependencies block in android/app/build.gradle:
  compile project(':react-native-uuid-generator')

Upgrading

See the changelog for instructions on upgrading to the latest version.

Example

Check out the example app included in the github repo to see the UUID Generator in action! I assume you already have the react-native-cli installed, as well as the required iOS or Android dependencies.

git clone https://github.com/Traviskn/react-native-uuid-generator.git

cd react-native-uuid-generator/example
npm install

Use react-native run-ios or react-native run-android to run the example.

react-native-uuid-generator's People

Contributors

adhax avatar behzad888 avatar ltoussaint avatar ossareh avatar richeterre avatar saeedzhiany avatar traviskn avatar ymuzikant avatar

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.