Skip to content

Commit fb69bb9

Browse files
- add ignoring of not supported platforms;
1 parent c2a0f81 commit fb69bb9

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lib/src/connectycube_flutter_call_kit.dart

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ class ConnectycubeFlutterCallKit {
144144
String? icon,
145145
String? notificationIcon,
146146
String? color}) {
147+
if (!Platform.isAndroid && !Platform.isIOS) return Future.value();
148+
147149
return _methodChannel.invokeMethod('updateConfig', {
148150
'ringtone': ringtone,
149151
'icon': icon,
@@ -155,20 +157,26 @@ class ConnectycubeFlutterCallKit {
155157
/// Returns VoIP token for iOS plaform.
156158
/// Returns FCM token for Android platform
157159
static Future<String?> getToken() {
160+
if (!Platform.isAndroid && !Platform.isIOS) return Future.value(null);
161+
158162
return _methodChannel.invokeMethod('getVoipToken', {}).then((result) {
159163
return result?.toString();
160164
});
161165
}
162166

163167
/// Show incoming call notification
164168
static Future<void> showCallNotification(CallEvent callEvent) async {
169+
if (!Platform.isAndroid && !Platform.isIOS) return Future.value();
170+
165171
return _methodChannel.invokeMethod(
166172
"showCallNotification", callEvent.toMap());
167173
}
168174

169175
/// Report that the current active call has been accepted by your application
170176
///
171177
static Future<void> reportCallAccepted({required String? sessionId}) async {
178+
if (!Platform.isAndroid && !Platform.isIOS) return Future.value();
179+
172180
return _methodChannel
173181
.invokeMethod("reportCallAccepted", {'session_id': sessionId});
174182
}
@@ -177,17 +185,22 @@ class ConnectycubeFlutterCallKit {
177185
static Future<void> reportCallEnded({
178186
required String? sessionId,
179187
}) async {
188+
if (!Platform.isAndroid && !Platform.isIOS) return Future.value();
189+
180190
return _methodChannel.invokeMethod("reportCallEnded", {
181191
'session_id': sessionId,
182192
});
183193
}
184194

185195
/// Get the current call state
186196
///
187-
/// Other platforms than Android and iOS will receive [CallState.unknown]
197+
/// Other platforms than Android and iOS will receive [CallState.UNKNOWN]
188198
static Future<String> getCallState({
189199
required String? sessionId,
190200
}) async {
201+
if (!Platform.isAndroid && !Platform.isIOS)
202+
return Future.value(CallState.UNKNOWN);
203+
191204
return _methodChannel.invokeMethod("getCallState", {
192205
'session_id': sessionId,
193206
}).then((state) {
@@ -200,6 +213,8 @@ class ConnectycubeFlutterCallKit {
200213
required String? sessionId,
201214
required String? callState,
202215
}) async {
216+
if (!Platform.isAndroid && !Platform.isIOS) return Future.value();
217+
203218
return _methodChannel.invokeMethod("setCallState", {
204219
'session_id': sessionId,
205220
'call_state': callState,
@@ -210,6 +225,8 @@ class ConnectycubeFlutterCallKit {
210225
static Future<Map<String, dynamic>?> getCallData({
211226
required String? sessionId,
212227
}) async {
228+
if (!Platform.isAndroid && !Platform.isIOS) return Future.value(null);
229+
213230
return _methodChannel.invokeMethod("getCallData", {
214231
'session_id': sessionId,
215232
}).then((data) {
@@ -224,6 +241,8 @@ class ConnectycubeFlutterCallKit {
224241
static Future<void> clearCallData({
225242
required String? sessionId,
226243
}) async {
244+
if (!Platform.isAndroid && !Platform.isIOS) return Future.value();
245+
227246
return _methodChannel.invokeMethod("clearCallData", {
228247
'session_id': sessionId,
229248
});
@@ -232,6 +251,8 @@ class ConnectycubeFlutterCallKit {
232251
/// Returns the id of the last displayed call.
233252
/// It is useful on starting app step for navigation to the call screen if the call was accepted
234253
static Future<String?> getLastCallId() async {
254+
if (!Platform.isAndroid && !Platform.isIOS) return Future.value(null);
255+
235256
return _methodChannel.invokeMethod("getLastCallId");
236257
}
237258

0 commit comments

Comments
 (0)