UI APIs

choosePhoneContact

Select a phone number from the device's contact directory.

Overview

my.choosePhoneContact allows users to select a phone number from their local system directory. This API opens the device's contact picker and returns the selected contact's information.

Sample Code

my.choosePhoneContact({
  success: (res) => {
    my.alert({
      content: 'choosePhoneContact response: ' + JSON.stringify(res)
    });
  },
  fail: (res) => {
    my.alert({
      content: 'choosePhoneContact response: ' + JSON.stringify(res)
    });
  },
});

Parameters

PropertyTypeRequiredDescription
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback function upon call completion (to be executed upon either call success or failure).

Success Callback Function

The incoming parameter is of the Object type with the following attributes:

PropertyTypeDescription
nameStringSelected contact name.
mobileStringSelected contact phone.

Error Code

Error CodeDescription
10No permission.
11The user cancels the operation (or the device does not authorize use of the directory).

Usage Notes

  • Requires permission to access the device's contact list
  • User can cancel the operation at any time
  • The API will fail if permission is denied or not granted