# Dial out with phone audio

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

> The code on this page works with either the **default UI** or the **custom UI**.

In some scenarios, you may want to use phone audio instead of VoIP audio. Use the SDK to call your phone number or to get the dial-in phone numbers and dial into the meeting to connect to meeting audio. The `ZoomSDKPhoneHelper` interface handles most of this functionality.

## Prerequisites

The meeting host account is Pro or above, and subscribes to the Audio Plan add-on.

## Verify feature support

Before using any phone functionality, use the method `isSupportPhone` to check whether the meeting supports basic phone features such as joining the meeting by phone. Then use the `isDialoutSupported` method to check if the meeting supports "call me" or "invite participants by phone" functionality.

```swift
if let phoneHelper = ZoomSDK.shared().getMeetingService()?.getPhoneHelper() {
    if phoneHelper.isSupportPhone() {
        // Phone audio is supported
        if phoneHelper.isDialoutSupported() {
            // Support phone dial-out features
        }
    }
}
```

```objectivec
ZoomSDKPhoneHelper *phoneHelper = [[[ZoomSDK sharedSDK] getMeetingService] getPhoneHelper];
if (phoneHelper) {
    if ([phoneHelper isSupportPhone]) {
        // Phone audio is supported
        if ([phoneHelper isDialoutSupported]) {
            // Support phone dial-out features
        }
    }
}
```

## Call in to the meeting

Instead of directly dialing out to a number, you can display a phone number for the user to call. `getCallInNumberInfo` provides a list of call-in numbers for the current meeting.

```swift
if let callInNumberInfo: [ZoomSDKCallInPhoneNumInfo] = phoneHelper.getCallInNumberInfo() as? [ZoomSDKCallInPhoneNumInfo] {
    // callInNumberInfo: A list of call-in numbers
}
```

```objectivec
NSArray<ZoomSDKCallInPhoneNumInfo *> *callInNumberInfo = [phoneHelper getCallInNumberInfo];
if (callInNumberInfo) {
    // callInNumberInfo: A list of call-in numbers
}
```

After getting the call in numbers, iterate through them to access data related to each number.

```swift
for numberInfo in callInNumberInfo {
    numberInfo.getCode() // country code
    numberInfo.getDisplayNumber() // whole display phone number (country code + number)
    numberInfo.getID() // country id
    numberInfo.getName() // country name
    numberInfo.getNumber() // call-in number
    numberInfo.getType() // phone number's call type
}
```

```objectivec
for (ZoomSDKCallInPhoneNumInfo *numberInfo in callInNumberInfo) {
    numberInfo.getCode; // country code
    numberInfo.getDisplayNumber; // whole display phone number (country code + number)
    numberInfo.getID; // country id
    numberInfo.getName; // country name
    numberInfo.getNumber; // call-in number
    numberInfo.getType; // phone number's call type
}
```

The phone number's call types can be either toll or toll-free.

-   `CallInNumberType_Toll` - toll numbers
-   `CallInNumberType_TollFree` - toll-free number
-   `CallInNumberType_None` - none of the above

## Start the phone call

To initiate phone audio, use the `callMe` method, providing the phone number and country code of the current user, to call the current user's phone as the meeting audio.

```swift
phoneHelper.callMe("PHONE_NUMBER", countryCode: "COUNTRY_CODE")
```

```objectivec
[phoneHelper callMe:@"PHONE_NUMBER" CountryCode:@"COUNTRY)CODE"];
```

You can also add a phone-audio-only user by providing the country code, phone number, and username. The username can be any value, but should be something identifiable and related to the user since it's visible to other participants in the meeting.

```swift
phoneHelper.inviteCalloutUser("USERNAME", phoneNumber: "PHONE_NUMBER", countryCode: "COUNTRY_CODE")
```

```objectivec
[phoneHelper inviteCalloutUser:@"USERNAME" PhoneNumber:@"PHONE_NUMBER" CountryCode:@"COUNTRY_CODE"];
```

End an in-session call by using the `hangUp` method.

```swift
phoneHelper.hangUp()
```

```objectivec
[phoneHelper hangUp];
```

## Get status updates

To get updates about the phone audio's call out status, conform your class to the `ZoomSDKPhoneHelperDelegate` protocol and add the delegate.

