Moi Meet Flutter SDK
The Moi Meet Flutter SDK provides the same user experience as the Moi Meet app, in the form of a Flutter plugin so that you can embed and customize Moi Meet in your own Flutter app.
Supported platforms
Platform | Supported | Notes |
---|---|---|
Android | ✅ | Minimum API level is 24 |
iOS | ✅ | Minimum supported version is 13.4 |
Web | ❌ |
Sample application using the Flutter
If you want to see how easy integrating the Moi Meet Flutter SDK into a Flutter application is, take a look at the
sample applications repository.
Installation
Add dependency
Add the dependency from command-line
$ flutter pub add moi_meet_flutter_sdk
The command above will add this to the pubspec.yaml
file in your project (you can do this manually):
dependencies:
moi_meet_flutter_sdk: ^10.2.1
Install
Install the packages from the terminal:
$ flutter pub get
Import files
Import the following files into your dart code:
import 'package:moi_meet_flutter_sdk/moi_meet_flutter_sdk.dart';
Usage
Join meeting
Firstly, create a MoiMeet
object, then call the method join
from it with a MoiMeetConferenceOptions
object
var moiMeet = MoiMeet();
var options = MoiMeetConferenceOptions(room: 'moiIsAwesome');
moiMeet.join(options);
Configuration
iOS
Make sure in Podfile
from ios
directory you set the ios version 15.1 or higher
platform :ios, '15.1'
The plugin requests camera and microphone access, make sure to include the required entries for NSCameraUsageDescription
and NSMicrophoneUsageDescription
in your Info.plist
file from the ios/Runner
directory.
<key>NSCameraUsageDescription</key>
<string>The app needs access to your camera for meetings.</string>
<key>NSMicrophoneUsageDescription</key>
<string>The app needs access to your microphone for meetings.</string>
Android
Go to android/app/build.gradle
and make sure that the minSdkVersion
is set to at lest 24
android {
...
defaultConfig {
...
minSdkVersion 24
}
}
The application:label
field from the Moi Meet Android SDK will conflict with your application's one . Go to android/app/src/main/AndroidManifest.xml
and add the tools library and tools:replace="android:label"
to the application tag.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
tools:replace="android:label"
android:label="sample_app"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
...
</application>
</manifest>
Using the API
MoiMeet
The MoiMeet
class is the entry point for the sdk. It is used to launch the meeting screen, to send and receive all the events.
-
MoiMeet()
The constructor for the class.
-
join(MoiMeetConferenceOptions options,
MoiMeetEventListener? listener
)Joins a meeting with the given options and optionally a listener is given
options
: meeting optionslistener
: event listener for events triggered by the native sdks
-
hangUp()
The localParticipant leaves the current meeting.
-
setAudioMuted(bool muted)
Sets the state of the localParticipant audio muted according to the
muted
parameter. -
setVideoMuted(bool muted)
Sets the state of the localParticipant video muted according to the
muted
parameter. -
sendEndpointTextMessage({String? to, required String message})
Sends a message via the data channel to one particular participant or to all of them. If the
to
param is empty, the message will be sent to all the participants in the conference.In order to get the participantId, the
participantsJoined
event should be listened for, which have as a parameter theparticipantId
and this should be stored somehow. -
toggleScreenShare(bool enabled)
Sets the state of the localParticipant screen sharing according to the
enabled
parameter. -
openChat(
String? to
)Opens the chat dialog. If
to
contains a valid participantId, the private chat with that particular participant will be opened. -
sendChatMessage({String? to, required String message})
Sends a chat message via to one particular participant or to all of them. If the
to
param is empty, the message will be sent to all the participants in the conference.In order to get the participantId, the
participantsJoined
event should be listened for, which have as a parameter theparticipantId
and this should be stored somehow. -
closeChat()
Closes the chat dialog.
-
retrieveParticipantsInfo()
Sends and event that will trigger the
participantsInfoRetrieved
event which will contain participants information
MoiMeetConferenceOptions
This object encapsulates all the options that can be tweaked when joining a conference.
Example:
var options = MoiMeetConferenceOptions(
serverURL: "https://meet.aioman.org",
room: "moiIsAwesomeWithFlutter",
configOverrides: {
"startWithAudioMuted": false,
"startWithVideoMuted": false,
"subject" : "Moi with Flutter",
},
featureFlags: {
"unsaferoomwarning.enabled": false
},
userInfo: MoiMeetUserInfo(
displayName: "Flutter user",
email: "user@example.com"
),
);
-
MoiMeetUserInfo({String displayName, String email, String avatar})
The constructor for the MoiMeetUserInfo. P.S. the avatar should be an url.
MoiMeetEventListener
This class intends to be used as a listener for events that come from the native sdks. It will receive as arguments the event handlers
-
conferenceJoined(String url)
Called when a conference was joined.
url
: the conference URL
-
conferenceTerminated(String url, Object? error)
Called when the active conference ends, be it because of user choice or because of a failure.
url
: the conference URLerror
: missing if the conference finished gracefully, otherwise contains the error message
-
conferenceWillJoin(String url)
Called before a conference is joined.
- url: the conference URL
-
participantJoined(String? email, String? name, String? role, String? participantId)
Called when a participant has joined the conference.
email
: the email of the participant. It may not be set if the remote participant didn't set one.name
: the name of the participant.role
: the role of the participant.participantId
: the id of the participant.
-
participantLeft(String? participantId)
Called when a participant has left the conference.
participantId
: the id of the participant that left.
-
audioMutedChanged(bool muted)
Called when the local participant's audio is muted or unmuted.
muted
: a boolean indicating whether the audio is muted or not.
-
videoMutedChanged(bool muted)
Called when the local participant's video is muted or unmuted.
muted
: a boolean indicating whether the video is muted or not.
-
endpointTextMessageReceived(String senderId, String message)
Called when an endpoint text message is received.
senderId
: the participantId of the sendermessage
: the content.
-
screenShareToggled(String participantId, bool sharing)
Called when a participant starts or stops sharing his screen.
participantId
: the id of the participantsharing
: the state of screen share
-
chatMessageReceived(String senderId, String message, bool isPrivate, String? timestamp)
Called when a chat text message is received.
senderId
: the id of the participant that sent the message.message
: the content of the message.isPrivate
: true if the message is private, false otherwise.timestamp
: the (optional) timestamp of the message.
-
chatToggled(bool isOpen)
Called when the chat dialog is opened or closed.
isOpen
: true if the chat dialog is open, false otherwise.
-
participantsInfoRetrieved(String participantsInfo)
Called when
retrieveParticipantsInfo
action is calledparticipantsInfo
: a list of participants information as a string.
-
readyToClose()
Called when the SDK is ready to be closed. No meeting is happening at this point.
Example of listener:
var listener = MoiMeetEventListener(
conferenceJoined: (url) {
debugPrint("conferenceJoined: url: $url");
},
participantJoined: (email, name, role, participantId) {
debugPrint(
"participantJoined: email: $email, name: $name, role: $role, "
"participantId: $participantId",
);
participants.add(participantId!);
},
chatMessageReceived: (senderId, message, isPrivate) {
debugPrint(
"chatMessageReceived: senderId: $senderId, message: $message, "
"isPrivate: $isPrivate",
);
},
readyToClose: () {
debugPrint("readyToClose");
},
);