Commit 27c4b076 authored by Gant Laborde's avatar Gant Laborde

merge

parents 35501dcf 53d75f1e
## Release Notes ## Release Notes
### 0.9.7
Several bugfixes and detecting if device is a tablet
### 0.9.3 ### 0.9.3
adds support for Brand information e.g. apple, htc, etc adds support for Brand information e.g. apple, htc, etc
......
...@@ -118,6 +118,29 @@ include ':app' ...@@ -118,6 +118,29 @@ include ':app'
(Thanks to @chirag04 for writing the instructions) (Thanks to @chirag04 for writing the instructions)
### Windows
- Open the solution in Visual Studio for your Windows apps
- right click your in the Explorer and click Add > Existing Project...
- Navigate to `./<app-name>/node_modules/react-native-device-info/windows/RNDeviceInfo` and add `RNDeviceInfo.csproj`
- this time right click on your React Native Windows app under your solutions directory and click Add > Reference...
- check the `RNDeviceInfo` you just added and press ok
- open up `MainPage.cs` for your app and edit the file like so:
```diff
+ using RNDeviceInfo;
......
get
{
return new List<IReactPackage>
{
new MainReactPackage(),
+ new RNDeviceInfoPackage(),
};
}
```
(Thanks to @josephan for writing the instructions)
## Device Name ## Device Name
If you want to get the device name in Android add this to your `AndroidManifest.xml` (optional): If you want to get the device name in Android add this to your `AndroidManifest.xml` (optional):
...@@ -136,43 +159,37 @@ See [CHANGELOG.md](https://github.com/rebeccahughes/react-native-device-info/blo ...@@ -136,43 +159,37 @@ See [CHANGELOG.md](https://github.com/rebeccahughes/react-native-device-info/blo
```js ```js
var DeviceInfo = require('react-native-device-info'); var DeviceInfo = require('react-native-device-info');
// or import DeviceInfo from 'react-native-device-info'; // or import DeviceInfo from 'react-native-device-info';
```
console.log("Device Unique ID", DeviceInfo.getUniqueID()); // e.g. FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9 | Name | Method | Return | Notes |
// * note this is IDFV on iOS so it will change if all apps from the current apps vendor have been previously uninstalled | :------------------------- | :------------------------------- | :-------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |
| Device Unique ID | `getUniqueID()` | FCDBD8EF-62FC-4ECB-B2F5-92C9E79AC7F9 | This is IDFV on iOS so it will change if all apps from the current apps vendor have been previously uninstalled. |
console.log("Device Manufacturer", DeviceInfo.getManufacturer()); // e.g. Apple | Device Manufacturer | `getManufacturer()` | Apple | |
| Device Brand | `getBrand()` | Apple / htc / Xiaomi | |
console.log("Device Brand", DeviceInfo.getBrand()); // e.g. Apple / htc / Xiaomi | Device Model | `getModel()` | iPhone 6 | |
| Device ID | `getDeviceId()` | iPhone7,2 | Or the board on Android e.g. goldfish |
console.log("Device Model", DeviceInfo.getModel()); // e.g. iPhone 6 | System Name | `getSystemName()` | iPhone OS | |
| System Version | `getSystemVersion()` | 9.0 | |
console.log("Device ID", DeviceInfo.getDeviceId()); // e.g. iPhone7,2 / or the board on Android e.g. goldfish | Bundle ID | `getBundleId()` | com.learnium.mobile | |
| Build Number | `getBuildNumber()` | 89 | |
console.log("System Name", DeviceInfo.getSystemName()); // e.g. iPhone OS | App Version | `getVersion()` | 1.1.0 | |
| App Version (Readable) | `getReadableVersion()` | 1.1.0.89 | |
console.log("System Version", DeviceInfo.getSystemVersion()); // e.g. 9.0 | Device Name | `getDeviceName()` | Becca's iPhone 6 | |
| User Agent | `getUserAgent()` | Dalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D) | |
console.log("Bundle ID", DeviceInfo.getBundleId()); // e.g. com.learnium.mobile | Device Locale | `getDeviceLocale()` | en-US | |
| Device Country | `getDeviceCountry()` | US | |
console.log("Build Number", DeviceInfo.getBuildNumber()); // e.g. 89 | Timezone | `getTimezone()` | America/Mexico_City | |
| App Instance ID | `getInstanceID()` | | ANDROID ONLY - see https://developers.google.com/instance-id/ |
console.log("App Version", DeviceInfo.getVersion()); // e.g. 1.1.0 | App is running in emulator | `isEmulator()` | true | if app is running in emulator return true |
| App is running on a tablet | `isTablet()` | true | if app is running on a tablet return true |
console.log("App Version (Readable)", DeviceInfo.getReadableVersion()); // e.g. 1.1.0.89 | PIN or fingerprint set | `isPinOrFingerprintSet(callback)`| | Only supported in Android and iOS 9.0 and above
console.log("Device Name", DeviceInfo.getDeviceName()); // e.g. Becca's iPhone 6 Since the device setting for PIN/Fingerprint can be modified while the app is still open, this is available via callback instead of as a constant. To use, pass a callback function in your javascript:
console.log("User Agent", DeviceInfo.getUserAgent()); // e.g. Dalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D)
console.log("Device Locale", DeviceInfo.getDeviceLocale()); // e.g en-US
console.log("Device Country", DeviceInfo.getDeviceCountry()); // e.g US
console.log("Timezone", DeviceInfo.getTimezone()); // e.g America/Mexico_City
console.log("App Instance ID", DeviceInfo.getInstanceID()); // ANDROID ONLY - see https://developers.google.com/instance-id/
console.log("App is running in emulator", DeviceInfo.isEmulator()); // if app is running in emulator return true
console.log("App is running on a tablet", DeviceInfo.isTablet()); // if app is running on a tablet return true ```js
RNDeviceInfo.isPinOrFingerprintSet(isPinOrFingerprintSet => {
if (!isPinOrFingerprintSet) {
...
}
}
``` ```
...@@ -217,11 +217,12 @@ ...@@ -217,11 +217,12 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../React/**",
"$(inherited)", "$(inherited)",
"$(BUILT_PRODUCTS_DIR)/usr/local/include",
"$(SRCROOT)/../../React/**",
"$(SRCROOT)/node_modules/react-native/React/**", "$(SRCROOT)/node_modules/react-native/React/**",
"$(SRCROOT)/../react-native/React/**", "$(SRCROOT)/../react-native/React/**",
"$(SRCROOT)/../../../node_modules/react-native/React/**", "$(SRCROOT)/../../../node_modules/react-native/React/**"
); );
IPHONEOS_DEPLOYMENT_TARGET = 8.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = "-ObjC";
...@@ -234,11 +235,12 @@ ...@@ -234,11 +235,12 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../React/**",
"$(inherited)", "$(inherited)",
"$(BUILT_PRODUCTS_DIR)/usr/local/include",
"$(SRCROOT)/../../React/**",
"$(SRCROOT)/node_modules/react-native/React/**", "$(SRCROOT)/node_modules/react-native/React/**",
"$(SRCROOT)/../react-native/React/**", "$(SRCROOT)/../react-native/React/**",
"$(SRCROOT)/../../../node_modules/react-native/React/**", "$(SRCROOT)/../../../node_modules/react-native/React/**"
); );
IPHONEOS_DEPLOYMENT_TARGET = 8.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = "-ObjC";
......
...@@ -9,7 +9,11 @@ ...@@ -9,7 +9,11 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import <sys/utsname.h> #import <sys/utsname.h>
#import "RCTBridgeModule.h" #if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif
@interface RNDeviceInfo : NSObject <RCTBridgeModule> @interface RNDeviceInfo : NSObject <RCTBridgeModule>
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "RNDeviceInfo.h" #import "RNDeviceInfo.h"
#import "DeviceUID.h" #import "DeviceUID.h"
#import <LocalAuthentication/LocalAuthentication.h>
@interface RNDeviceInfo() @interface RNDeviceInfo()
...@@ -179,7 +180,7 @@ RCT_EXPORT_MODULE() ...@@ -179,7 +180,7 @@ RCT_EXPORT_MODULE()
@"deviceCountry": self.deviceCountry ?: [NSNull null], @"deviceCountry": self.deviceCountry ?: [NSNull null],
@"uniqueId": uniqueId, @"uniqueId": uniqueId,
@"bundleId": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"], @"bundleId": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"],
@"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"appVersion": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ?: [NSNull null],
@"buildNumber": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"], @"buildNumber": [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"],
@"systemManufacturer": @"Apple", @"systemManufacturer": @"Apple",
@"userAgent": self.userAgent, @"userAgent": self.userAgent,
...@@ -189,4 +190,11 @@ RCT_EXPORT_MODULE() ...@@ -189,4 +190,11 @@ RCT_EXPORT_MODULE()
}; };
} }
RCT_EXPORT_METHOD(isPinOrFingerprintSet:(RCTResponseSenderBlock)callback)
{
LAContext *context = [[LAContext alloc] init];
BOOL isPinOrFingerprintSet = ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:nil]);
callback(@[[NSNumber numberWithBool:isPinOrFingerprintSet]]);
}
@end @end
...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
android { android {
compileSdkVersion 23 compileSdkVersion 23
buildToolsVersion "23.0.1" buildToolsVersion "25.0.2"
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
......
package com.learnium.RNDeviceInfo; package com.learnium.RNDeviceInfo;
import android.app.KeyguardManager;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Configuration; import android.content.res.Configuration;
...@@ -11,6 +13,8 @@ import com.google.android.gms.iid.InstanceID; ...@@ -11,6 +13,8 @@ import com.google.android.gms.iid.InstanceID;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
...@@ -69,6 +73,12 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -69,6 +73,12 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
return layout == Configuration.SCREENLAYOUT_SIZE_LARGE || layout == Configuration.SCREENLAYOUT_SIZE_XLARGE; return layout == Configuration.SCREENLAYOUT_SIZE_LARGE || layout == Configuration.SCREENLAYOUT_SIZE_XLARGE;
} }
@ReactMethod
public void isPinOrFingerprintSet(Callback callback) {
KeyguardManager keyguardManager = (KeyguardManager) this.reactContext.getSystemService(Context.KEYGUARD_SERVICE); //api 16+
callback.invoke(keyguardManager.isKeyguardSecure());
}
@Override @Override
public @Nullable Map<String, Object> getConstants() { public @Nullable Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<String, Object>(); HashMap<String, Object> constants = new HashMap<String, Object>();
...@@ -92,7 +102,9 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -92,7 +102,9 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
try { try {
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter(); BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
deviceName = myDevice.getName(); if(myDevice!=null){
deviceName = myDevice.getName();
}
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -62,4 +62,7 @@ module.exports = { ...@@ -62,4 +62,7 @@ module.exports = {
isTablet: function() { isTablet: function() {
return RNDeviceInfo.isTablet; return RNDeviceInfo.isTablet;
}, },
isPinOrFingerprintSet: function () {
return RNDeviceInfo.isPinOrFingerprintSet;
},
}; };
{ {
"name": "react-native-device-info", "name": "react-native-device-info",
"version": "0.9.7", "version": "0.10.0",
"description": "Get device information using react-native", "description": "Get device information using react-native",
"main": "deviceinfo.js", "main": "deviceinfo.js",
"repository": { "repository": {
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"react-native", "react-native",
"ios", "ios",
"android", "android",
"windows",
"device", "device",
"events", "events",
"cocoapod" "cocoapod"
......
# OSX
#
.DS_Store
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
# node.js
#
node_modules/
npm-debug.log
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
build/
# Other files
.vs/
*project.lock.json
obj/
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RNDeviceInfo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("RNDeviceInfo")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
This file contains Runtime Directives, specifications about types your application accesses
through reflection and other dynamic code patterns. Runtime Directives are used to control the
.NET Native optimizer and ensure that it does not remove code accessed by your library. If your
library does not do any reflection, then you generally do not need to edit this file. However,
if your library reflects over types, especially types passed to it or derived from its types,
then you should write Runtime Directives.
The most common use of reflection in libraries is to discover information about types passed
to the library. Runtime Directives have three ways to express requirements on types passed to
your library.
1. Parameter, GenericParameter, TypeParameter, TypeEnumerableParameter
Use these directives to reflect over types passed as a parameter.
2. SubTypes
Use a SubTypes directive to reflect over types derived from another type.
3. AttributeImplies
Use an AttributeImplies directive to indicate that your library needs to reflect over
types or methods decorated with an attribute.
For more information on writing Runtime Directives for libraries, please visit
http://go.microsoft.com/fwlink/?LinkID=391919
-->
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Library Name="RNDeviceInfo">
<!-- add directives for your library here -->
</Library>
</Directives>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RNDeviceInfo</RootNamespace>
<AssemblyName>RNDeviceInfo</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="RNDeviceInfoPackage.cs" />
<Compile Include="RNDeviceInfoModule.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\RNDeviceInfo.rd.xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\node_modules\react-native-windows\ReactWindows\ReactNative\ReactNative.csproj">
<Project>{c7673ad5-e3aa-468c-a5fd-fa38154e205c}</Project>
<Name>ReactNative</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RNDeviceInfo", "RNDeviceInfo.csproj", "{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReactNative", "..\..\node_modules\react-native-windows\ReactWindows\ReactNative\ReactNative.csproj", "{C7673AD5-E3AA-468C-A5FD-FA38154E205C}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\..\node_modules\react-native-windows\ReactWindows\ReactNative.Shared\ReactNative.Shared.projitems*{c7673ad5-e3aa-468c-a5fd-fa38154e205c}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Debug|ARM.ActiveCfg = Debug|ARM
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Debug|ARM.Build.0 = Debug|ARM
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Debug|x64.ActiveCfg = Debug|x64
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Debug|x64.Build.0 = Debug|x64
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Debug|x86.ActiveCfg = Debug|x86
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Debug|x86.Build.0 = Debug|x86
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Release|Any CPU.Build.0 = Release|Any CPU
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Release|ARM.ActiveCfg = Release|ARM
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Release|ARM.Build.0 = Release|ARM
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Release|x64.ActiveCfg = Release|x64
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Release|x64.Build.0 = Release|x64
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Release|x86.ActiveCfg = Release|x86
{C56790CE-79E5-4D7D-BEB7-8403E70BB0E4}.Release|x86.Build.0 = Release|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|Any CPU.ActiveCfg = Debug|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|ARM.ActiveCfg = Debug|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|ARM.Build.0 = Debug|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|x64.ActiveCfg = Debug|x64
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|x64.Build.0 = Debug|x64
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|x86.ActiveCfg = Debug|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Debug|x86.Build.0 = Debug|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|Any CPU.ActiveCfg = Release|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|ARM.ActiveCfg = Release|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|ARM.Build.0 = Release|ARM
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|x64.ActiveCfg = Release|x64
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|x64.Build.0 = Release|x64
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|x86.ActiveCfg = Release|x86
{C7673AD5-E3AA-468C-A5FD-FA38154E205C}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
using ReactNative.Bridge;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
using System.Text.RegularExpressions;
using Windows.ApplicationModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using WinRTXamlToolkit.Controls;
namespace RNDeviceInfo
{
public class RNDeviceInfoModule : ReactContextNativeModuleBase
{
public RNDeviceInfoModule(ReactContext reactContext)
: base(reactContext)
{
}
public override string Name
{
get
{
return "RNDeviceInfo";
}
}
private bool IsEmulator(string model)
{
Regex rgx = new Regex("(?i:virtual)");
return rgx.IsMatch(model);
}
private bool IsTablet(string os)
{
Regex rgx = new Regex("(?i:windowsphone)");
return !rgx.IsMatch(os);
}
public override IReadOnlyDictionary<string, object> Constants
{
get
{
Dictionary<string, object> constants = new Dictionary<string, object>();
constants["appVersion"] = "not available";
constants["buildVersion"] = "not available";
constants["buildNumber"] = 0;
Package package = Package.Current;
PackageId packageId = package.Id;
PackageVersion version = packageId.Version;
String packageName = package.DisplayName;
try
{
constants["appVersion"] = string.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
constants["buildNumber"] = version.Build.ToString();
constants["buildVersion"] = version.Build.ToString();
}
catch
{
}
String deviceName = "not available";
String manufacturer = "not available";
String device_id = "not available";
String model = "not available";
String hardwareVersion = "not available";
String osVersion = "not available";
String os = "not available";
CultureInfo culture = CultureInfo.CurrentCulture;
try
{
var deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
deviceName = deviceInfo.FriendlyName;
manufacturer = deviceInfo.SystemManufacturer;
device_id = deviceInfo.Id.ToString();
model = deviceInfo.SystemProductName;
hardwareVersion = deviceInfo.SystemHardwareVersion;
os = deviceInfo.OperatingSystem;
string deviceFamilyVersion = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamilyVersion;
ulong version2 = ulong.Parse(deviceFamilyVersion);
ulong major = (version2 & 0xFFFF000000000000L) >> 48;
ulong minor = (version2 & 0x0000FFFF00000000L) >> 32;
osVersion = $"{major}.{minor}";
}
catch
{
}
constants["instanceId"] = "not available";
constants["deviceName"] = deviceName;
constants["systemName"] = "Windows";
constants["systemVersion"] = osVersion;
constants["model"] = model;
constants["brand"] = model;
constants["deviceId"] = hardwareVersion;
constants["deviceLocale"] = culture.Name;
constants["deviceCountry"] = culture.EnglishName;
constants["uniqueId"] = device_id;
constants["systemManufacturer"] = manufacturer;
constants["bundleId"] = packageName;
constants["userAgent"] = "not available";
constants["timezone"] = TimeZoneInfo.Local.Id;
constants["isEmulator"] = IsEmulator(model);
constants["isTablet"] = IsTablet(os);
return constants;
}
}
}
}
using ReactNative.Bridge;
using ReactNative.Modules.Core;
using ReactNative.UIManager;
using System;
using System.Collections.Generic;
namespace RNDeviceInfo
{
public class RNDeviceInfoPackage : IReactPackage
{
public IReadOnlyList<INativeModule> CreateNativeModules(ReactContext reactContext)
{
return new List<INativeModule>
{
new RNDeviceInfoModule(reactContext)
};
}
public IReadOnlyList<Type> CreateJavaScriptModulesConfig()
{
return new List<Type>(0);
}
public IReadOnlyList<IViewManager> CreateViewManagers(
ReactContext reactContext)
{
return new List<IViewManager>(0);
}
}
}
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
\ No newline at end of file
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