```swift
if let phoneHelper = ZoomSDK.shared().getMeetingService()?.getPhoneHelper() {
    phoneHelper.delegate = self
}

extension ViewController: ZoomSDKPhoneHelperDelegate {
    func onInviteCalloutUserStatus(_ status: PhoneStatus, failedReason reason: PhoneFailedReason) {

    }

    func onCallMeStatus(_ status: PhoneStatus, failedReason reason: PhoneFailedReason) {

    }
}
```

```objectivec
// In your .h file
@interface ZMSDKTestWindow : NSWindowController <ZoomSDKPhoneHelperDelegate> {

}

// In your .m file
ZoomSDKPhoneHelper *phoneHelper = [[[ZoomSDK sharedSDK] getMeetingService] getPhoneHelper];
if (phoneHelper) {
    phoneHelper.delegate = self;
}

- (void)onInviteCalloutUserStatus:(PhoneStatus)status FailedReason:(PhoneFailedReason)reason {

}

- (void)onCallMeStatus:(PhoneStatus)status FailedReason:(PhoneFailedReason)reason {

}
```

Within the listeners, you can get updates to `PhoneStatus` to know if a call is active and whether the request was successful.

-   `PhoneStatus_Calling` - The phone call is connecting.
-   `PhoneStatus_Ringing` - The phone call is connected and waiting for the other end to answer.
-   `PhoneStatus_Accepted` - The phone call has been answered.
-   `PhoneStatus_Success` - The phone call was successful.
-   `PhoneStatus_Failed` - The phone call has failed.
-   `PhoneStatus_Canceling`- The phone call is being cancelled.
-   `PhoneStatus_Canceled` - The phone call has been successfully cancelled.
-   `PhoneStatus_Cancel_Failed` - The SDK was unable to cancel the call.
-   `PhoneStatus_Timeout` - The call timed out.
-   `PhoneStatus_None` - Status unknown.

If a call fails, learn what caused the failure through the `PhoneFailedReason` enum.

-   `PhoneFailedReason_Busy` - The number dialed was busy.
-   `PhoneFailedReason_Not_Available` - The number dialed was disconnected or otherwise unable to connect.
-   `PhoneFailedReason_User_Hangup` - The phone number terminated the connection by hanging up.
-   `PhoneFailedReason_No_Answer` The phone call was not answered.
-   `PhoneFailedReason_Block_No_Host` - The call was not allowed because the host is not present.
-   `PhoneFailedReason_Block_High_Rate` - // The system blocks invite by phone due to the high cost.
-   `PhoneFailedReason_Block_Too_Frequent` - The rate limit for this feature has been hit. Please wait and try again later.
-   `PhoneFailedReason_Other_Fail` - The call failed for another reason.
-   `PhoneFailedReason_None` - The status was not related to a failure.

## Access call data

After a call has started, access additional data about the active call.

-   `callMeStatus` - The status of the call started by the `callMe` method.
-   `inviteCallOutUserStatus` - The status of the call started by the `inviteCallOutUser` method.
-   `supportCountryInfo` - A list of supported countries for the meeting. Each `PhoneSupportCountryInfo` object has 3 fields.
    -   `countryCode` - The country code at the start of the phone number.
    -   `countryID` - A unique identifier associated with the country.
    -   `countryName` - A human-readable name of the country.

```swift
phoneHelper.getCallMeStatus()
phoneHelper.getInviteCalloutUserStatus()
if let phoneSupportCountryInfoList = phoneHelper.getSupportCountryInfo() as? [ZoomSDKPhoneSupportCountryInfo] {
    for supportCountryInfo in phoneSupportCountryInfoList {
        supportCountryInfo.getCountryCode()
        supportCountryInfo.getCountryID()
        supportCountryInfo.getCountryName()
    }
}
```

```objectivec
phoneHelper.getCallMeStatus;
phoneHelper.getInviteCalloutUserStatus;
NSArray<ZoomSDKPhoneSupportCountryInfo *> *phoneSupportCountryInfoList =  [phoneHelper getSupportCountryInfo];
if (phoneSupportCountryInfoList) {
    for (ZoomSDKPhoneSupportCountryInfo *supportCountryInfo in phoneSupportCountryInfoList) {
        supportCountryInfo.getCountryCode;
        supportCountryInfo.getCountryID;
        supportCountryInfo.getCountryName;
    }
}
```

## End the call and remove the listener

When you are no longer using phone audio, remove the listener.

```swift
phoneHelper.delegate = nil
```

```objectivec
phoneHelper.delegate = nil;
```

---
