Commit f4226480 authored by Rebecca Hughes's avatar Rebecca Hughes

Initial Commit

parent f0fde333
node_modules
# Xcode
#
build/
......
The MIT License (MIT)
Copyright (c) 2015 Rebecca Hughes
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# react-native-device-info
Device Information for React Native
## react-native-device-info
Device Information for react-native
## Usage
First you need to install react-native-device-info:
```javascript
npm install react-native-device-info --save
```
In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name] Go to node_modules ➜ react-native-device-info and add the .xcodeproj file
In XCode, in the project navigator, select your project. Add the lib*.a from the deviceinfo project to your project's Build Phases ➜ Link Binary With Libraries Click .xcodeproj file you added before in the project navigator and go 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.
Run your project (Cmd+R)
(Thanks to @brysgo for writing the instructions)
## Example
```js
var DeviceInfo = require('react-native-device-info');
console.log("Device Unique ID", DeviceInfo.getUniqueID()); // e.g. FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9
console.log("Device Manufacturer", DeviceInfo.getManufacturer()); // e.g. Apple
console.log("Device Model", DeviceInfo.getModel()); // e.g. iPhone
console.log("Device Name", DeviceInfo.getSystemName()); // e.g. iPhone OS
console.log("Device Version", DeviceInfo.getSystemVersion()); // e.g. 9.0
```
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
DA5891DC1BA9A9FC002B4DB2 /* RNDeviceInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DA5891DB1BA9A9FC002B4DB2 /* RNDeviceInfo.h */; };
DA5891DE1BA9A9FC002B4DB2 /* RNDeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = DA5891DD1BA9A9FC002B4DB2 /* RNDeviceInfo.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
DA5891D61BA9A9FC002B4DB2 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/$(PRODUCT_NAME)";
dstSubfolderSpec = 16;
files = (
DA5891DC1BA9A9FC002B4DB2 /* RNDeviceInfo.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
DA5891D81BA9A9FC002B4DB2 /* libRNDeviceInfo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNDeviceInfo.a; sourceTree = BUILT_PRODUCTS_DIR; };
DA5891DB1BA9A9FC002B4DB2 /* RNDeviceInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNDeviceInfo.h; sourceTree = "<group>"; };
DA5891DD1BA9A9FC002B4DB2 /* RNDeviceInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNDeviceInfo.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
DA5891D51BA9A9FC002B4DB2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
DA5891CF1BA9A9FC002B4DB2 = {
isa = PBXGroup;
children = (
DA5891DA1BA9A9FC002B4DB2 /* RNDeviceInfo */,
DA5891D91BA9A9FC002B4DB2 /* Products */,
);
sourceTree = "<group>";
};
DA5891D91BA9A9FC002B4DB2 /* Products */ = {
isa = PBXGroup;
children = (
DA5891D81BA9A9FC002B4DB2 /* libRNDeviceInfo.a */,
);
name = Products;
sourceTree = "<group>";
};
DA5891DA1BA9A9FC002B4DB2 /* RNDeviceInfo */ = {
isa = PBXGroup;
children = (
DA5891DB1BA9A9FC002B4DB2 /* RNDeviceInfo.h */,
DA5891DD1BA9A9FC002B4DB2 /* RNDeviceInfo.m */,
);
path = RNDeviceInfo;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
DA5891D71BA9A9FC002B4DB2 /* RNDeviceInfo */ = {
isa = PBXNativeTarget;
buildConfigurationList = DA5891E11BA9A9FC002B4DB2 /* Build configuration list for PBXNativeTarget "RNDeviceInfo" */;
buildPhases = (
DA5891D41BA9A9FC002B4DB2 /* Sources */,
DA5891D51BA9A9FC002B4DB2 /* Frameworks */,
DA5891D61BA9A9FC002B4DB2 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = RNDeviceInfo;
productName = RNDeviceInfo;
productReference = DA5891D81BA9A9FC002B4DB2 /* libRNDeviceInfo.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
DA5891D01BA9A9FC002B4DB2 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = Learnium;
TargetAttributes = {
DA5891D71BA9A9FC002B4DB2 = {
CreatedOnToolsVersion = 7.0;
};
};
};
buildConfigurationList = DA5891D31BA9A9FC002B4DB2 /* Build configuration list for PBXProject "RNDeviceInfo" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = DA5891CF1BA9A9FC002B4DB2;
productRefGroup = DA5891D91BA9A9FC002B4DB2 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
DA5891D71BA9A9FC002B4DB2 /* RNDeviceInfo */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
DA5891D41BA9A9FC002B4DB2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DA5891DE1BA9A9FC002B4DB2 /* RNDeviceInfo.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
DA5891DF1BA9A9FC002B4DB2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
DA5891E01BA9A9FC002B4DB2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
DA5891E21BA9A9FC002B4DB2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../React/**",
"$(inherited)",
"$(SRCROOT)/node_modules/react-native/React/**",
"$(SRCROOT)/../react-native/React/**",
"$(SRCROOT)/../../../node_modules/react-native/React/**",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Debug;
};
DA5891E31BA9A9FC002B4DB2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../React/**",
"$(inherited)",
"$(SRCROOT)/node_modules/react-native/React/**",
"$(SRCROOT)/../react-native/React/**",
"$(SRCROOT)/../../../node_modules/react-native/React/**",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
DA5891D31BA9A9FC002B4DB2 /* Build configuration list for PBXProject "RNDeviceInfo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DA5891DF1BA9A9FC002B4DB2 /* Debug */,
DA5891E01BA9A9FC002B4DB2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
DA5891E11BA9A9FC002B4DB2 /* Build configuration list for PBXNativeTarget "RNDeviceInfo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DA5891E21BA9A9FC002B4DB2 /* Debug */,
DA5891E31BA9A9FC002B4DB2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = DA5891D01BA9A9FC002B4DB2 /* Project object */;
}
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:RNDeviceInfo.xcodeproj">
</FileRef>
</Workspace>
//
// RNDeviceInfo.h
// Learnium
//
// Created by Rebecca Hughes on 03/08/2015.
// Copyright © 2015 Learnium Limited. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <sys/utsname.h>
#import "RCTBridgeModule.h"
@interface RNDeviceInfo : NSObject <RCTBridgeModule>
@end
//
// RNDeviceInfo.m
// Learnium
//
// Created by Rebecca Hughes on 03/08/2015.
// Copyright © 2015 Learnium Limited. All rights reserved.
//
#import "RNDeviceInfo.h"
@interface RNDeviceInfo()
@end
@implementation RNDeviceInfo
{
}
RCT_EXPORT_MODULE()
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
- (NSDictionary *)constantsToExport
{
UIDevice *currentDevice = [UIDevice currentDevice];
NSUUID *identifierForVendor = [currentDevice identifierForVendor];
NSString *deviceId = [identifierForVendor UUIDString];
return @{
@"systemName": currentDevice.systemName,
@"systemVersion": currentDevice.systemVersion,
@"model": currentDevice.model,
@"deviceId": deviceId,
};
}
@end
\ No newline at end of file
/**
* @providesModule react-native-device-info
*/
var { RNDeviceInfo } = require('react-native').NativeModules;
export default class CurrentDeviceIOS {
static getUniqueID() {
return RNDeviceInfo.deviceId;
}
static getManufacturer() {
return "Apple";
}
static getModel() {
return RNDeviceInfo.model;
}
static getSystemName() {
return RNDeviceInfo.systemName;
}
static getSystemVersion() {
return RNDeviceInfo.systemVersion;
}
}
{
"name": "react-native-device-info",
"version": "0.2.0",
"description": "Get device information using react-native",
"main": "deviceinfo.ios.js",
"repository": {
"type": "git",
"url": "git@github.com:rebeccahughes/react-native-device-info.git"
},
"keywords": [
"react-component",
"react-native",
"ios",
"device",
"events"
],
"author": "Rebecca Hughes <rebecca@learnium.net> (https://github.com/rebeccahughes)",
"license": "MIT",
"dependencies": {
"eventemitter3": "^1.1.0"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment