Last active
March 8, 2024 05:05
-
-
Save Ayush783/66a091de7b4e34bd69fbbf46032bd4fd to your computer and use it in GitHub Desktop.
updated calling kit service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CallingKitService { | |
static final CallingKitService _instance = CallingKitService._internal(); | |
factory CallingKitService() { | |
return _instance; | |
} | |
CallingKitService._internal() { | |
MethodChannel('YOUR_CHANNEL_NAME').setMethodCallHandler( | |
(call) async { | |
if (call.method == 'CALL_ACCEPTED_INTENT') { | |
final data = call.arguments; | |
if (data != null) { | |
_completer.complete(data); | |
} else { | |
_completer.completeError('No data found'); | |
} | |
} | |
}, | |
); | |
} | |
Completer<Map> _completer = Completer(); | |
Future<Map> getAppLaunchedData() async { | |
try { | |
return await _completer.future; | |
} catch (e) { | |
log('$_logName Either data is empty or No call received in killed state: ${e.toString()}'); | |
return {}; | |
} | |
} | |
static void showCallkitIncoming(...) async { | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment