Skip to main content
Version: 5.5

Implement your first group call (macOS)

PlanetKit lets you integrate audio and video call functionality for 1-to-1 calls or group calls into your app. This guide shows how to get started with the implementation of a group audio call in your macOS app.

Note

For faster development, you can implement your app on top of our quick start.

Prerequisites

Create a project

To get started, open Xcode and create a new project as follows:

  1. Click Create a new Xcode Project in the Welcome to Xcode window.
  2. In macOS tab, select App and click Next.
  3. In the project creation window, do the following.
    1. Enter your product name in the Product Name field.
    2. Select your development team in the Team field.
    3. Enter the organization identifier in the Organization Identifier field.
    4. Select Storyboard in the Interface field.
    5. Click Next. Create a macOS project
  4. Select the location where your project will be created, and click Create.

Install the SDK

Install the SDK through Swift Package Manager.

  1. Select File > Add Packages... in the Xcode menu bar.
  2. Enter the PlanetKit repository URL (https://github.com/line/planet-kit-apple) in the Search or Enter Package URL field.
  3. Click the Add Package button.

Request system permissions

To enable audio call functionality, users need to grant your app the permission to access the microphone. To make that procedure happen, perform the following:

Initialize the SDK

To call the PlanetKit APIs, you must initialize PlanetKit first. Initialize PlanetKit using initialize() of PlanetKitManager with a PlanetKitInitialSettingBuilder object.

You must set the server URL (planet_base_url) in the PlanetKitInitialSettingBuilder object when calling initialize(). Make sure that you use an appropriate planet_base_url depending on the development environment that you're using.

// AppDelegate.swift

// Import PlanetKit SDK
import PlanetKit

PlanetKitManager.shared.initialize(initialSettings: PlanetKitInitialSettingBuilder()
.withSetKitServerKey(serverUrl: planet_base_url)
.build())
Note

The initialize() method must be called once initially in your app. It is recommended to initialize the SDK in the applicationDidFinishLaunching(_:) method of your AppDelegate that adopts and conforms to NSApplicationDelegate.

Get the access token

In the client app, request your app server to generate an access token and get the generated access token.

Note

You must get a new access token and use it each time you call joinConference().

Join a group audio call

To join a group audio call, call joinConference() of PlanetKitManager with a PlanetKitConferenceParam object that includes the following properties:

  • myUserId: Local user's user ID
  • roomId: Room ID
  • roomServiceId: Room service ID
  • delegate: Event delegate that adopts and conforms to PlanetKitConferenceDelegate
  • accessToken: Access token
import PlanetKit

class YourClass {
func joinConference() {
let param = PlanetKitConferenceParam(myUserId: myUserId, roomId: roomId, roomServiceId: serviceId, displayName: nil, delegate: self, accessToken: accessToken)
let result = PlanetKitManager.shared.joinConference(param: param, settings: nil)

if (result.reason == PlanetKitStartFailReason.none && result.conference != null) {
// The "result.conference" instance is the main instance to call APIs from now on.
// You must keep it to control this call.
}
else {
// Handle an error by referring to result.reason.
}
}
}

extension YourClass: PlanetKitConferenceDelegate {
func didConnect(_ conference: PlanetKitConference, connected: PlanetKitConferenceConnectedParam) {
// This is called when the call is connected.
// Write your own code here.
}

func didDisconnect(_ conference: PlanetKitConference, disconnected: PlanetKitDisconnectedParam) {
// This is called when the call is disconnected.
// Write your own code here.
}

func peerListDidUpdate(_ conference: PlanetKitConference, updated: PlanetKitConferencePeerListUpdateParam) {
// This is called when the list of peers is updated.
// Write your own code here.
}
}
Note

Users need the room ID to enter the room from the client app, so the room ID must be shared with other users through an application-defined communication channel.

Next steps

See the following documents to learn more about the various features provided by PlanetKit and how to use each feature.

  • Call flow: Familiarize yourself with the call flow for each call type.
  • Subgroup: Read the guides on subgroups, which allows you to implement advanced features such as multi-subgroup rooms or translation rooms.
  • Extended functions: Explore the guides on extended functions, such as screen share and data sessions.
  • Code examples: See the code examples that you can use for implementing your own app.
  • Reference: Refer to the API reference, API changelog, and release notes.