这次介绍的获取移动设备信息的组件名叫:react-native-device-info,兼容IOS和安卓双平台,可以获取设备ID、设备品牌、设备型号、IP以及APP版本号等信息。 安装 npm install--save react-native-device-info 注:如果React Naitve的版本大于0.47,那么需要使用>=0.11版本的react-native-device-info 组件 因为涉及到原生代码,所以在执行完install后,需要执行link命令 react-nativelink react-native-device-info 使用示例 import DeviceInfo from 'react-native-device-info'; const device = {}; device.DeviceID = deviceInfo.getUniqueID(); GitHub地址:https://github.com/rebeccahughes/react-native-device-info
二、组件介绍 1.首先需要安装组件:npm install react-native-device-info --save 2.IOS初始化:打开Xcode——>右击Libraries——>选择文件到当前项目 ,进入到node_modules/react-native-device-info——>添加.xcodeproj文件 2.1.在Xcode中点击你的工程名字——>Build Phases——>Link /React 并且修改 recursive 2.3.好了,下面就是基本的用法了 import DeviceInfo from 'react-native-device-info' console.log DeviceInfo.getDeviceCountry()); // e.g US 3.Android的安装: 3.1首先需要修改下Gradle文件 在你的根目录下运行:react-native link react-native-device-info 翻译链接:https://github.com/rebeccahughes/react-native-device-info
://github.com/react-community/react-navigation 网络请求 asios: https://github.com/mzabriskie/axios 设备信息 react-native-device-info : https://github.com/rebeccahughes/react-native-device-info 缓存使用 react-native-storage: https://github.com
setTimeout(() => Alert.alert('环境切换', '服务器环境已经切换至' + baseUrl), 1000) }); 注:当前设备信息的显示依赖于 'react-native-device-info ' 库 需在调用页面引入依赖:import DeviceInfo from 'react-native-device-info';并把DeviceInfo传入到DebugManager的初始化参数中。
当前支持以下的插件: BackHandler (Android) Brightness (by react-native-device-brightness) Console DeviceInfo (by react-native-device-info
toBeCalledWith('https://www.phodal.com/'); }); 唯一比较麻烦的是,当我们要测试原生的组件,需要在 jest.setup.js 中 mock 这些方法,如下是用来 mock 包 react-native-device-info 中的 getVersion 方法: jest.mock('react-native-device-info', () => ({ getVersion: jest.fn(),})); 而 React
ViewPropTypes, } from 'react-native'; import PropTypes from 'prop-types'; import DeviceInfo from 'react-native-device-info
react-native-animatable 动画 react-native-carousel 轮播 react-native-countdown 倒计时 react-native-device-info PDF https://github.com/cnjon/react-native-pdf-view 获取设备信息 https://github.com/rebeccahughes/react-native-device-info
和ios的toast https://github.com/remobile/react-native-toast 获取设备各类信息 https://github.com/rebeccahughes/react-native-device-info