/** * Indicates the Json types, incldue `undefind` cause of * Sometimes we allow some typing property is optional. */ export type Json = undefined | null | boolean | number | string | Json[] | { [prop: string]: Json; }; /** * 选择通讯录 */ export type FabricUtilsGetContactOptions = { /** * 单选还是多选. 默认只允许选择一个联系人 * @default false */ multi: boolean; }; /** * 返回通讯录列表 */ export type FabricUtilsGetContactsCallbackData = { contacts: Array<{ mobile: string[]; contactName: string; }>; }; /** * 选择通讯录, 会弹出通讯录界面, 让用户选择单个联系人 */ export type FabricUtilsGetContactApi = (options: FabricUtilsGetContactOptions) => Promise; /** * 获取通讯录列表, 异步调用 */ export type FabricUtilsGetContactsApi = () => Promise; /** * 获取重力感应毁掉数据 */ export type FabricGetGravityCallbackData = { /** * 状态 0:不支持 ; 1:成功 ; 2:失败 */ status: "0" | "1" | "2"; /** * 重力信息 */ gravityInfo?: { x: string; y: string; z: string; }; }; /** * 获取重力感应信息, 使用异步实现来 */ export type FabricUtilsGetGravityApi = () => Promise; /** * 获取本机安装的app列表 */ export type FabricGetInstalledAppsCallbackData = { /** * 安装的app列表 */ appList?: Array<{ name: string; }>; }; /** * 获取本机安装的app列表 */ export type FabricUtilsGetInstalledAppsApi = () => Promise; /** * 返回当前是否有权限读取APP站外目录权限 * 用户同意后返回: { allowed: true },没有权限时跑出统一的权限拒绝错误码: ntv_permission_reject */ export type FabricUtilsGetOutsidePathReadPermissionCallbackData = { allowed: boolean; }; /** * 使用场景举例: * 判断文件存储的路径是否是存储截屏图片的目录,来监听用户动作是否是截屏操作 */ export type FabricUtilsGetOutsidePathReadPermissionApi = () => Promise; export type FabricUtilsGetOutsidePathReadPermissionStatusApi = () => FabricUtilsGetOutsidePathReadPermissionCallbackData; export type FabricUtilsGetPermissionOptions = { type: "camera" | "microphone"; }; export type FabricUtilsGetPermissionApi = (options: FabricUtilsGetPermissionOptions) => Promise<{}>; /** * 获取本地运行时配置的动态数据, 比如调试工具提供的`tagline`, 自定义`accessToken` */ export type FabricGetRuntimeConfigCallbackData = { /** * 客户端调试工具模拟的并行环境tagline?, 对应APP需要去实现. * 注意并行环境的使用业务侧当下需要排除掉生产环境或者准生产环境, 避免生产日志干扰. */ tagline?: string; /** * 客户端调试工具模拟的accessToken?, 对应APP需要去实现. */ accessToken?: string; }; declare const getRuntimeConfig: () => Partial; /** * 在竖屏正方向下的安全区域 */ export type SafeArea = { /** * 安全区域左上角横坐标 * @example iphonex `44` */ left: number; /** * 安全区域右下角横坐标 * @example iphonex `375` */ right: number; /** * 安全区域左上角纵坐标 * @example iphonex `44` */ top: number; /** * 安全区域右下角纵坐标 * @example iphonex `778` */ bottom: number; /** * 安全区域的宽度,单位逻辑像素 * @example iphonex `375` */ width: number; /** * 安全区域的高度,单位逻辑像素 * @example iphonex `734` */ height: number; }; /** * 获取标准系统设备信息 */ export type FabricGetSystemInfoCallbackData = { /** * 设备品牌 */ brand: string; /** * 设备型号。新机型刚推出一段时间会显示unknown,微信会尽快进行适配。 * case "iPod1,1": return "iPod Touch 1G" * case "iPod2,1": return "iPod Touch 2G" * case "iPod3,1": return "iPod Touch 3G" * case "iPod4,1": return "iPod Touch 4G" * case "iPod5,1": return "iPod Touch (5 Gen)" * case "iPod7,1": return "iPod touch 6G" * ///iphone * case "iPhone1,1": return "iPhone 1G" * case "iPhone1,2": return "iPhone 3G" * case "iPhone2,1": return "iPhone 3GS" * case "iPhone3,1", "iPhone3,2", "iPhone3,3": return "iPhone 4" * case "iPhone4,1": return "iPhone 4S" * case "iPhone5,1", "iPhone5,2": return "iPhone 5" * case "iPhone5,3","iPhone5,4": return "iPhone 5C" * @example `iPhone X` */ model: string; /** * 设备像素比 * @example `3` */ pixelRatio: number; /** * 屏幕宽度,单位px * @example iphonex `375` */ screenWidth: number; /** * 屏幕高度,单位px * @example '768' */ screenHeight: number; /** * 屏幕真实高度,在刘海屏的时候不会减去刘海屏高度,单位px, android独有. * @example '804' */ realScreenHeight?: number; /** * 可使用窗口宽度,单位px * @example iphonex `375` */ windowWidth: number; /** * 可使用窗口高度,单位px * @example iphonex `642` */ windowHeight: number; /** * 状态栏的高度,单位px * @example `44` */ statusBarHeight: number; /** * 设置的语言, 默认`zh_CN` */ language: string; /** * 客户端平台 * @example `devtools` */ platform: string; /** * 地理位置定位能力是否可用, 如果定位被用户强制关闭, 或者在设置里面禁用了则为不可用, 如果能弹出让用户授权允许的弹窗认为是可用. * 此值参考值, 如果用户初次进入app打开了定位授权, 中途用户自行关闭了设置, 这个值不会得到及时更新, 如果需要及时准确请使用插件`get_location` */ locationEnabled: boolean; /** * Wi-Fi 的系统开关 */ wifiEnabled: boolean; /** * 在竖屏正方向下的安全区域 */ safeArea: SafeArea; /** * IOS 专有, true 表示模糊定位,false 表示精确定位 */ locationReducedAccuracy: boolean; /** * 统当前主题,取值为light或dark,全局配置"darkmode":true时才能获取,否则为 undefined (不支持小游戏) */ theme: "dark" | "light"; /** * 是否已打开调试。可通过右上角菜单或 fabric.setEnableDebug 打开调试。 */ enableDebug: boolean; /** * 设备方向 * @example `portrait` */ deviceOrientation: "portrait" | "landscape"; /** * 操作系统及版本 * @example `iOS 10.0.1` */ system: string; /** * 当前应用的名字. */ appName: string; /** * App版本号, 当前应用的版本号.`1.0.0` */ appVersion: string; /** * 纬度,范围为 -90~90,负数表示南纬, 获取缓存的版本 * `getLocation`插件会更新此缓存 */ latitude: string; /** * 经度,范围为 -180~180,负数表示西经, 获取缓存的版本 * `getLocation`插件会更新此缓存 */ longitude: string; /** * IOS 专有 */ idfa?: string; /** * Android 设备特有, IOS 无法获取 */ mac?: string; /** * 渠道, ios只有一个appStore */ appChannel?: string; /** * Android 设备特有 * 规则就行imei > oaid > android_id */ androidId?: string; /** * Android 设备特有, 移动设备国际身份码 15位数字组成,有一定编码规则 */ imei?: string; /** * Android 设备特有 */ oaid?: string; /** * 网络类型 * @example 'WIFI | GPRS | 2G | 2.75G Edge | 3G | 3.5G HSDPA | 3.5G HSUPA | HRPD | 4G | 5G | 5G NSA' */ networkType: string; /** * clientIP地址, android:1; iOS:1 * @example '10.10.35.37' */ clientIp: string; /** * 设备号, 每个设备生成的唯一值, 标识当前设备, 相对稳定 * @example '63A20CC9-9978-42B7-9689-771F415A6B75' */ deviceId: string; /** * refId, 渠道ID, 当前应用的下载渠道, android独有. * @example '5866741' */ refId: string; /** * 设备标识符, ios独有. */ adid?: string; /** * 设备指纹 */ deviceToken: string; /** * 设备名称 * @example 'OPPO Reno9 5G'、'iPhone14,2' */ deviceName: string; }; /** * 获取系统扩展信息。 */ export type FabricGetSystemInfoExtendCallbackData = { /** * APP数量 * @example '' */ appAmt: string; /** * 是否充电 */ charging: boolean; /** * 系统是否已录入指纹 */ isEnrolledFingerPrints: boolean; /** * 系统是否已录入人脸 */ isEnrolledFacePrints: boolean; /** * 是否刷机 */ isRoot: boolean; /** * 是否支持人脸 */ isSupportFaceID: boolean; /** * 是否设置锁屏密码,1代表是 */ isKeyguardSecure: boolean; /** * 是否支持指纹解锁,1代表是 */ isSupportTouchID: boolean; /** * 系统时区 * @example 'Asia/Shanghai (GMT+8) offset 28800' */ systemTimezone: string; /** * 推送通知app内部开关 与 appNotifySwitch 相同 */ systemNotifySwitch: boolean; /** * 系统日期包含时间戳 * @example 1637894302771 */ systemDate: string; /** * 支持视频分辨率范围 * @example ['4032x3024', '192x144']; */ videoResolutionRanges: string[]; /** * 可自由使用存储容量,kb单位 * @example 151594816 */ freeDiskSpace: string; /** * 短信内容权限 */ msgCompetence: boolean; /** * 全部存储空间容量,kb单位 * @example 249880148 */ totalDiskSpace: string; /** * 国际移动用户识别码 经常变更随机值 */ imsi: string; /** * 电池状态,0-1值,1代表满电,0代表空电 * @example '0.50' */ soc: string; /** * 支持图片分辨率范围 * @example ['4032x3024', '192x144'] */ photoResolutionRanges: string[]; /** * 屏幕亮度 0 - 1 * @example 0.76 */ screenBrightness: string; /** * 推送通知app内部开关 */ appNotifySwitch: boolean; /** * 可自由使用的运行内存容量,kb单位 * @example 1246960 */ freeRAM: string; /** * sim卡卡号,标准20位,各家运营商逻辑略有不同,可查询归属地 */ iccid: string; /** * 风控要求参考旅行APP拼接的设备拓展信息,ios、android拼接规则不同 * Android拼接规则:"4^" + 系统版本 + ",5^" + 手机型号 + ",6^" + 网络类型 * Ios拼接规则: "2^\(AppInfo.bundleIdentifier),4^\(DeviceInfo.getDeviceSystemVersion()),5^\(DeviceInfo.getDeviceCode())" * @example android: '4^13,5^PHM110,6^WIFI' * @example ios: '2^com.ly.wallet,4^16.2,5^iPhone14,2' */ extend?: string; }; declare enum SupportedRuntimeObject { imei = "imei", location = "location" } export type FabricGetSystemRuntimeInfoOptions = { /** * 当前需要实时获取的Native对象(location,...) */ objects: Array; }; export type FabricGetSystemRuntimeInfoCallbackData = { [key in keyof typeof SupportedRuntimeObject]: Json; }; export type FabricGetSystemRuntimeInfoApi = (options: FabricGetSystemRuntimeInfoOptions) => Promise; /** * PDFviewer参数选项 */ export type FabricUtilsOpenPdfViewerOptions = { /** * PDF网络地址 */ url: string; /** * PDF显示的标题 */ title?: string; /** * 是否禁止录屏、截图 */ disableScreenRecord?: boolean; }; export type FabricUtilsOpenPdfViewerCallbackFunc = (data: FabricUtilsOpenPdfViewerCallbackData) => void; export type FabricUtilsOpenPdfViewerApi = (options: FabricUtilsOpenPdfViewerOptions, callback?: FabricUtilsOpenPdfViewerCallbackFunc) => void; export type FabricUtilsOpenPdfViewerCallbackData = { state: "onLoad" | "onShow" | "onHide" | "onDestroy" | "onScrollBottom" | "onBackground"; }; export type FabricUtilsOpenAppSettingsOptions = { type: "permission" | "location"; } | undefined; export type FabricUtilsOpenAppSettingsApi = (options?: FabricUtilsOpenAppSettingsOptions) => Promise; export type FabricUtilsScanQrCodeOptions = { needResult?: boolean; }; export type FabricUtilsScanQrCodeResult = { content: string; }; export type FabricUtilsScanQrCodeApi = (options: FabricUtilsScanQrCodeOptions) => Promise; /** * 打开发短信应用, 并初始化接受者电话, 短信内容 */ export type FabricUtilsSendTextMsgOptions = { /** * 接受者电话 */ receiver?: string; /** * 短信内容 */ body?: string; }; export type FabricUtilsSendTextMsgApi = (options: FabricUtilsSendTextMsgOptions) => Promise; /** * 打电话 */ export type FabricUtilsCallPhoneNumberOptions = { /** * 手机号码 */ phone: string; }; export type FabricUtilsCallPhoneNumberApi = (options: FabricUtilsCallPhoneNumberOptions) => Promise; export type FabricUtilsApi = { /** * 选择通讯录, 会弹出通讯录界面, 让用户选择单个联系人 */ getContact: FabricUtilsGetContactApi; /** * 获取通讯录列表, 异步调用 */ getContacts: FabricUtilsGetContactsApi; /** * 检查当前是否有权限获取通讯录信息, 业务上可能在有权限再去获取, 避免权限弹窗干扰. */ getContactsPermissionStatus: () => boolean; /** * 获取本机安装的app列表 */ getInstalledApps: FabricUtilsGetInstalledAppsApi; /** * 获取本地运行时配置的动态数据, 比如调试工具提供的`tagline`, 自定义`accessToken` */ getRuntimeConfig: typeof getRuntimeConfig; /** * 获取系统信息, 使用同步实现来返回。 */ getSystemInfo: () => FabricGetSystemInfoCallbackData; /** * 获取系统扩展信息, 使用同步实现来返回, 增强设备端信息获取. 有合规风险 */ getSystemInfoExtend: () => FabricGetSystemInfoExtendCallbackData; /** * 异步获取当前设备需要动态获取权限的API */ getSystemRuntimeInfo: FabricGetSystemRuntimeInfoApi; /** * 获取重力感应毁掉数据, 会使用同步实现来返回。 */ getGravityInfo: FabricUtilsGetGravityApi; /** * 设置系统剪贴板的内容。调用成功后,会弹出 toast 提示"内容已复制",持续 1.5s */ setClipboardData: (data: Json) => Promise; /** * 获取系统剪贴板的内容 */ getClipboardData: () => Promise; /** * 打开PDF文件预览 */ openPdfViewer: FabricUtilsOpenPdfViewerApi; /** * 扫描二维码 */ scanQrCode: FabricUtilsScanQrCodeApi; /** * 拨打手机号码 */ callPhoneNumber: FabricUtilsCallPhoneNumberApi; /** * 打开应用设置面板. */ openAppSettings: FabricUtilsOpenAppSettingsApi; /** * 打开发短信应用, 并初始化接受者电话, 短信内容 */ sendTextMsg: FabricUtilsSendTextMsgApi; /** * Android专用,异步调用 * 向用户索要APP站外目录读取权限 */ getOutsidePathReadPermissionStatus: FabricUtilsGetOutsidePathReadPermissionStatusApi; getOutsidePathReadPermission: FabricUtilsGetOutsidePathReadPermissionApi; /** * 获取权限 */ getPermission: FabricUtilsGetPermissionApi; }; export declare const fabricUtils: FabricUtilsApi; export {};