ZegoUIKitPrebuiltCallInvitationService class
To receive the call invites from others and let the calling notification show on the top bar when receiving it, you will need to initialize the call invitation service (ZegoUIKitPrebuiltCallInvitationService) first.
1.1 Set up the context. To make the UI show when receiving a call invite, you will need to get the Context. To do so, do the following 3 steps: 1.1.1 Define a navigator key. 1.1.2 Set the navigatorKey to ZegoUIKitPrebuiltCallInvitationService. 1.1.3 Register the navigatorKey to MaterialApp.
1.2 Initialize/Deinitialize the call invitation service. 1.2.1 Initialize the service when your app users logged in successfully or re-logged in after an exit. 1.2.2 Deinitialize the service after your app users logged out.
Example:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
/// 1.1.1 define a navigator key
final navigatorKey = GlobalKey<NavigatorState>();
/// 1.1.2: set navigator key to ZegoUIKitPrebuiltCallInvitationService
ZegoUIKitPrebuiltCallInvitationService().setNavigatorKey(navigatorKey);
runApp(MyApp(navigatorKey: navigatorKey));
}
class MyApp extends StatefulWidget {
final GlobalKey<NavigatorState> navigatorKey;
const MyApp({
required this.navigatorKey,
Key? key,
}) : super(key: key);
@override
State<StatefulWidget> createState() => MyAppState();
}
class MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
if (/*the user of the app is logged in*/) {
onUserLogin();
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
/// 1.1.3: register the navigator key to MaterialApp
navigatorKey: widget.navigatorKey,
...
);
}
}
/// on App's user login
void onUserLogin() {
/// 1.2.1. initialized ZegoUIKitPrebuiltCallInvitationService
/// when app's user is logged in or re-logged in
/// We recommend calling this method as soon as the user logs in to your app.
ZegoUIKitPrebuiltCallInvitationService().init(
appID: yourAppID /*input your AppID*/,
appSign: yourAppSign /*input your AppSign*/,
userID: currentUser.id,
userName: currentUser.name,
plugins: [ZegoUIKitSignalingPlugin()],
);
}
/// on App's user logout
void onUserLogout() {
/// 1.2.2. de-initialization ZegoUIKitPrebuiltCallInvitationService
/// when app's user is logged out
ZegoUIKitPrebuiltCallInvitationService().uninit();
}
Constructors
- ZegoUIKitPrebuiltCallInvitationService()
-
factory
Properties
- controller → ZegoUIKitPrebuiltCallController
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isInCalling → bool
-
no setter
- isInit → bool
-
no setter
- private → ZegoCallInvitationServicePrivateImpl
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- version → String
-
no setter
Methods
-
accept(
{String customData = ''}) → Future< bool> -
To accept the current call invitation, you can use the
customData
parameter if you need to provide a reason for the acceptance to the other party. -
cancel(
{required List< ZegoCallUser> callees, String customData = ''}) → Future<bool> -
To cancel the invitation for
callees
in a call, you can include your cancellation reason using thecustomData
. -
init(
{required int appID, required String userID, required String userName, required List< IZegoUIKitPlugin> plugins, String appSign = '', String token = '', ZegoCallPrebuiltConfigQuery? requireConfig, ZegoUIKitPrebuiltCallEvents? events, ZegoCallInvitationConfig? config, ZegoCallRingtoneConfig? ringtoneConfig, ZegoCallInvitationUIConfig? uiConfig, ZegoCallInvitationNotificationConfig? notificationConfig, ZegoCallInvitationInnerText? innerText, ZegoUIKitPrebuiltCallInvitationEvents? invitationEvents}) → Future<void> - you must call this method as soon as the user login(or re-login, auto-login) to your app.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reject(
{String customData = ''}) → Future< bool> -
To reject the current call invitation, you can use the
customData
parameter if you need to provide a reason for the rejection to the other party. -
send(
{required List< ZegoCallUser> invitees, required bool isVideoCall, String customData = '', String? callID, String? resourceID, String? notificationTitle, String? notificationMessage, int timeoutSeconds = 60}) → Future<bool> - This function is used to send call invitations to one or more specified users.
- we need a context object, to push/pop page when receive invitation request so we need navigatorKey to get context
-
toString(
) → String -
A string representation of this object.
inherited
-
uninit(
) → Future< void> - you must call this method as soon as the user logout from your app
-
useSystemCallingUI(
List< IZegoUIKitPlugin> plugins) → void
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited