Skip to main content
Version: 1.2

Implement your first group call

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 Flutter app.

Prerequisites​

Create a project​

Create a project by referring to Set up an editor.

Install the SDK​

  1. In pubspec.yaml, add the following lines. Replace {PLANET_KIT_VERSION} with the SDK version to use (for example, v1.0.0).

    dependencies:
    flutter:
    sdk: flutter

    planet_kit_flutter:
    git:
    url: git@github.com:line/planet-kit-flutter.git
    ref: {PLANET_KIT_VERSION}
  2. Import planet_kit_flutter to application source code.

    import 'package:planet_kit_flutter/planet_kit_flutter.dart';

Request system permissions​

Use Dart permission_handler package to request phone, microphone, and Bluetooth connection permission.

import 'package:permission_handler/permission_handler.dart';
final status = await [Permission.microphone, Permission.phone, Permission.bluetoothConnect].request();

Initialize the SDK​

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

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

Future<void> initializePlanetKit() async {
final serverUrl = "SERVER_URL";
final initParam = PlanetKitInitParam(
logSetting: PlanetKitLogSetting(
enabled: false,
logLevel: PlanetKitLogLevel.silent,
logSizeLimit: PlanetKitLogSizeLimit.small),
serverUrl: serverUrl);
final result =
await PlanetKitManager.instance.initializePlanetKit(initParam);
}
Note
  • The initializePlanetKit() method must be called once initially in your app. It is recommended to initialize the SDK in the initState() method of your app.
  • For more information on SDK initialization and log setting, see PlanetKit initialization and log setting.

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() of PlanetKitManager.

Join a group audio call​

To join a group audio call, call joinConference() of PlanetKitManager with the following arguments:

  • PlanetKitJoinConferenceParam object, which includes the following properties:
    • myUserId: Local user's user ID
    • roomId: Room ID
    • myServiceId: Local user's service ID
    • roomServiceId: Room service ID
    • accessToken: Access token
  • PlanetKitConferenceEventHandler object, which includes the implementation of event callbacks
Future<bool> joinConference(String roomId, String accessToken) async {
var builder = PlanetKitJoinConferenceParamBuilder()
.setMyUserId(myUserId)
.setMyServiceId(myServiceId)
.setRoomServiceId(roomServiceId)
.setRoomId(roomId)
.setAccessToken(accessToken);

PlanetKitJoinConferenceParam? param;
try {
param = builder.build();
} catch (error) {
print("failed to build join conference param $error");
return false;
}
final result =
await PlanetKitManager.instance.joinConference(param, _eventHandler);

if (result.reason != PlanetKitStartFailReason.none) {
print("join conference result ${result.reason}");
return false;
}

// The "result.conference" instance is the main instance to call APIs from now on.
// You must keep it to control this call.
return true;
}

final _eventHandler = PlanetKitConferenceEventHandler(
onConnected: (conference) => print("connected"),
onDisconnected: (conference, reason, source, byRemote) => print("disconnected $reason"),
onPeerListUpdated: (conference, updateParam) => print("peer list updated $updateParam"));
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.
  • Extended functions: Explore the guides on extended functions, such as mute control and screen share.
  • 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.