Voice Call
  • iOS : Objective-C
  • Android
  • Web
  • Flutter
  • React Native
  • Electron
  • Unity3D
  • Cocos Creator
  • Windows
  • macOS
  • Linux
  • Overview
  • Develop your app
    • Integrate the SDK
    • Implement a basic voice call
    • Enhance basic feature
      • Use Tokens for authentication
      • Set up common audio config
      • Check the room connection status
  • Upgrade using advanced features
    • Advanced features
      • Configure the audio
        • Beautify & Change the voice
      • Improve audio quality
        • Test network and devices in advance
        • Monitor streaming quality
        • Visualize the sound level
      • Message signaling
        • Broadcast real-time messages to a room
        • Convey extra information using SEI
        • Quotas and limits
      • Play media files
        • Play media files
        • Play sound effects
      • Mix the streams
      • Record media data
      • Encrypt the streams
    • Distincitve features
      • Join multiple rooms
      • Customize the audio
      • Play streams via URL
      • Low-latency live streaming
  • Resources & Reference
    • SDK
    • Sample code
    • API reference
    • Debugging
    • FAQs
    • Key concepts
  • Documentation
  • Voice Call
  • Resources & Reference
  • Sample code
Sample code
Download

Sample source code running guide

This article describes how to quickly run the sample source code and experience basic audio and video calling services.

1 Prepare the environment

Before you run the sample source code, make sure that the development environment meets the following requirements:

  • Xcode 13.0 or above.
  • iOS devices or simulators with iOS 9.0 or above that support audio and video (real devices are recommended).
  • The iOS device is connected to the Internet.

2 Prerequisites

Go to ZEGOCLOUD Admin Console to create a new project, and get the AppID and AppSign of your project.

The SDK now also supports using Token for authentication, if you want to change your authentication mode, refer to the Guide for upgrading the authentication mode from using the AppSign to Token.

3 Sample source code directory structure

The following directory structure is the file structure of the ios_objc subdirectory, and the file paths mentioned below are all relative to this directory.

.
├─ DownloadSDK.sh
├─ Libs # ZegoExpressVideo iOS SDK storage directory
├─ README.md
├─ README_zh.md
├─ VERSION.txt
├─ ZegoExpressExample
|    ...
│    ├─ Examples 
│    │    ├─ AdvancedAudioProcessing   # Advanced audio features
│    │    ├─ AdvancedStreaming         # Advanced stream publish and play
│    │    ├─ AdvancedVideoProcessing   # Advanced video features
│    │    ├─ CommonFeatures            # Common functions
│    │    ├─ Debug&Config              # Debug and configure
│    │    ├─ Others                    # Other functions
│    │    ├─ QuickStart                # Quick start
│    │    └─ Scenes                    # Best practices
|    ...
│    ├─ Info.plist
│    ├─ KeyCenter.h
│    ├─ KeyCenter.m # Fill in the AppID and AppSign of the application
│    ...
└─ ZegoExpressExample.xcodeproj  # Demo engineering documents

4 Run the sample source code

  1. Open AppStore, search for "Xcode", and download and install it.

  2. Open the ZegoExpressExample.xcodeproj file by using Xcode.

  3. Open Xcode and select File > Open... in the upper-left corner.

  4. In the decompressed sample source code folder, select the ZegoExpressExample.xcodeproj file and open it.

  5. Log in to your Apple developer account.

  6. Open Xcode and select Xcode > Preferences... in the upper-left corner.

    /Pics/iOS/ZegoExpressEngine/Common/xcode_preferences.png

  7. Click the Accounts tab, click the plus (+) icon in the lower-left corner, select Add Apple ID, and click Continue.

  8. Enter your Apple ID and password to log in.

  9. Modify the Bundle identifier and developer certificate.

  10. Open Xcode and click the "ZegoExpressExample" project on the left.

  11. Open the TARGETS option. Developers can click the General tab to modify the Bundle identifier of the project based on their needs and click the Signing & Capabilities tab to select the developer certificate.

    /Pics/iOS/ZegoExpressEngine/Common/bundle_id.png
    /Pics/iOS/ZegoExpressEngine/Common/team_signing_new.png

  12. The AppID and AppSign required for SDK initialization are missing in the sample source code, and the /ZegoExpressExample/KeyCenter.m file needs to be modified. Please use the AppID and AppSign mentioned in the Prerequisites to fill in the information correctly. Otherwise, the example source code cannot run properly.

/Pics/QuickStart/sample_code/sample_code_ios.png

  1. Connect the iOS device to the development computer, click Any iOS Device on Xcode, and select the iOS device or simulator in the pop-up window.

    /Pics/iOS/ZegoExpressEngine/Common/xcode_select_device_new.png
    /Pics/iOS/ZegoExpressEngine/Common/xcode_select_real_device_new.png

  2. Click Build in the upper-left corner of Xcode to compile and run the sample source code.

    /Pics/iOS/ZegoExpressEngine/Common/build_and_run_new.png

5 Experience audio and video calling/live streaming function

We recommend you run your project on a real device. If your app runs successfully, you should hear the sound and see the video captured locally from your device.

To test out the real-time audio and video features, visit the ZEGO Express Web Demo, and enter the same AppID, Server and RoomID to join the same room. If it runs successfully, you should be able to view the video from both the local side and the remote side, and hear the sound from both sides as well.

In audio-only scenarios, no video will be captured and displayed.

Page Directory