• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

react-native-device-info/react-native-device-info: Device Information for React ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

react-native-device-info/react-native-device-info

开源软件地址:

https://github.com/react-native-device-info/react-native-device-info

开源编程语言:

TypeScript 32.9%

开源软件介绍:

react-native-device-info

npm version npm total downloads npm monthly downloads npm weekly downloads

Device Information for React Native.

TOC

v6 to v7 upgrade

Your iOS Podfile will need to move to an iOS 10 minimum. v7 of this module no longer supports iOS9.

Installation

Using npm:

npm install --save react-native-device-info

or using yarn:

yarn add react-native-device-info

Proguard

If you want to use Install Referrer tracking, you will need to add this config to your Proguard config

-keepclassmembers class com.android.installreferrer.api.** {
  *;
}

If you are experiencing issues with hasGms() on your release apks, please add the following rule to your Proguard config

-keep class com.google.android.gms.common.** {*;}

AndroidX Support

This module defaults to AndroidX you should configure your library versions similar to this in your android/build.gradle file's "ext" block

Android
...
  ext {
    // dependency versions

    We have 3 options for deviceId:
    //Option 1 (latest):
    firebaseIidVersion = "19.0.1" // default: "19.0.1"
    //Option 2 (legacy GooglePlay dependency but using AndroidX):
    googlePlayServicesIidVersion = "17.0.0" // default: "17.0.0" - AndroidX
    //Option 3 (legacy GooglePlay dependency before AndroidX):
    googlePlayServicesIidVersion = "16.0.1"


    //include as needed:
    compileSdkVersion = "28" // default: 28 (28 is required for AndroidX)
    targetSdkVersion = "28" // default: 28 (28 is required for AndroidX)
    supportLibVersion = '1.0.2' // Use '28.0.0' or don't specify for old libraries, '1.0.2' or similar for AndroidX
    mediaCompatVersion = '1.0.1' // Do not specify if using old libraries, specify '1.0.1' or similar for androidx.media:media dependency
    supportV4Version = '1.0.0' // Do not specify if using old libraries, specify '1.0.0' or similar for androidx.legacy:legacy-support-v4 dependency
  }
...

If you need non-AndroidX you will need to use the jetifier package in reverse mode, documentation available with that package.

Linking

Linking in native modules is a frequent source of trouble for new react-native developers, resulting in errors like "RNDeviceInfo is null" etc. For this reason automatic linking was implemented, and it should be used in your project.

Automatic linking is supported for all platforms (even windows on React native >= 0.63!)

Previous versions need to do manual linking. No support is offered for these previous react-native versions but you may refer to older versions of this README if you like. Upgrade to modern versions of react-native. Use upgrade-helper tool on the internet if needed.

Usage

import DeviceInfo from 'react-native-device-info';

// or ES6+ destructured imports

import { getUniqueId, getManufacturer } from 'react-native-device-info';

API

Note that many APIs are platform-specific. If there is no implementation for a platform, then the "default" return values you will receive are "unknown" for string, -1 for number, and false for boolean. Arrays and Objects will be empty ([] and {} respectively).

Most APIs return a Promise but also have a corresponding API with Sync on the end that operates synchronously. For example, you may prefer to call isCameraPresentSync() during your app bootstrap to avoid async calls during the first parts of app startup.

The example app in this repository shows an example usage of every single API, consult the example app if you have questions, and if you think you see a problem make sure you can reproduce it using the example app before reporting it, thank you.

Method Return Type iOS Android Windows Web
getAndroidId() Promise<string>
getApiLevel() Promise<number>
getApplicationName() string
getAvailableLocationProviders() Promise<Object>
getBaseOs() Promise<string>
getBuildId() Promise<string>
getBatteryLevel() Promise<number>
getBootloader() Promise<string>
getBrand() string
getBuildNumber() string
getBundleId() string
isCameraPresent() Promise<boolean>
getCarrier() Promise<string>
getCodename() Promise<string>
getDevice() Promise<string>
getDeviceId() string
getDeviceType() string
getDisplay() Promise<string>
getDeviceName() Promise<string>
getDeviceToken() Promise<string>
getFirstInstallTime() Promise<number>
getFingerprint() Promise<string>
getFontScale() Promise<number>
getFreeDiskStorage() Promise<number>
getFreeDiskStorageOld() Promise<number>
getHardware() Promise<string>
getHost() Promise<string>
getIpAddress() Promise<string>
getIncremental() Promise<string>
getInstallerPackageName() Promise<string>
getInstallReferrer() Promise<string>
getInstanceId() Promise<string>
getLastUpdateTime() Promise<number>
getMacAddress() Promise<string>
getManufacturer() Promise<string>
getMaxMemory() Promise<number>
getModel() string
getPhoneNumber() Promise<string>
getPowerState() Promise<object>
getProduct() Promise<string>
getPreviewSdkInt() Promise<number>
getReadableVersion() string
getSerialNumber() Promise<string>
getSecurityPatch() Promise<string>
getSystemAvailableFeatures() Promise<string[]>
getSystemName() string
getSystemVersion() string
getTags() Promise<string>
getType() Promise<string>
getTotalDiskCapacity() Promise<number>
getTotalDiskCapacityOld() Promise<number>
getTotalMemory() Promise<number>
getUniqueId() string
getUsedMemory() Promise<number>
getUserAgent() Promise<string>
getVersion() string
getBrightness() Promise<number>
hasGms() Promise<boolean>
hasHms() Promise<boolean>
hasNotch() boolean
hasSystemFeature() Promise<boolean>
isAirplaneMode() Promise<boolean>
isBatteryCharging() Promise<boolean>
isEmulator() Promise<boolean>

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
skyming/Trip-to-iOS-Design-Patterns: iOS 设计模式相关资料整理发布时间:2022-06-21
下一篇:
yixia/Vitamio-iOS: Vitamio for iOS发布时间:2022-06-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap