my.choosePhoneContact

Select the phone number of a contact in the local system directory.

Supported types of mini programs: DSL, H5+  

Sample Code

copy
//.json
{
   "defaultTitle": "Contact"
}
copy
<!-- .axml -->
<view class="page">

  <view class="page-description">Contact API</view>

  <view class="page-section">
    <view class="page-section-title">my.choosePhoneContact</view>
    <view class="page-section-demo">
      <button type="primary" onTap="choosePhoneContact">Evoke local directory</button>
    </view>
  </view>

  </view>

</view>
copy
//.js
Page({
  choosePhoneContact() {
    my.choosePhoneContact({
      success: (res) => {
        my.alert({
          content: 'choosePhoneContact response: ' + JSON.stringify(res)
        });
      },
      fail: (res) => {
        my.alert({
          content: 'choosePhoneContact response: ' + JSON.stringify(res)
        });
      },
    });
  }
});

Parameters

Object type with the following attributes:

PropertyType

Required

Description
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 Codes

Error codeError message

Further action

11

User cancels or device does not have contact permission

Check whether the app has permission to access contacts.