Use this guide after Firebase and platform setup are already complete.
final sdk = DaakiaCallkitFlutter(
config: const DaakiaCallkitConfig(
baseUrl: 'https://your-daakia-base-url',
secret: 'your-shared-secret',
),
);await sdk.initialize(
onIncomingCall: (payload) async {
// Open your incoming call UI.
},
onCallEvent: (event) async {
switch (event.type) {
case DaakiaCallEventType.accepted:
break;
case DaakiaCallEventType.declined:
break;
case DaakiaCallEventType.ended:
break;
case DaakiaCallEventType.timedOut:
break;
case DaakiaCallEventType.incoming:
case DaakiaCallEventType.unknown:
break;
}
},
);Call initialize() as part of app startup. Do not wait until the user opens a
debug, settings, or onboarding screen if you need accept actions from a closed
state to immediately continue into your app flow.
Call this on iOS once the SDK is initialized, ideally in the same startup flow:
final voipToken = await sdk.initializeVoip(
onVoipTokenUpdated: (token) async {
// Persist or register updated token.
},
);If you want the SDK to fetch the current FCM token and register the current push device:
await sdk.registerCurrentPushDevice(
username: 'current_user_id',
platform: DaakiaPlatform.android, // or DaakiaPlatform.ios
voipToken: latestVoipToken,
);voipToken is only relevant on iOS. On Android, leave it null or omit it.
If you already have the token yourself:
await sdk.registerCurrentDevice(
username: 'current_user_id',
token: 'fcm_or_apns_token',
voipToken: 'optional_ios_voip_token',
platform: DaakiaPlatform.android, // or DaakiaPlatform.ios
);await sdk.startCallByUsername(
username: 'target_user_id',
title: 'Caller Name',
message: 'Incoming call',
data: {
'type': 'incoming_call',
'callId': 'meeting_uid_123',
'sender': '{"uid":"current_user_id","userName":"Caller Name"}',
'callerId': 'current_user_id',
'receiverId': 'target_user_id',
'callTimestamp': DateTime.now().toUtc().toIso8601String(),
'body': 'Incoming call',
'title': 'Caller Name',
},
);await sdk.startCallByToken(
token: 'device_token',
platform: DaakiaPlatform.ios,
title: 'Caller Name',
message: 'Incoming call',
data: {
'type': 'incoming_call',
'callId': 'meeting_uid_123',
'sender': '{"uid":"current_user_id","userName":"Caller Name"}',
'callerId': 'current_user_id',
'receiverId': 'target_user_id',
},
);For the current integration, keep these fields in the incoming call payload:
typecallIdsendercallerIdreceiverIdcallTimestampbodytitle
sender may be sent as a JSON string or an object. The SDK currently tolerates both.
The main event types are:
incomingaccepteddeclinedendedtimedOutunknown
Use event.call for the parsed DaakiaIncomingCallPayload.
When using daakia_vc_flutter_sdk for the actual meeting join, report call lifecycle events to the Daakia backend.
Report user actions like accept, reject, end, or timeout:
await sdk.sendCallEvent(
meetingUid: 'meeting_uid_123',
action: DaakiaCallEventAction.callAccept,
metadata: {'userId': 'current_user_id'},
);The event is sent only once per action per meeting UID. Use clearSentCallEventCache() to reset if needed.
Metadata is optional and can be any key-value pairs you want to include.
Set up fallback events for when the app is closed:
await sdk.configureCallEventFallback(
actions: {DaakiaCallEventAction.callAccept, DaakiaCallEventAction.callReject},
metadata: {'fallback': true},
);This allows events to be sent even if the app process is not running. Metadata is fixed at setup time.
Metadata is optional and can be any key-value pairs you want to include.
Reset the cache to allow re-sending the same event:
await sdk.clearSentCallEventCache();Use this sparingly, as it bypasses duplicate prevention.
If you want to use the built-in Flutter screen:
await Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => DaakiaIncomingCallScreen(
payload: payload,
onAccept: (payload) async {},
onReject: (payload) async {},
onTimeout: (payload) async {},
),
),
);if (!await sdk.notifications.canUseFullScreenIntent()) {
await sdk.notifications.openFullScreenIntentSettings();
}This package does not join the media call for you. Use your own RTC flow or see call-ui-integration.md.