{"id":19390230,"url":"https://github.com/connectycube/connectycube-flutter-call-kit","last_synced_at":"2025-04-09T22:10:28.514Z","repository":{"id":44920499,"uuid":"338140307","full_name":"ConnectyCube/connectycube-flutter-call-kit","owner":"ConnectyCube","description":"A Flutter plugin for displaying call screen when the app in the background or terminated.","archived":false,"fork":false,"pushed_at":"2025-03-19T13:15:11.000Z","size":192,"stargazers_count":60,"open_issues_count":13,"forks_count":85,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-02T21:37:46.546Z","etag":null,"topics":["call","calling","calling-app","callkit","flutter","flutter-apps","flutter-demo","flutter-examples","videochat"],"latest_commit_sha":null,"homepage":"https://developers.connectycube.com/flutter","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ConnectyCube.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-11T20:10:22.000Z","updated_at":"2025-03-23T18:06:16.000Z","dependencies_parsed_at":"2023-12-13T17:58:22.265Z","dependency_job_id":"c2973de4-c77e-41ef-95aa-85c75ee53e30","html_url":"https://github.com/ConnectyCube/connectycube-flutter-call-kit","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConnectyCube%2Fconnectycube-flutter-call-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConnectyCube%2Fconnectycube-flutter-call-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConnectyCube%2Fconnectycube-flutter-call-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConnectyCube%2Fconnectycube-flutter-call-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ConnectyCube","download_url":"https://codeload.github.com/ConnectyCube/connectycube-flutter-call-kit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119294,"owners_count":21050755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["call","calling","calling-app","callkit","flutter","flutter-apps","flutter-demo","flutter-examples","videochat"],"created_at":"2024-11-10T10:19:37.061Z","updated_at":"2025-04-09T22:10:28.505Z","avatar_url":"https://github.com/ConnectyCube.png","language":"Kotlin","funding_links":["https://www.buymeacoffee.com/connectycube"],"categories":[],"sub_categories":[],"readme":"[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://stand-with-ukraine.pp.ua)\n\n# ConnectyCube Flutter Call Kit plugin\n\nA Flutter plugin for displaying call screen when the app is in the background or terminated.\nIt provides a complex solution for implementation the background calls feature in your app including \ngetting token and displaying the Incoming call screen.\n\n## Supported platforms\n\n- Android\n- iOS\n\n## Features\n\n- access device token (FCM for Android and VoIP for iOS)\n- notifying the app about token refreshing via callback\n- displaying the Incoming call screen when push notification was delivered on the device\n- notifying the app about user action performed on the Incoming call screen (accept, reject, mute (for iOS))\n- providing the methods for manual managing of the Incoming screen including the manual showing the Incoming call screen\n- getting the data about the current call during the call session\n- some customizations according to your app needs (ringtone, app icon, accent color(for Android))\n- checking and changing the access to the `Manifest.permission.USE_FULL_SCREEN_INTENT` permission (for Android 14 and above)\n\n\n\u003ckbd\u003e\u003cimg alt=\"Flutter P2P Calls code sample, incoming call in background Android\" src=\"https://developers.connectycube.com/images/code_samples/flutter/background_call_android.png\" height=\"440\" /\u003e\u003c/kbd\u003e \n\u003ckbd\u003e\u003cimg alt=\"Flutter P2P Calls code sample, incoming call locked Android\" src=\"https://developers.connectycube.com/images/code_samples/flutter/background_call_android_locked.png\" height=\"440\" /\u003e\u003c/kbd\u003e \n\u003ckbd\u003e\u003cimg alt=\"Flutter P2P Calls code sample, incoming call in background iOS\" src=\"https://developers.connectycube.com/images/code_samples/flutter/background_call_ios.PNG\" height=\"440\" /\u003e\u003c/kbd\u003e\n\u003ckbd\u003e\u003cimg alt=\"Flutter P2P Calls code sample, incoming call locked iOS\" src=\"https://developers.connectycube.com/images/code_samples/flutter/background_call_ios_locked.PNG\" height=\"440\" /\u003e\u003c/kbd\u003e\n\n## Configure your project\n\nThis plugin doesn't require complicated configs, just [connect it](https://pub.dev/packages/connectycube_flutter_call_kit/install) \nas usual flutter plugin to your app and do the next simple actions:\n\n### Prepare Android\n\n- add the Google services config file `google-services.json` by path `your_app/android/app/`\n- add next string at the end of your **build.gradle** file by path `your_app/android/app/build.gradle`:\n```groovy\napply plugin: 'com.google.gms.google-services'\n```\n\nIf your app is targeted to `targetSdkVersion 31` and above and you need to start the app by clicking the `Accept` \nbutton you should request the permission `SYSTEM_ALERT_WINDOW` from the user first. For it, you can use \nthe plugin [`permission_handler`](https://pub.dev/packages/permission_handler).\n\nIf your app is targeted to `targetSdkVersion 33` and above you should request the permission \n`POST_NOTIFICATIONS` from the user first.\n\n### Prepare iOS\n\n- add next strings to your **Info.plist** file by path `your_app/ios/Runner/Info.plist`:\n```\n\u003ckey\u003eUIBackgroundModes\u003c/key\u003e\n\u003carray\u003e\n    \u003cstring\u003eremote-notification\u003c/string\u003e\n    \u003cstring\u003evoip\u003c/string\u003e\n\u003c/array\u003e\n```\n\n## API and callbacks\n### Get token\nThe plugin returns the VoIP token for the iOS platform and the FCM token for the Android platform.\n\nGet token from the system:\n\n```dart\nConnectycubeFlutterCallKit.getToken().then((token) {\n    // use received token for subscription on push notifications on your server\n});\n```\n\nListen to the refresh token event:\n```dart\nConnectycubeFlutterCallKit.onTokenRefreshed = (token) {\n    // use refreshed token for resubscription on your server\n};\n```\n### Customize the plugin\nWe added a helpful method for customization the plugin according to your needs. At this moment you \ncan customize the ringtone, application icon, noitification small icon (Android only) \nand notification accent color (Android only). Use the next method for it:\n\n```dart\nConnectycubeFlutterCallKit.instance.updateConfig(\n  ringtone: 'custom_ringtone', \n  icon: Platform.isAndroid ? 'default_avatar' : 'CallKitIcon', // is used as an avatar placeholder for Android and as the app icon for iOS\n  color: '#07711e');\n```\n\n#### [Android only] Notification icon customisation\nYou can set different icons for Audion and Video calls, add suitable resources to your\n`android/app/src/main/AndroidManifest.xml` to the `application` section for it:\n```xml\n\u003cmeta-data\n    android:name=\"com.connectycube.flutter.connectycube_flutter_call_kit.audio_call_notification_icon\"\n    android:resource=\"@drawable/ic_notification_audio_call\" /\u003e\n\n\u003cmeta-data\n    android:name=\"com.connectycube.flutter.connectycube_flutter_call_kit.video_call_notification_icon\"\n    android:resource=\"@drawable/ic_notification_video_call\" /\u003e\n```\n\nIf you don't need it, add only the default notification icon:\n```xml\n\u003cmeta-data\n    android:name=\"com.connectycube.flutter.connectycube_flutter_call_kit.app_notification_icon\"\n    android:resource=\"@drawable/ic_notification\" /\u003e\n```\n\n### Show Incoming call notification\n\n```dart\nP2PCallSession incomingCall; // the call received somewhere\n\nCallEvent callEvent = CallEvent(\n    sessionId: incomingCall.sessionId,\n    callType: incomingCall.callType,\n    callerId: incomingCall.callerId,\n    callerName: 'Caller Name',\n    opponentsIds: incomingCall.opponentsIds,\n    callPhoto: 'https://i.imgur.com/KwrDil8b.jpg',\n    userInfo: {'customParameter1': 'value1'});\nConnectycubeFlutterCallKit.showCallNotification(callEvent);\n```\n\n### Listen to the user action from the Incoming call screen:\n\n#### Listen in the foreground\n\nAdd the listeners during initialization of the plugin:\n\n```dart\nConnectycubeFlutterCallKit.instance.init(\n    onCallAccepted: _onCallAccepted,\n    onCallRejected: _onCallRejected,\n    onCallIncoming: _onCallIncoming,\n);\n\nFuture\u003cvoid\u003e _onCallAccepted(CallEvent callEvent) async {\n    // the call was accepted\n}\n\nFuture\u003cvoid\u003e _onCallRejected(CallEvent callEvent) async {\n    // the call was rejected\n}\n\nFuture\u003cvoid\u003e _onCallRejected(CallEvent callEvent) async {\n    // the Incoming call screen/notification was shown for user\n}\n```\n\n#### Listen in the background or terminated state (Android only):\n\n```dart\nConnectycubeFlutterCallKit.onCallRejectedWhenTerminated = onCallRejectedWhenTerminated;\nConnectycubeFlutterCallKit.onCallAcceptedWhenTerminated = onCallAcceptedWhenTerminated;\nConnectycubeFlutterCallKit.onCallIncomingWhenTerminated = onCallIncomingWhenTerminated;\n```\n\n!\u003e Attention: the functions `onCallRejectedWhenTerminated`, `onCallAcceptedWhenTerminated` and `onCallIncomingWhenTerminated` must \nbe a top-level functions and cannot be anonymous. Mark these callbacks with the `@pragma('vm:entry-point')` \nannotation to allow using them from the native code.\n\n#### Listen for the actions performed on the CallKit screen (iOS only):\n\n##### Listening for the muting/unmuting the call\n\n```dart\nConnectycubeFlutterCallKit.onCallMuted = onCallMuted;\n\nFuture\u003cvoid\u003e onCallMuted(bool mute, String uuid) async {\n  // [mute] - `true` - the call was muted on the CallKit screen, `false` - the call was unmuted\n  // [uuid] - the id of the muted/unmuted call\n}\n```\n\n### Get the call state\n\n```dart\nvar callState = await ConnectycubeFlutterCallKit.getCallState(sessionId: sessionId);\n```\n\n### Get the call data\n```dart\nConnectycubeFlutterCallKit.getCallData(sessionId: sessionId).then((callData) {\n      \n});\n```\n\n### Get the id of the latest call\n\nIt is helpful for some cases to know the id of the last received call. You can get it via:\n\n```dart\nvar sessionId = await ConnectycubeFlutterCallKit.getLastCallId();\n```\nThen you can get the state of this call using `getCallState`.\n\n### Notify the plugin about user actions concerning the call on the Flutter app side\n\nFor dismissing the Incoming call screen (or the Call Kit for iOS) you should notify the plugin about \nthese events.\nUse next functions for it:\n\n```dart\nConnectycubeFlutterCallKit.reportCallAccepted(sessionId: uuid);\nConnectycubeFlutterCallKit.reportCallEnded(sessionId: uuid);\n```\n\nNotifying the plugin about muting/unmuting the call (iOS only):\n```dart\nvar muted = true; // set `true` if the call was muted or `false` if the call was unmuted\n\nConnectycubeFlutterCallKit.reportCallMuted(sessionId: uuid, muted: muted);\n```\n\n### Clear call data\nAfter finishing the call you can clear all data on the plugin side related to this call, call the \nnext code for it\n\n```dart\nawait ConnectycubeFlutterCallKit.clearCallData(sessionId: sessionId);\n```\n\n### Manage the app visibility on the lock screen (Android only)\n\nIn case you need to show your app after accepting the call from the lock screen you can do it using \nthe method\n```dart\nConnectycubeFlutterCallKit.setOnLockScreenVisibility(isVisible: true);\n```\n\nAfter finishing that call you should hide your app under the lock screen, do it via\n```dart\nConnectycubeFlutterCallKit.setOnLockScreenVisibility(isVisible: false);\n```\n\n### Check the permission `Manifest.permission.USE_FULL_SCREEN_INTENT` state (Android 14 and above)\n\n```dart\nvar canUseFullScreenIntent = await ConnectycubeFlutterCallKit.canUseFullScreenIntent();\n```\n\n### Request the access to the `Manifest.permission.USE_FULL_SCREEN_INTENT` permission (Android 14 and above)\n\n```dart\nConnectycubeFlutterCallKit.provideFullScreenIntentAccess();\n```\nThe function moves the user to the specific setting for your app where you can grant or deny this \npermission for your app.\n\n## Show Incoming call screen by push notification\nIn case you want to display the Incoming call screen automatically by push notification you can do \nit easily. For it, the caller should send the push notification to all call members. This push notification should contain some required parameters. If you use the [Connectycube Flutter SDK](https://pub.dev/packages/connectycube_sdk), you can do it using the next code:\n\n```dart\nCreateEventParams params = CreateEventParams();\nparams.parameters = {\n    'message': \"Incoming ${currentCall.callType == CallType.VIDEO_CALL ? \"Video\" : \"Audio\"} call\",\n    'call_type': currentCall.callType,\n    'session_id': currentCall.sessionId,\n    'caller_id': currentCall.callerId,\n    'caller_name': callerName,\n    'call_opponents': currentCall.opponentsIds.join(','),\n    'photo_url': 'https://i.imgur.com/KwrDil8b.jpg'\n    'signal_type': 'startCall',\n    'ios_voip': 1,\n };\n\nparams.notificationType = NotificationType.PUSH;\nparams.environment = CubeEnvironment.DEVELOPMENT; // not important\nparams.usersIds = currentCall.opponentsIds.toList();\n\ncreateEvent(params.getEventForRequest()).then((cubeEvent) {\n      // event was created\n}).catchError((error) {\n      // something went wrong during event creation\n});\n```\n\nFor hiding the Incoming call screen via push notification use a similar request but with a \ndifferent `signal_type`, it can be `'endCall'` or `'rejectCall'`.\n\n## Android 14 features\nStarting from Android `Build.VERSION_CODES.UPSIDE_DOWN_CAKE`, apps may not have permission to use \n`Manifest.permission.USE_FULL_SCREEN_INTENT`. If permission is denied, the call notification will \nshow up as an expanded heads up notification on lockscreen. The plugin provides the API for checking \nthe access state and moves to the System setting for enabling it. Please follow the next code \nsnippet to manage it:\n```dart\nvar canUseFullScreenIntent = await ConnectycubeFlutterCallKit.canUseFullScreenIntent();\n\nif (!canUseFullScreenIntent){\n  ConnectycubeFlutterCallKit.provideFullScreenIntentAccess();\n}\n```\n\nYou can check how this plugin works in our [P2P Calls code sample](https://github.com/ConnectyCube/connectycube-flutter-samples/tree/master/p2p_call_sample).\n\n## Have an issue?\n\nJoin our [Discord](https://discord.com/invite/zqbBWNCCFJ) for quick answers to your questions\n\n## Community\n\n- [Blog](https://connectycube.com/blog)\n- X (twitter)[@ConnectyCube](https://x.com/ConnectyCube)\n- [Facebook](https://www.facebook.com/ConnectyCube)\n\n**Want to support our team**:\u003cbr\u003e\n\u003ca href=\"https://www.buymeacoffee.com/connectycube\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-blue.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n\n## License\n\nSee [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconnectycube%2Fconnectycube-flutter-call-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconnectycube%2Fconnectycube-flutter-call-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconnectycube%2Fconnectycube-flutter-call-kit/lists"}