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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-uuid-generator's Issues

UUID version

What version of UUID does this library generate?

life time for the UUID generator?

Before using this library i just want to know will this uuid be generated everytime i open my app or else. it will generated for the first time when the app is installed and will be removed after uninstalling the app.

React 0.60 support

[!] use_native_modules! skipped the react-native dependency 'react-native-uuid-generator'. No podspec file was found.
- Check to see if there is an updated version that contains the necessary podspec file
- Contact the library maintainers or send them a PR to add a podspec. The react-native-webview podspec is a good example of a package.json
driven podspec. See https://github.com/react-native-community/react-native-webview/blob/master/react-native-webview.podspec
- If necessary, you can disable autolinking for the dependency and link it manually. See
https://github.com/react-native-community/cli/blob/master/docs/autolinking.md#how-can-i-disable-autolinking-for-unsupported-library

Can we do the required react native 60 updates?

react-native link adds com.Traviskn.RNUUIDGeneratorPackage

`error: cannot find symbol

import com.Traviskn.RNUUIDGeneratorPackage;

symbol: class RNUUIDGeneratorPackage

location: package com.Traviskn`

Works after manually change MainApplication.java content to

import io.github.traviskn.rnuuidgenerator.RNUUIDGeneratorPackage;

Why the process is async?

Hey @Traviskn,

Before going further I want to thank you for having published this, thanks!

I was just wondering why the necessity of going async, can you give me an insight on the decisions around this?

Thanks again!

unable to build

yarn run v1.9.4
$ ./node_modules/.bin/react-native run-android
Scanning folders for symlinks in /[app path]/node_modules (8ms)

JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /[user home]/Android/Sdk/ndk-bundl
e.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to /[user home]/Android/Sdk/ndk-bundl
e.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareAndroidArchLifecycleRuntime100Library
:app:prepareComAndroidSupportAnimatedVectorDrawable2610Library

:react-native-uuid-generator:prepareComAndroidSupportAnimatedVectorDrawable2610Library
:react-native-uuid-generator:prepareComAndroidSupportAppcompatV72610Library
:react-native-uuid-generator:prepareComAndroidSupportSupportCompat2610Library
:react-native-uuid-generator:prepareComAndroidSupportSupportCoreUi2610Library
:react-native-uuid-generator:prepareComAndroidSupportSupportCoreUtils2610Library
:react-native-uuid-generator:prepareComAndroidSupportSupportFragment2610Library
:react-native-uuid-generator:prepareComAndroidSupportSupportMediaCompat2610Library
:react-native-uuid-generator:prepareComAndroidSupportSupportV42610Library
:react-native-uuid-generator:prepareComAndroidSupportSupportVectorDrawable2610Library
:react-native-uuid-generator:prepareComFacebookFbuiTextlayoutbuilderTextlayoutbuilder100Library
:react-native-uuid-generator:prepareComFacebookFrescoDrawee190Library
:react-native-uuid-generator:prepareComFacebookFrescoFbcore190Library
:react-native-uuid-generator:prepareComFacebookFrescoFresco190Library
:react-native-uuid-generator:prepareComFacebookFrescoImagepipeline190Library
:react-native-uuid-generator:prepareComFacebookFrescoImagepipelineBase190Library
:react-native-uuid-generator:prepareComFacebookFrescoImagepipelineOkhttp3190Library
:react-native-uuid-generator:prepareComFacebookReactReactNative0560Library
:react-native-uuid-generator:prepareComFacebookSoloaderSoloader030Library
:react-native-uuid-generator:prepareOrgWebkitAndroidJscR174650Library
:react-native-uuid-generator:prepareReleaseDependencies
:react-native-uuid-generator:compileReleaseAidl UP-TO-DATE
:react-native-uuid-generator:compileReleaseNdk NO-SOURCE
:react-native-uuid-generator:compileLint UP-TO-DATE
:react-native-uuid-generator:copyReleaseLint NO-SOURCE
:react-native-uuid-generator:compileReleaseRenderscript UP-TO-DATE
:react-native-uuid-generator:generateReleaseBuildConfig UP-TO-DATE
:react-native-uuid-generator:generateReleaseResValues UP-TO-DATE
:react-native-uuid-generator:processReleaseManifest UP-TO-DATE
:react-native-uuid-generator:processReleaseResources
/[app path]/node_modules/react-native-uuid-generator/android/build/intermediates/res/merged/release/values-v26/values-v26.x
ml:15:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

/[app path]/node_modules/react-native-uuid-generator/android/build/intermediates/res/merged/release/values-v26/values-v26.x
ml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.


:react-native-uuid-generator:processReleaseResources FAILED

FAILURE: Build failed with an exception.

FAILURE: Build failed with an exception.


* What went wrong:
Execution failed for task ':react-native-uuid-generator:processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 6.319 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

Failed to resolve: com.facebook.react:react-native:0.61.2

I was found error when upgrade version from react-native 0.61.2 to 0.63.2 at android/build.gradle
dependencies implemetation

and I was fix it from
implement "com.facebook.react:react-native:${safeExtGet("reactNative", "+")}"
to
implement "com.facebook.react:react-native:+"

and I can run it other process

image

Thanks

some error

rnpm-install info Linking react-native-uuid-generator android dependency
rnpm-install ERR! Something went wrong while linking. Error: ENOENT: no such file or directory, open '/Users/lidongbo/Desktop/RN/TravellerProject/Traveller/android/app/src/main/java/com/zoomdu/findtour/traveller/MainApplication.java'
Please file an issue here: https://github.com/facebook/react-native/issues

ENOENT: no such file or directory, open '/Users/lidongbo/Desktop/RN/TravellerProject/Traveller/android/app/src/main/java/com/zoomdu/findtour/traveller/MainApplication.java'

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.