Giter Club home page Giter Club logo

react-native-device-uuid's Introduction

react-native-device-uuid

What?

Allow developer to retrieve iOS's identifierForVendor as UUID for React Native Application.

Why?

Sometimes we need an unique identifier (e.g., when implementing special authentication flow) to identify an "user-device" pair. However, device token, which is mainly used for push notification, is not suitable in such use case. The reason is that device token can and will change. For details, please refers to Is the device token as unique as the device ID?.

Note: The UUID will change if the app is reinstalled

"The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them. The value can also change when installing test builds using Xcode or when installing an app on a device using ad-hoc distribution. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes." - source: identifierForVendor

How?

Install

npm install --save react-native-device-uuid
react-native link

Usage

var DeviceUUID = require("react-native-device-uuid");
DeviceUUID.getUUID().then((uuid) => {
  console.log(uuid);
});

Troubleshooting

DeviceUUID just hangs and does not log the uuid to the console (#2), thanks to @irfaan

  1. In XCode, in the project navigator, right click Libraries
  2. Add Files to [your project's name]
  3. Go to node_modules
  4. react-native-device-uuid and add the .xcodeproj file
  5. In XCode, in the project navigator, select your project
  6. Add the lib*.a from the react-native-device-uuid project to your project's Build Phases - Link Binary With Libraries. Select the .a file.
  7. Go to the Build Settings tab.
  8. Make sure 'All' is toggled on (instead of 'Basic').
  9. Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React - mark both as recursive.

react-native-device-uuid's People

Contributors

antoniopresto avatar ashleydw avatar gage avatar gargsms avatar lazywei avatar license2e 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

Watchers

 avatar  avatar  avatar  avatar  avatar

react-native-device-uuid's Issues

No dependencies listed in package.json

This package would not work with other installed modules (which were working fine) in XCode unless I specifically cd'd into node_modules/react-native-device-uuid/, ran npm install invariant --save to add the invariant dependency to the package.json, and changed the first line of node_modules/react-native-device-uuid/DeviceUUID.ios.js from var RCTDeviceUUID = require('NativeModules').DeviceUUID; to var RCTDeviceUUID = require('react-native').NativeModules.DeviceUUID;.

what about android

why not support android and give cross platform api as in react-native?

NativeModules does not resolve - [React Native v.0.5.0]

Receiving Invariant Violation that prevents application from loading:

Unable to resolve module NativeModules from /Users/.../node_modules/react-native-device-uuid/DeviceUUID.ios.js

React Native v. 0.7.1

Edit
Does it have something to do with requiring react-native instead of referencing private modules? Something like this perhaps (adapted from johanneslumpe/react-native-keyboardevents@5e57191)?:

var {
  invariant,
  NativeModules: {
    DeviceUUID,
  },
} = require('react-native');

Hangs with no error

Running on both simulator and device (with update to RCTDeviceUUID.m), DeviceUUID just hangs and does not log the uuid to the console. Any ideas on how to begin debugging this?

Update
I needed to perform the following steps (adapted from react-native-keyboardevents):

In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name] Go to node_modules ➜ react-native-device-uuid and add the .xcodeproj file

In XCode, in the project navigator, select your project. Add the lib*.a from the react-native-device-uuid project to your project's Build Phases ➜ Link Binary With Libraries. Select the .a file. Go to the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React - mark both as recursive.

Possible Unhandled Promise Rejection (id: 0)

Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'getUUID' of undefined
TypeError: Cannot read property 'getUUID' of undefined
    at blob:http://localhost:8081/15b07455-e83e-4936-b6ec-2953b21fdf89:132798:20
    at tryCallTwo (blob:http://localhost:8081/15b07455-e83e-4936-b6ec-2953b21fdf89:13422:7)
    at doResolve (blob:http://localhost:8081/15b07455-e83e-4936-b6ec-2953b21fdf89:13586:15)
    at new Promise (blob:http://localhost:8081/15b07455-e83e-4936-b6ec-2953b21fdf89:13445:5)
    at Object.getUUID (blob:http://localhost:8081/15b07455-e83e-4936-b6ec-2953b21fdf89:132797:14)
    at Login.<anonymous> (blob:http://localhost:8081/15b07455-e83e-4936-b6ec-2953b21fdf89:91202:26)
    at commitCallbacks (blob:http://localhost:8081/15b07455-e83e-4936-b6ec-2953b21fdf89:6324:21)
    at commitLifeCycles (blob:http://localhost:8081/15b07455-e83e-4936-b6ec-2953b21fdf89:8517:19)
    at commitAllLifeCycles (blob:http://localhost:8081/15b07455-e83e-4936-b6ec-2953b21fdf89:9567:15)
    at Object._invokeGuardedCallback (blob:http://localhost:8081/15b07455-e83e-4936-b6ec-2953b21fdf89:2789:16)

Getting this error while trying to get the uuid and print it on console using console.log. I tried to add the library using the method given in documentation but it didn't help.

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.