UNPKG

para-bridge-demo

Version:

a bridge api for js-ios/andriod rest

103 lines (97 loc) 3.15 kB
import { BridgePlugin } from '../bridge'; interface IGetDeviceInfoResult { // 设备Id deviceId: string; // 设备名称 deviceName: string; // 客户端类型("android"/"iPhone") appVersionType: string; // 客户端版本号 appVersionNumber: string; // 当前登录类型,微信登录,手机号登录 loginType: string; // 接口中extend的数据 标识符+系统版本+手机版本 extend: string; // 接口中pushInfo的数据,用于推送token. pushInfo: string; // refid refid: string; // for android imei: string; // iOS since 系统生成,唯一标识,代表一款产品,相同的标识符,安装在一台手机上,会覆盖安装 // com.fc.iphone, com.fc.android idfa: string; // 屏幕尺寸(分辨率)如:750x1334 screenSize: string; // 屏幕高 screenHeight: string; // 屏幕密度 screenDensity: string; // navbar高度 像素。 navBarHeightPx: string; // 状态栏高度, iOS: < iOS11 : 20 px | iOS 11 iPhone X 20px:44px (since 838) Android: 每个机型都可能不同 (since 840) statusBarHeightPx: string; // iPhone X底部手势区域高度 34px (iOS only) since 838 bottomHomeIndicatorHeightPx: string; // 推送通知系统开关 "1"| "0" ; '1' 标识已打开 systemNotifySwitch: '1' | '0'; // 推送通知app内部开关 "1"| "0"; '1' 标识已打开 appNotifySwitch: '1' | '0'; // 获取用户当前剪贴板的内容 clipboardContent: string; // 操作系统版本,如10.3.3 OSVer: string; // 是否越狱 "1":越狱 | "0":未越狱 isRoot: '1' | '0'; // 剩余电量(0.00-1.00之间的浮点值) soc: string; // 剩余内存容量(KB) freeRAM: string; // APP装机数量 appAmt: string; // 设备ICCID, 插手机卡之后才有值 苹果需要越狱 iccid: string; // 设备IMSI imsi: string; // IP地址 ip: string; // 系统时区 如:"Asia/Shanghai (GMT+8) offset 28800" systemTimezone: string; // 系统时间 如:"15:40:21" systemTime: string; // 系统日期 "2017-08-11" since 8.3. systemDate: string; // 纬度 如:"31.251161" lat: string; // 经度 如:"120.730246" lon: string; // 短信内容权限 "0":无权限, "1":有权限 msgCompetence: '0' | '1'; // 屏幕亮度 范围:0.00--1.00 screenBrightness: string; // 是否在充电 "0":否 "1":是 charging: '0' | '1'; // 是否是留海屏 "0":否 "1":是 hasCutOut: string; } export class GetDeviceInfo<K> extends BridgePlugin<void, K> { protected get ntvPluginName() { return '_ntv_user_get_device_info'; } protected get availableMinVersion() { return '1.0.0'; } protected bridgeExecChrome(cbPluginName?: string | undefined, cbTagName?: string | undefined): void { // 可针对不同运行环境实现特定的调用逻辑来MOCK,弥补平台差异性. throw new Error('GetDeviceInfo() 未针对当前环境实现'); } } /** * 获取Naitve设备端信息 * @returns IDeviceInfo */ export const getDeviceInfo = () => { return new GetDeviceInfo<IGetDeviceInfoResult>().invokeOnce().then(result => { return result.cbData; }); }