A react native based native module for generating Unique User IDentity (UUID). This module is MIT Licensed and is meant for anyone who wants to get
$ npm install rn-uuid-generator --save
Sorry, this module does not support Expo, you might like to check any other ways of generating UUIDs inside your application.
$ react-native link rn-uuid-generator
-> If this does not seem to work, you can try the following approaches for iOS & Android respectively.
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜rn-uuid-generator
and adduuidGenerator.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNuuidGenerator.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import io.github.traviskn.rnuuidgenerator.uuidGeneratorPackage;
to the imports at the top of the file - Add
new uuidGeneratorPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:
include ':rn-uuid-generator'
project(':rn-uuid-generator').projectDir = new File(rootProject.projectDir, '../node_modules/rn-uuid-generator/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:
compile project(':rn-uuid-generator')
import uuidGenerator from 'rn-uuid-generator';
// Callback interface
uuidGenerator.getUUID((uuid) => {
console.log(uuid);
});
// Promise interface
uuidGenerator.getUUID()
.then((uuid) => {
console.log(uuid);
});