uni.getSystemInfo(OBJECT)

获取系统信息。 OBJECT 参数说明: success 返回参数说明: Tips

  • safeArea 的结构 示例
    1. uni.getSystemInfo({ success: function (res) { console.log(res.model); console.log(res.pixelRatio); console.log(res.windowWidth); console.log(res.windowHeight); console.log(res.language); console.log(res.version); console.log(res.platform); }});

    uni.getSystemInfoSync()

    获取系统信息同步接口。 同步返回参数说明 Tips
  • safeArea 的结构 示例
    1. try { const res = uni.getSystemInfoSync(); console.log(res.model); console.log(res.pixelRatio); console.log(res.windowWidth); console.log(res.windowHeight); console.log(res.language); console.log(res.version); console.log(res.platform);} catch (e) { // error}
    获取设备标记 H5、小程序、iOS,属于对用户隐私保护比较严格的平台,在这些平台很难获取有效的设备唯一标记。 Android已经改进用户隐私保护,在很多新手机上,获取imei等信息时需要弹框让用户授权。
  • plus.device.getInfo 可以获得设备的唯一标识(uuid),这个id其实也是一种随机数概念。卸载app重装会发生变化;iOS还有一个叫idfa的广告识别符,可通过Native.js实现,在社区中搜索可见。
  • plus.device.getInfo 可以获得设备的国际移动设备身份码(imei)。注意很多新手机在获取imei时会弹框要求用户授权。plus.device.getInfo的API是从HBuilderX 2.0.3+开始提供的,老版需使用plus.devide.uuid或plus.device.imei。

    uni.canIUse(String)

    判断应用的 API,回调,参数,组件等是否在当前版本可用。 平台差异说明 String 参数说明 ${API}.${method}.${param}.${options} 或者 ${component}.${attribute}.${option} 方式来调用,例如:
  • ${API} 代表 API 名字
  • ${method} 代表调用方式,有效值为return, success, object, callback
  • ${param} 代表参数或者返回值
  • ${options} 代表参数的可选值
  • ${component} 代表组件名字
  • ${attribute} 代表组件属性
  • ${option} 代表组件属性的可选值示例
    1. uni.canIUse('getSystemInfoSync.return.screenWidth');uni.canIUse('getSystemInfo.success.screenWidth');uni.canIUse('showToast.object.image');uni.canIUse('request.object.method.GET');uni.canIUse('live-player');uni.canIUse('text.selectable');uni.canIUse('button.open-type.contact');

在 GitHub 上编辑此页面!