Run the demo of RTC SDK for iOS

更新时间:
复制 MD 格式

This topic describes how to run the demo of Real-Time Communication (RTC) SDK for iOS.

Prerequisites

You have obtained your authentication information from the console. For more information, see Access tools.

Note The token obtained from the console is for development and testing only. Using this token in a production environment poses a security threat. For production environments, you must set up your own server to generate tokens and use the HTTPS protocol. For more information, see Generate a token on the server-side.

Environment requirements

TypeDescription
DeviceiPhone 5 or later physical devices
iOS versioniOS 9 or later

Procedure

  1. Download and decompress the software development kit (SDK) and sample code. For more information, see SDK download.
  2. Copy the SDK file to the following directory of the sample code.
    Directory
  3. Configure the parameters.
    1. Add AliRTCSdk.framework to the dynamic library. The following figure shows that AliRTCSdk.framework is added to the dynamic library.
      Dynamic library
    2. Upload the certificate and profile file.

      The demo of RTC SDK for iOS can only run on a physical machine. Upload your certificate and profile file and configure the Bundle Identifier based on your certificate. If you use Xcode 9.0 or later, you can select Automatically manage signing to allow Xcode to manage your certificate and profile file.

      Automatic management
    3. Open the RTCSampleChatViewController.m file and configure the AliRtcAuthInfo authentication parameter in the joinBegin function.
      /*
        NSString *AppID  = @"aoe****";
        NSString *userID = @"f303d59acae073****";
        NSString *channelID = @"23****";
        NSString *nonce = @"AK-7c8f947b-e55e-4ed5-ab09-bc849****";
          long long timestamp = 1585119606;   //The timestamp when the token expires. For example, 1560588594 indicates that the token expires at 16:49:54, June 15, 2019. 
        NSString *token = @"70f77b8****";
        NSArray <NSString *> *GSLB = @[@"https://rgslb.rtc.aliyuncs.com"];
        NSArray <NSString *> *agent = @[@""];
      */         
  4. Run the demo.

    After you start the demo, you are directed to the audio or video call interface on which the local preview is displayed. Then, you are automatically added to the channel. When another user joins the channel, you can start an audio or video call in real time.

    iOS Demo