-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathpush_notification_manager.dart
More file actions
129 lines (108 loc) · 3.8 KB
/
Copy pathpush_notification_manager.dart
File metadata and controls
129 lines (108 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import 'dart:async';
import 'package:equatable/equatable.dart';
import 'package:rxdart/rxdart.dart';
import '../coordinator/coordinator_client.dart';
import '../stream_video.dart';
part 'call_kit_events.dart';
/// Signature for a function which provides a new instance of
/// [PushNotificationManager].
typedef PNManagerProvider = PushNotificationManager Function(
CoordinatorClient client,
StreamVideo streamVideo,
);
/// Interface for managing push notifications related to call events.
abstract class PushNotificationManager {
/// Stream of [CallKitEvent] for call-related events.
Stream<CallKitEvent> get onCallEvent;
/// Registers the device for push notifications.
void registerDevice();
/// Unregisters the device for push notifications.
Future<void> unregisterDevice();
/// Displays an incoming call notification.
///
/// [uuid] is the unique identifier for the call.
/// [callCid] is the call's unique identifier.
/// [avatar] is the avatar of the caller.
/// [handle] is the handle of the caller.
/// [nameCaller] is the name of the caller.
/// [hasVideo] indicates whether the call has video (default is true).
Future<void> showIncomingCall({
required String uuid,
required String callCid,
String? avatar,
String? handle,
String? nameCaller,
bool hasVideo = true,
});
/// Displays a missed call notification.
///
/// [uuid] is the unique identifier for the call.
/// [callCid] is the call's unique identifier.
/// [avatar] is the avatar of the caller.
/// [handle] is the handle of the caller.
/// [nameCaller] is the name of the caller.
/// [hasVideo] indicates whether the call has video (default is true).
Future<void> showMissedCall({
required String uuid,
required String callCid,
String? avatar,
String? handle,
String? nameCaller,
bool hasVideo = true,
});
/// Initiates an outgoing call.
///
/// [uuid] is the unique identifier for the call.
/// [callCid] is the call's unique identifier.
/// [avatar] is the avatar of the caller.
/// [handle] is the handle of the caller.
/// [nameCaller] is the name of the caller.
/// [hasVideo] indicates whether the call has video (default is true).
Future<void> startOutgoingCall({
required String uuid,
required String callCid,
String? avatar,
String? handle,
String? nameCaller,
bool hasVideo = true,
});
/// Mutes or unmutes the call.
///
/// [uuid] is the unique identifier for the call.
/// [isMuted] indicates whether the call is muted (default is true).
Future<void> muteCall(String uuid, {bool isMuted = true});
/// Holds or unholds the call.
///
/// [uuid] is the unique identifier for the call.
/// [isOnHold] indicates whether the call is on hold (default is true).
Future<void> holdCall(String uuid, {bool isOnHold = true});
/// Ends the call.
///
/// [uuid] is the unique identifier for the call.
Future<void> endCall(String uuid);
/// Ends the call.
///
/// [cid] is the call id for the call.
Future<void> endCallByCid(String cid);
/// Ends all ongoing calls.
Future<void> endAllCalls();
/// Sets the call status to connected.
///
/// [uuid] is the unique identifier for the call.
Future<void> setCallConnected(String uuid);
/// Sets call as muted/unmuted (iOS only).
Future<void> setCallMutedByCid(String cid, bool isMuted);
/// Retrieves a list of active calls.
Future<List<CallData>> activeCalls();
/// Obtains the device's push token for VoIP.
Future<String?> getDevicePushTokenVoIP();
/// Disposes of the notification manager.
Future<void> dispose();
}
extension NotificationManagerExtension on PushNotificationManager {
StreamSubscription<T> on<T extends CallKitEvent>(
void Function(T event)? onEvent,
) {
return onCallEvent.whereType<T>().listen(onEvent);
}
}