All Products
Search
Document Center

Mobile Platform as a Service:Can I use

Last Updated:Feb 05, 2021

my.canIUse(String)

This API is supported in mPaaS 10.1.32 and later versions.

This interface is used to determine whether the current version supports the API, input parameters or return values, components, attributes, etc. of the current MINI.

Input parameter

The parameters are called by the ${API}.${type}.${param}.${option} or ${component}.${attribute}.${option} method.

  • API: Indicates the API name, exclude the name of my.. For example: if you want to judge my.getFileInfo, you only need to pass in getFileInfo.
  • type: Possible values are object/return/callback, which indicates the judgment type of the API.
  • param: Indicates an attribute name of the parameter.
  • option: Indicates the specific attribute value of the parameter attribute.
  • component: Indicates the component name.
  • attribute: Indicates the component attribute name.
  • option: Indicates the component attribute value.

Code sample

  1. // Whether the new API is available
  2. my.canIUse('getFileInfo')
  3. // Whether the new API attribute is available
  4. my.canIUse('closeSocket.object.code')
  5. // Whether the new API attribute is available
  6. my.canIUse('getLocation.object.type')
  7. // Whether the new attribute of the API return value is available
  8. my.canIUse('getSystemInfo.return.brand')
  9. // Whether the new component "Follow lifestyle account" is available
  10. my.canIUse('lifestyle')
  11. // Whether the new attribute value of the component is available
  12. my.canIUse('button.open-type.share')

Return value

Boolean type, indicating whether it is supported.