All Products
Search
Document Center

Mobile Platform as a Service:System info

Last Updated:Feb 05, 2021

my.getSystemInfo

This API is supported in mPaaS 10.1.32 and later versions.

This interface is used for system information.

Input parameter

Name Type Required Description
success Function No Callback function for successful call
fail Function No Callback function for failed call
complete Function No Callback function for ended call (executed regardless of whether the call is successful or failed)

success return value

Name Type Description Minimum Version
model String Phone model -
pixelRatio Number Device pixel ratio -
windowWidth Number Window width -
windowHeight Number Window height -
language String Language set by the application -
version String Application version number -
storage String Device disk capacity 1.1.1
currentBattery String Percentage of current battery 1.1.1
system String System version 1.1.1
platform String System name: Android, iOS / iPhone OS 1.1.1
titleBarHeight Number Title bar height
Description: This return value is only supported by version 10.1.60.
1.1.1
statusBarHeight Number Status bar height
Description: This return value is only supported by version 10.1.60.
1.1.1
screenWidth Number Screen width 1.1.1
screenHeight Number Screen height 1.1.1
brand String Mobile phone brand 1.4.0
fontSizeSetting Number Users set font size
Description: This return value is only supported by version 10.1.60.
1.4.0
app String The currently running client. -

Model parameter

For iPhone, the iPhone internal code (Internal Name) is returned in the model parameter. The iPhone model and the corresponding model return values are shown in the following table:

iPhone model model return value
iPhone iPhone11
iPhone 3G iPhone12
iPhone 3GS iPhone21
iPhone 4 iPhone31 / iPhone32 / iPhone33
iPhone 4S iPhone41
iPhone 5 iPhone51 / iPhone52
iPhone 5S iPhone61 / iPhone62
iPhone 6 iPhone72
iPhone 6 Plus iPhone71
iPhone 6S iPhone8,1
iPhone 6S Plus iPhone8,2
iPhone 7 iPhone9,1 / iPhone9,3
iPhone 7 Plus iPhone9,2 / iPhone9,4
iPhone 8 iPhone10,1 / iPhone10,4
iPhone 8 Plus iPhone10,2 / iPhone10,5
iPhone X iPhone10,3 / iPhone10,6
iPhone XR iPhone11,8
iPhone XS iPhone11,2
iPhone 11 iPhone12,1
iPhone 11 Pro iPhone12,3
iPhone XS Max iPhone11,6 / iPhone11,4
iPhone 11 Pro Max iPhone12,5

Code sample

  1. // API-DEMO page/API/get-system-info/get-system-info.json
  2. {
  3. "defaultTitle": "Get phone system info"
  4. }
  1. <!-- API-DEMO page/API/get-system-info/get-system-info.axml-->
  2. <view class="page">
  3. <view class="page-section">
  4. <view class="page-section-demo">
  5. <text>Phone model</text>
  6. <input type="text" disabled="{{true}}" value="{{systemInfo.model}}"></input>
  7. </view>
  8. <view class="page-section-demo">
  9. <text>Language</text>
  10. <input type="text" disabled="{{true}}" value="{{systemInfo.language}}"></input>
  11. </view>
  12. <view class="page-section-demo">
  13. <text>Version</text>
  14. <input type="text" disabled="{{true}}" value="{{systemInfo.version}}"></input>
  15. </view>
  16. <view class="page-section-demo">
  17. <text>Window width</text>
  18. <input type="text" disabled="{{true}}" value="{{systemInfo.windowWidth}}"></input>
  19. </view>
  20. <view class="page-section-demo">
  21. <text>Window height</text>
  22. <input type="text" disabled="{{true}}" value="{{systemInfo.windowHeight}}"></input>
  23. </view>
  24. <view class="page-section-demo">
  25. <text>DPI</text>
  26. <input type="text" disabled="{{true}}" value="{{systemInfo.pixelRatio}}"></input>
  27. </view>
  28. <view class="page-section-btns">
  29. <view onTap="getSystemInfo">Get phone system info</view>
  30. <view onTap="getSystemInfoSync">Get phone system info synchronously</view>
  31. </view>
  32. </view>
  33. </view>
  1. // API-DEMO page/API/get-system-info/get-system-info.js
  2. Page({
  3. data: {
  4. systemInfo: {}
  5. },
  6. getSystemInfo() {
  7. my.getSystemInfo({
  8. success: (res) => {
  9. this.setData({
  10. systemInfo: res
  11. })
  12. }
  13. })
  14. },
  15. getSystemInfoSync() {
  16. this.setData({
  17. systemInfo: my.getSystemInfoSync(),
  18. });
  19. },
  20. })

my.getSystemInfoSync

This API is supported in mPaaS 10.1.32 and later versions.

A synchronization interface for obtaining mobile phone system information. The return value is the same as the success callback parameter of getSystemInfo.

This interface is a synchronous interface and has a timeout judgment. When it times out, the interface returns undefined.

Code sample

  1. // API-DEMO page/API/get-system-info/get-system-info.json
  2. {
  3. "defaultTitle": "Get phone system info"
  4. }
  1. <!-- API-DEMO page/API/get-system-info/get-system-info.axml-->
  2. <view class="page">
  3. <view class="page-section">
  4. <view class="page-section-demo">
  5. <text>Phone model</text>
  6. <input type="text" disabled="{{true}}" value="{{systemInfo.model}}"></input>
  7. </view>
  8. <view class="page-section-demo">
  9. <text>Language</text>
  10. <input type="text" disabled="{{true}}" value="{{systemInfo.language}}"></input>
  11. </view>
  12. <view class="page-section-demo">
  13. <text>Version</text>
  14. <input type="text" disabled="{{true}}" value="{{systemInfo.version}}"></input>
  15. </view>
  16. <view class="page-section-demo">
  17. <text>window width</text>
  18. <input type="text" disabled="{{true}}" value="{{systemInfo.windowWidth}}"></input>
  19. </view>
  20. <view class="page-section-demo">
  21. <text>Window height</text>
  22. <input type="text" disabled="{{true}}" value="{{systemInfo.windowHeight}}"></input>
  23. </view>
  24. <view class="page-section-demo">
  25. <text>DPI</text>
  26. <input type="text" disabled="{{true}}" value="{{systemInfo.pixelRatio}}"></input>
  27. </view>
  28. <view class="page-section-btns">
  29. <view onTap="getSystemInfo">Get phone system info</view>
  30. <view onTap="getSystemInfoSync">Get phone system info synchronously</view>
  31. </view>
  32. </view>
  33. </view>
  1. // API-DEMO page/API/get-system-info/get-system-info.js
  2. Page({
  3. data: {
  4. systemInfo: {}
  5. },
  6. getSystemInfo() {
  7. my.getSystemInfo({
  8. success: (res) => {
  9. this.setData({
  10. systemInfo: res
  11. })
  12. }
  13. })
  14. },
  15. getSystemInfoSync() {
  16. this.setData({
  17. systemInfo: my.getSystemInfoSync(),
  18. });
  19. },
  20. })