public var body: some View {
IncomingCallView(
callInfo: callInfo,
onCallAccepted: { _ in
// handle call accepted
}, onCallRejected: { _ in
// handle call rejected
}
)
}
IncomingCallView
The IncomingCallView
lets you easily build UI when you’re being called or ringed by other people in an app. It’s used to show more information about the participants and the call itself, as well as give you the option to reject or accept the call.
Usage
In order to create the IncomingCallView
, you need to instantiate it with the following code:
If you are using our CallContainer
to add calling support to your views, this view is automatically shown when the callingState
in the CallViewModel
is .incoming
.
If you want to customize (or completely replace) the IncomingCallView
, you should use the ViewFactory
method makeIncomingCallView
:
public func makeIncomingCallView(viewModel: CallViewModel, callInfo: IncomingCall) -> some View {
CustomIncomingCallView(viewModel: viewModel, callInfo: callInfo)
}
Sounds
By default, the outgoing call view plays ringing sound when the ringing is in progress. If you want to change the sounds, you should provide your own instance of the Sounds
class in the Appearance
object, while replacing the incomingCallSound
with your own sound file.
let sounds = Sounds()
sounds.incomingCallSound = "your_sounds.m4a"
let appearance = Appearance(sounds: sounds)
streamVideoUI = StreamVideoUI(streamVideo: streamVideo, appearance: appearance)
Localization and icons
You can change the texts and the icons in the IncomingCallView
. For more details about changing the texts, please check the localization guide.
In order to change the icons, you need to create your own version of the Images
class and change the icons you want to customize.
For example, if we want to change the hangup
icon, we can do the following:
let images = Images()
images.hangup = Image("custom_hangup_icon")
let appearance = Appearance(images: images)
streamVideoUI = StreamVideoUI(streamVideo: streamVideo, appearance: appearance)