• iOS : Objective-C
  • Android
  • Web
  • Flutter
  • Introduction
  • Demo app
  • Sample codes
  • Client SDKs
    • SDK downloads
    • Release notes
  • Getting started
    • Integration
    • Start a room
  • Guides
    • Customize room parameters
    • Customize the room UI
    • Listen for room callbacks
    • Screen rotation support
    • Screen sharing
    • Manage rooms with Education Cloud Service
    • Use server event callbacks
  • Server APIs
  • Error codes
Sample code

Run the RoomKit sample code


  1. Contact ZEGO Sales to enable the RoomKit service and obtain your RoomKit Admin Console login account and password.
  2. Log in to RoomKit Admin Console to obtain the SecretID, SecretSign, and ProductID, which are required for initializing the RoomKit SDK.
  3. Make sure your development environment meets the following requirements:
  • Xcode 7.0 or later.
  • An iOS device or simulator running iOS 9.0 or later (we recommend you use a real device).
  • The iOS device is connected to the internet.
  • CocoaPods installed.

While the sample code shows that it is possible to get the SDK access token required for the subsequent login process by directly specifying the SecretID and SecretSign in the client code, don't use this approach when you develop your own app. To ensure system security, get the SDK access token by posting a Get SDK access token request from your application server to the RoomKit server.

Run the sample code

  1. Download the RoomKit sample code.

  2. Open Terminal, go to the directory where the Podfile is located, and run the command pod repo update to update the local dependency library index. This step may take a while ( about 3 to 20 minutes) to complete, depending on your network condition,

  3. Run the command pod install and wait for all the dependent libraries to be downloaded (the size of RoomKit related SDKs is about 300 MB).

  4. Double-click the file ZegoRoomkitDemo.xcworkspace in the unzipped folder.


  5. Change the bundle identifier and signing certificate.

    a. In the Xcode project navigator, click the project ZegoRoomkitDemo.


    b. Select the target ZegoRoomkitDemo, click Signing & Capabilities, then under Signing, choose your team from the Team pop-up menu, and change Bundle Identifier and App Groups to your own value. Repeat the same steps for the extension target ZegoRoomkitDemoScreenShare.

    For the target ZegoRoomkitDemo, change the settings as indicated below:


    For the extension target ZegoRoomkitDemoScreenShare, change the settings as indicated below:


  6. Modify the source file ZegoAuthConstants.h.

    Specify the values of the parameters that are required for initializing the RoomKit SDK, including kZegoSecretID, kZegoSecretSign, and kProductID. You must use the values you obtained according to the procedure mentioned in the Prerequisites section above. Otherwise, the sample code will not run correctly.


  7. Connect the iOS device to your development computer. Then, from the scheme menu in the Xcode toolbar, choose the connected iOS device (or an iOS simulator) as the run destination.


  8. Click the Run button in the toolbar to build and run the sample code.