@@ -13,29 +13,6 @@ import Intents
1313
1414@MainActor
1515fileprivate func content( ) {
16- container {
17- @Injected ( \. callKitAdapter) var callKitAdapter
18-
19- callKitAdapter. availabilityPolicy = . always
20- }
21-
22- container {
23- @Injected ( \. callKitAdapter) var callKitAdapter
24-
25- callKitAdapter. availabilityPolicy = . regionBased
26- }
27-
28- container {
29- struct MyCustomAvailabilityPolicy : CallKitAvailabilityPolicyProtocol {
30- var isAvailable : Bool {
31- // Example: Enable CallKit only for premium users
32- return UserManager . currentUser? . isPremium == true
33- }
34- }
35-
36- @Injected ( \. callKitAdapter) var callKitAdapter
37- callKitAdapter. availabilityPolicy = . custom( MyCustomAvailabilityPolicy ( ) )
38- }
3916
4017 container {
4118 @Injected ( \. callKitAdapter) var callKitAdapter
@@ -80,23 +57,15 @@ fileprivate func content() {
8057
8158 container {
8259 struct MyCustomView : View {
83- @Injected ( \. streamVideo) var streamVideo
8460 @Injected ( \. callKitAdapter) var callKitAdapter
85- @Injected ( \. callKitPushNotificationAdapter) var callKitPushNotificationAdapter
86-
61+ @Injected ( \. sounds) var sounds
8762 var body : some View {
88- Button {
89- let deviceToken = callKitPushNotificationAdapter. deviceToken
90- if !deviceToken. isEmpty {
91- Task {
92- // Unregister the device token
93- try await streamVideo. deleteDevice ( id: deviceToken)
94- }
95- }
96- // Perform any other logout operations
97- callKitAdapter. streamVideo = nil
98- } label: {
99- Text ( " Logout " )
63+ EmptyView ( ) // Your content goes here.
64+ . onAppear {
65+ // Here we register for incomingCalls and provide
66+ // a logo as we did on the previous example
67+ // Provide the ringtone to use when a CallKit call is ringing
68+ callKitAdapter. ringtoneSound = sounds. incomingCallSound
10069 }
10170 }
10271 }
@@ -125,6 +94,68 @@ fileprivate func content() {
12594 }
12695 }
12796
97+ asyncContainer {
98+ let call = streamVideo. call ( callType: " default " , callId: UUID ( ) . uuidString)
99+ let result = try await call. create (
100+ memberIds: memberIds,
101+ custom: [ " display_name " : . string( " My awesome group " ) ] ,
102+ ring: true
103+ )
104+ }
105+
106+ container {
107+ @Injected ( \. callKitAdapter) var callKitAdapter
108+ callKitAdapter. callSettings = CallSettings ( audioOn: true , videoOn: false )
109+ }
110+
111+ container {
112+ struct MyCustomView : View {
113+ @Injected ( \. streamVideo) var streamVideo
114+ @Injected ( \. callKitAdapter) var callKitAdapter
115+ @Injected ( \. callKitPushNotificationAdapter) var callKitPushNotificationAdapter
116+
117+ var body : some View {
118+ Button {
119+ let deviceToken = callKitPushNotificationAdapter. deviceToken
120+ if !deviceToken. isEmpty {
121+ Task {
122+ // Unregister the device token
123+ try await streamVideo. deleteDevice ( id: deviceToken)
124+ }
125+ }
126+ // Perform any other logout operations
127+ callKitAdapter. streamVideo = nil
128+ } label: {
129+ Text ( " Logout " )
130+ }
131+ }
132+ }
133+ }
134+
135+ container {
136+ @Injected ( \. callKitAdapter) var callKitAdapter
137+
138+ callKitAdapter. availabilityPolicy = . always
139+ }
140+
141+ container {
142+ @Injected ( \. callKitAdapter) var callKitAdapter
143+
144+ callKitAdapter. availabilityPolicy = . regionBased
145+ }
146+
147+ container {
148+ struct MyCustomAvailabilityPolicy : CallKitAvailabilityPolicyProtocol {
149+ var isAvailable : Bool {
150+ // Example: Enable CallKit only for premium users
151+ return UserManager . currentUser? . isPremium == true
152+ }
153+ }
154+
155+ @Injected ( \. callKitAdapter) var callKitAdapter
156+ callKitAdapter. availabilityPolicy = . custom( MyCustomAvailabilityPolicy ( ) )
157+ }
158+
128159 container {
129160 class IntentHandler : INExtension , INStartCallIntentHandling {
130161 override func handler( for intent: INIntent ) -> Any {
0 commit comments