All Products
Search
Document Center

Intelligent Media Services:iOS

Last Updated:Dec 09, 2025

This topic walks you through integrating an AI agent into an iOS application for real-time messaging.

Source code

Download link

Go to GitHub repository to download the source code.

Directory structure

├── iOS  // The root directory.
│   ├── AUIAICall.podspec                // The pod specification file.
│   ├── Source                                    // The source code files.
│   ├── Resources                                 // The resource files.
│   ├── Example                                   // The source code of the demo.
│   ├── AUIBaseKits                               // The basic UI components. 
│   ├── README.md                                 // Readme  

Environment requirements

  • Xcode: V16.0 or later, preferably the latest official version

  • CocoaPods: V1.9.3 or later

  • iOS device: iOS 11.0 or later

Before you begin

Develop relevant API operations on your server or deploy the provided server source code. For more information, see Deploy a project.

Run the demo

  1. After downloading the source code, open the Example folder.

  2. Run the command pod install --repo-update to install the required SDKs.

  3. Open the AUIAICallExample.xcworkspace project file and modify the package ID.

  4. Configure the AI agent ID and region in the AUIAICallAgentConfig.swift file.

    // AUIAICallAgentConfig.swift
    let ChatAgentId = "AI agent ID"
    let Region = "Region where the agent was created"

    Region

    Region ID

    China (Hangzhou)

    cn-hangzhou

    China (Shanghai)

    cn-shanghai

    China (Beijing)

    cn-beijing

    China (Shenzhen)

    cn-shenzhen

    Singapore

    ap-southeast-1

  5. After completing the agent configuration, you can start the agent using one of the following methods:

    • When the app server is deployed: If you have deployed the source code provided by Alibaba Cloud on your app server, go to the AUIAICallAppServer.swift and modify the server domain: 

      // AUIAICallAppServer.swift
      public let AICallServerDomain = "Your app server domain"
    • When the app server is not deployed: If you have not yet deployed the source code on your app server and need to run the demo for trial, go to the AUIAIChatAuthTokenHelper.swift file, configure the EnableDevelopToken parameter, and copy the application ID, AppKey, and AppSign of the Interactive Messaging (IM) application used by the agent from the console to generate the authentication token on the client side.

      Important

      This method requires embedding your AppKey and other sensitive information into your application. It is for testing and development only. Never use this method in a production environment. Exposing your AppKey on the client side creates a serious security risk.

      // AUIAIChatAuthTokenHelper.swift
      @objcMembers public class AUIAIChatAuthTokenHelper: NSObject {
      
          // Set the value to true to enable Develop mode.
          private static let EnableDevelopToken: Bool = true     
          // AppId of IM application copied from the console.
          private static let IMDevelopAppId: String = "AppId of IM application"
          // AppKey of IM application copied from the console.
          private static let IMDevelopAppKey: String = "AppKey of IM application"
          // AppSign of IM application copied from the console.
          private static let IMDevelopAppSign: String = "AppSign of IM application"
          ...
      }
  6. Select the Example target and run the project.

Develop Conversational AI capabilities

Perform the following steps to integrate AUIAICall into your app:

Integrate the source code

  1. Import AUIAICall

    Copy the downloaded iOS folder to your app's code directory and rename it AUIAICall. Make sure that the folder is at the same level as your Podfile. You can delete the Example and AICallKit directories. 

  2. Modify your Podfile to include the following modules:

    • AliVCSDK_ARTC: the ApsaraVideo MediaBox SDK that supports ApsaraVideo Real-time Communication (ARTC). You can also import AliVCSDK_Standard or AliVCSDK_InteractiveLive. For more information, see iOS.

    • AliVCInteractionMessage: the SDK for interactive messaging. V1.5.0 or later is required.

    • ARTCAICallKit: the SDK for AI real-time interaction.

    • AUIFoundation: the basic UI components. 

    • AUIAICall: the source code of UI components for AI calls.

    # iOS 11.0 or later is required. 
    platform :ios, '11.0'
    
    target 'App target' do
        # Select an SDK that supports ARTC. Supported SDKs: AliVCSDK_ARTC, AliVCSDK_Standard, and AliVCSDK_InteractiveLive
        pod 'AliVCSDK_ARTC', '~> x.x.x'
    
        # The SDK for Real-time Conversational AI.
        pod 'ARTCAICallKit/Chatbot', '~> x.x.x'
    
        # The basic UI components. 
        pod 'AUIFoundation', :path => "./AUIAICall/AUIBaseKits/AUIFoundation/", :modular_headers => true
    
        # The source code of UI components for AI calls. 
        pod 'AUIAICall/Chatbot',  :path => "./AUIAICall/"
    
        # The SDK for interactive messaging. Version 1.7.0 or later is required.
        pod 'AliVCInteractionMessage', '~> x.x.x'
    
    end
    Note
    • The minimum compatible version of the ARTC SDK is V7.1.0. Latest version: 7.8.1.

    • Latest version of AICallKit SDK: 2.9.0.

    • Latest version of AliVCInteractionMessage: 1.8.0.

  3. Run pod install --repo-update. The source code is integrated.

Configure the project

  1. Open the info.Plist file in your project and add the following permissions: NSMicrophoneUsageDescription and NSCameraUsageDescription.

  2. In the project settings, enable Background Modes on the Signing & Capabilities tab. If it's disabled, you must develop code to end calls after they are switched to the background. 

Configure the source code

After you complete all the steps above, modify the server domain name in the AUIAICallAppServer.swift file.

// AUIAICallAppServer.swift
public let AICallServerDomain = "Domain name of your app server"
Note

If you have not deployed the app server, you can generate a token on the client side to test and run the demo. For more information, see Step 5 in "Run the demo" section.

Call API operations

After completing the above steps, call API operations in other modules of your app or on its homepage to start a conversation with the AI agent. You can also modify the source code as needed.

// Import modules.
import AUIAICall
import ARTCAICallKit
import AUIFoundation

// We recommend using the user ID for login.
let userId = "123"
// Set deviceId.
let deviceId = UIDevice.current.identifierForVendor?.uuidString
let userInfo = ARTCAIChatUserInfo(userId, deviceId)

// Configure the AI agent. The agent ID is required.
let agentId = "xxxxx"
let agentInfo = ARTCAIChatAgentInfo(agentId: agentId)

// Create ViewController for messaging.
let vc = AUIAIChatViewController(userInfo: userInfo, agentInfo: agentInfo)
// Open the conversation interface.
self.navigationController?.pushViewController(vc, animated: true)