Skip to content

Commit 4629e15

Browse files
authored
fix: fixing ios call id issues when using firebase provider (#599)
* fixing ios call id issues * typo fix
1 parent c3dd8a2 commit 4629e15

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

docusaurus/docs/Flutter/05-advanced/02-ringing.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ To receive push notifications from Stream Video, you'll need to:
2020
1. Configure your push notification provider on the Stream Dashboard.
2121
2. Add the client-side integration. For Flutter this guide demonstrates using Firebase Cloud Messaging (FCM) for Android and Apple Push Notification Service (APNs) for iOS devices.
2222

23+
:::warning
24+
To get the best experience we strongly suggest using APNs for iOS. While our goal is to ensure compatibility with both providers on iOS, Firebase is not yet fully supported.
25+
:::
26+
2327
### Integrating Firebase for Android
2428

2529
#### Step 1 - Get the Firebase Credentials

packages/stream_video/lib/src/stream_video.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ class StreamVideo {
584584
final callCid = payload['call_cid'] as String?;
585585
if (callCid == null) return false;
586586

587+
final callUUID = const Uuid().v4();
587588
var callId = const Uuid().v4();
588589
var callType = StreamCallType();
589590

@@ -606,7 +607,7 @@ class StreamVideo {
606607
case CallRingingState.ringing:
607608
unawaited(
608609
manager.showIncomingCall(
609-
uuid: callId,
610+
uuid: callUUID,
610611
handle: createdById,
611612
nameCaller: createdByName,
612613
callCid: callCid,
@@ -620,7 +621,7 @@ class StreamVideo {
620621
case CallRingingState.ended:
621622
unawaited(
622623
manager.showMissedCall(
623-
uuid: callId,
624+
uuid: callUUID,
624625
handle: createdById,
625626
nameCaller: createdByName,
626627
callCid: callCid,

packages/stream_video_push_notification/ios/Classes/StreamVideoPKDelegateManager.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,19 @@ public class StreamVideoPKDelegateManager: NSObject, PKPushRegistryDelegate {
8080
let defaultCallText = "Unknown Caller"
8181

8282
let callCid = streamDict?["call_cid"] as? String ?? ""
83-
var createdByName = streamDict?["created_by_display_name"] as? String
84-
var createdById = streamDict?["created_by_id"] as? String
83+
let createdByName = streamDict?["created_by_display_name"] as? String
84+
let createdById = streamDict?["created_by_id"] as? String
8585

86-
let splitCid = callCid.split(separator: ":", maxSplits: 1, omittingEmptySubsequences: true)
87-
var callId = UUID().uuidString;
88-
var callType = "";
86+
var callUUID = UUID().uuidString;
8987

90-
if splitCid.count == 2 {
91-
let callType = String(splitCid[0])
92-
let callId = String(splitCid[1])
93-
}
94-
9588
let data: StreamVideoPushParams
9689
if let jsonData = self.defaultData {
9790
data = StreamVideoPushParams(args: jsonData)
9891
} else {
9992
data = StreamVideoPushParams(args: [String: Any]())
10093
}
10194

102-
data.callKitData.uuid = callId
95+
data.callKitData.uuid = callUUID
10396
data.callKitData.nameCaller = createdByName ?? defaultCallText
10497
data.callKitData.handle = createdById ?? defaultCallText
10598
data.callKitData.type = 1 //video

packages/stream_video_push_notification/lib/src/stream_video_push_notification.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:async';
22
import 'dart:io';
33

4+
import 'package:collection/collection.dart';
45
import 'package:firebase_messaging/firebase_messaging.dart';
56
import 'package:flutter_callkit_incoming/entities/entities.dart';
67
import 'package:flutter_callkit_incoming/flutter_callkit_incoming.dart';
@@ -66,7 +67,7 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
6667
_idCallEnded,
6768
client.events.on<CoordinatorCallEndedEvent>(
6869
(event) {
69-
FlutterCallkitIncoming.endCall(event.callCid.id);
70+
endCallByCid(event.callCid.toString());
7071
},
7172
),
7273
);
@@ -82,7 +83,7 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
8283
case CallRingingState.accepted:
8384
case CallRingingState.rejected:
8485
case CallRingingState.ended:
85-
FlutterCallkitIncoming.endCall(event.callCid.id);
86+
endCallByCid(event.callCid.toString());
8687
case CallRingingState.ringing:
8788
break;
8889
}
@@ -102,7 +103,7 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
102103
case CallRingingState.rejected:
103104
case CallRingingState.ended:
104105
await FlutterCallkitIncoming.silenceEvents();
105-
await FlutterCallkitIncoming.endCall(event.callCid.id);
106+
await endCallByCid(event.callCid.toString());
106107
await Future<void>.delayed(const Duration(milliseconds: 300));
107108
await FlutterCallkitIncoming.unsilenceEvents();
108109
case CallRingingState.ringing:
@@ -307,6 +308,16 @@ class StreamVideoPushNotificationManager implements PushNotificationManager {
307308
@override
308309
Future<void> endCall(String uuid) => FlutterCallkitIncoming.endCall(uuid);
309310

311+
Future<void> endCallByCid(String cid) async {
312+
final activeCalls = await this.activeCalls();
313+
final calls =
314+
activeCalls.where((call) => call.callCid == cid && call.uuid != null);
315+
316+
for (final call in calls) {
317+
await endCall(call.uuid!);
318+
}
319+
}
320+
310321
@override
311322
Future<String?> getDevicePushTokenVoIP() async {
312323
if (Platform.isIOS) {

0 commit comments

Comments
 (0)