UNPKG

imobile_for_reactnative

Version:

iMobile for ReactNative,是SuperMap iMobile推出的一款基于React-Native框架的移动应用开发工具。基于该开发工具,用户可以使用JavaScript开发语言,开发出在Android和IOS操作系统下运行的原生移动GIS应用,入门门槛低,一次开发,处处运行。

59 lines (51 loc) 1.17 kB
/** * 获取设备信息 */ import { NativeModules, Platform, } from "react-native" const DeviceUtils = NativeModules.DeviceUtils export function get(dim) { if (Platform.OS !== 'android') { // console.warn('DeviceUtils is only available on Android. Trying to access', dim) return 0 } else { // android try { if (!DeviceUtils) { throw "DeviceUtils not defined." } const result = DeviceUtils[dim] if (typeof result !== 'number') { return result } return result } catch (e) { console.error(e) } } } export function getNavigationBarHeight() { if (Platform.OS !== 'android') { // console.warn('DeviceUtils is only available on Android. Trying to access', dim) return 0 } return get('NAVIGATION_BAR_HEIGHT') } /** * 获取设备是否有虚拟导航按键 * Android Only * @returns {*} */ async function hasNavigationBar(): Promise<boolean> { try { if (Platform.OS !== 'android') return false return DeviceUtils.hasNavigationBar() } catch (error) { console.error(error) } } export default { hasNavigationBar, getNavigationBarHeight, }