init method

Future<void> init({
  1. @Deprecated('Set UIKitSettings.callingConfiguration instead. It wins over this ' 'parameter, which is only read when UIKitSettings has none. ' 'Will be removed in 7.0.0.') CallingConfiguration? configuration,
})

Starts call handling for the logged-in user: registers the call listeners (at once), then initialises the Calls SDK and logs the user into it (bounded; a failure is logged, never thrown, and retried once at the next waitForCallsSdk).

Safe to call repeatedly and concurrently: calls for the same user share one start. A call for a different user than the one started stops the previous one first. Returns without doing anything when no user is logged in.

configuration is used only when UIKitSettings.callingConfiguration is not set, and only the first non-null one passed after login counts: a later call no longer replaces it. It then applies to the incoming call banner, the message header's call buttons and the meeting bubble.

Implementation

Future<void> init({
  @Deprecated(
    'Set UIKitSettings.callingConfiguration instead. It wins over this '
    'parameter, which is only read when UIKitSettings has none. '
    'Will be removed in 7.0.0.',
  )
  CallingConfiguration? configuration,
}) async {
  final user = await _loggedInUser();
  if (user == null) {
    CallingConfigurationResolver.offerHostConfiguration(configuration);
    ccLog(
      'CallEventService.init(): no logged-in user; call it after login. '
      'Nothing was started.',
    );
    return;
  }
  // start() stops the previous user synchronously on a user switch, and
  // that clears the host configuration: offer this one after it.
  final started = CallsLifecycle.start(user);
  CallingConfigurationResolver.offerHostConfiguration(configuration);
  await started;
}