All Projects → ConnectyCube → connectycube-flutter-call-kit

ConnectyCube / connectycube-flutter-call-kit

Licence: Apache-2.0 license
A Flutter plugin for displaying call screen when the app in the background or terminated.

Programming Languages

kotlin
9241 projects
swift
15916 projects
dart
5743 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to connectycube-flutter-call-kit

WhatsappClone
Flutter WhatsappClone
Stars: ✭ 29 (-17.14%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
flutter designs world
We at Appstree has implemented design concepts of different application using mock ups available out there at internet. These are open source projects and any once can use them. Say Hello to us at [email protected], if you want to hire our team is available to provide you top notch solutions.
Stars: ✭ 22 (-37.14%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
weather app
Weather App built in Flutter and Riverpod state management
Stars: ✭ 38 (+8.57%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
Best Flutter Ui Templates
completely free for everyone. Its build-in Flutter Dart.
Stars: ✭ 13,448 (+38322.86%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
flutter do
Basic Flutter apps, for flutter devs
Stars: ✭ 47 (+34.29%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
FlutterMarvelHeroesLibrary
The simple concept for Marvel universe fans made in Flutter. Everything about favourite characters in one app.
Stars: ✭ 18 (-48.57%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
Bank-profile
a flutter Ui profile for bank account
Stars: ✭ 33 (-5.71%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
flutter pokedex
Pokedex app built with Flutter (with lots of animations) using Clean Architecture
Stars: ✭ 1,603 (+4480%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
data examples
An example app showing different ways to pass to and share data with widgets and pages.
Stars: ✭ 56 (+60%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
flutter-UI
将Flutter各种Widget各种API📘都实现一次。喜欢请Star。
Stars: ✭ 67 (+91.43%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
Chi Food
Food Delivery App made by Flutter and Bloc
Stars: ✭ 103 (+194.29%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
shoppers
Flutter E-Commerce App using Firebase, Razorpay and Stripe
Stars: ✭ 94 (+168.57%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
stuff
Crud operation with Firebase
Stars: ✭ 80 (+128.57%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
swipedetector
A Flutter package to detect up, down, left, right swipes.
Stars: ✭ 34 (-2.86%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
Mathematics
In this application, we can perform some actions like subtraction, addition, multiplication, and division. And by selecting any of these, you will receive a PDF with the answer key to your MCQ or question!
Stars: ✭ 45 (+28.57%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
aarogya seva
A beautiful 😍 covid-19 app with self - assessment and more.
Stars: ✭ 118 (+237.14%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
flutter todos
A cross platform todo list app using flutter, sqlite etc. If you read the code, you will understand how to create simple elegant mobile app using Flutter and Dart language.
Stars: ✭ 60 (+71.43%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
BloodMS
🔥 🔥 🔥 A blood management project. 🔥 🔥 🔥
Stars: ✭ 48 (+37.14%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
flutter dribble signup challenge
A dribble login UI challenge in Flutter
Stars: ✭ 43 (+22.86%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples
WhatsAppUIClone
WhatsApp UI Clone with Flutter
Stars: ✭ 66 (+88.57%)
Mutual labels:  flutter-apps, flutter-demo, flutter-examples

Stand With Ukraine

ConnectyCube Flutter Call Kit plugin

A Flutter plugin for displaying call screen when the app is in the background or terminated. It provides a complex solution for implementation the background calls feature in your app including getting token and displaying the Incoming call screen.

Supported platforms

  • Android
  • iOS

Features

  • access device token (FCM for Android and VoIP for iOS)
  • notifying the app about token refreshing via callback
  • displaying the Incoming call screen when push notification was delivered on the device
  • notifying the app about user action performed on the Incoming call screen (accept, reject, mute (for iOS))
  • providing the methods for manual managing of the Incoming screen including the manual showing the Incoming call screen
  • getting the data about the current call during the call session
  • some customizations according to your app needs (ringtone, icon, accent color(for Android))

Flutter P2P Calls code sample, incoming call in background Android Flutter P2P Calls code sample, incoming call locked Android Flutter P2P Calls code sample, incoming call in background iOS Flutter P2P Calls code sample, incoming call locked iOS

Configure your project

This plugin doesn't require complicated configs, just connect it as usual flutter plugin to your app and do the next simple actions:

Prepare Android

  • add the Google services config file google-services.json by path your_app/android/app/
  • add next string at the end of your build.gradle file by path your_app/android/app/build.gradle:
apply plugin: 'com.google.gms.google-services'

If your app is targeted to targetSdkVersion 31 and above and you need to start the app by clicking the Accept button you should request the permission SYSTEM_ALERT_WINDOW from the user first. For it, you can use the plugin permission_handler.

If your app is targeted to targetSdkVersion 33 and above you should request the permission POST_NOTIFICATIONS from the user first.

Prepare iOS

  • add next strings to your Info.plist file by path your_app/ios/Runner/Info.plist:
<key>UIBackgroundModes</key>
<array>
    <string>remote-notification</string>
    <string>voip</string>
</array>

API and callbacks

Get token

The plugin returns the VoIP token for the iOS platform and the FCM token for the Android platform.

Get token from the system:

ConnectycubeFlutterCallKit.getToken().then((token) {
    // use received token for subscription on push notifications on your server
});

Listen to the refresh token event:

ConnectycubeFlutterCallKit.onTokenRefreshed = (token) {
    // use refreshed token for resubscription on your server
};

Customize the plugin

We added a helpful method for customization the plugin according to your needs. At this moment you can customize the ringtone, application icon, noitification small icon (Android only) and notification accent color (Android only). Use the next method for it:

ConnectycubeFlutterCallKit.instance.updateConfig(
  ringtone: 'custom_ringtone', 
  icon: 'app_icon', 
  notificationIcon: 'ic_notification', 
  color: '#07711e');

Show Incoming call notification

P2PCallSession incomingCall; // the call received somewhere

CallEvent callEvent = CallEvent(
    sessionId: incomingCall.sessionId,
    callType: incomingCall.callType,
    callerId: incomingCall.callerId,
    callerName: 'Caller Name',
    opponentsIds: incomingCall.opponentsIds,
    userInfo: {'customParameter1': 'value1'});
ConnectycubeFlutterCallKit.showCallNotification(callEvent);

Listen to the user action from the Incoming call screen:

Listen in the foreground

Add the listeners during initialization of the plugin:

ConnectycubeFlutterCallKit.instance.init(
    onCallAccepted: _onCallAccepted,
    onCallRejected: _onCallRejected,
);

Future<void> _onCallAccepted(CallEvent callEvent) async {
    // the call was accepted
}

Future<void> _onCallRejected(CallEvent callEvent) async {
    // the call was rejected
}

Listen in the background or terminated state (Android only):

ConnectycubeFlutterCallKit.onCallRejectedWhenTerminated = onCallRejectedWhenTerminated;
ConnectycubeFlutterCallKit.onCallAcceptedWhenTerminated = onCallAcceptedWhenTerminated;

!> Attention: the functions onCallRejectedWhenTerminated and onCallAcceptedWhenTerminated must be a top-level function and cannot be anonymous

Get the call state

var callState = await ConnectycubeFlutterCallKit.getCallState(sessionId: sessionId);

Get the call data

ConnectycubeFlutterCallKit.getCallData(sessionId: sessionId).then((callData) {
      
});

Get the id of the latest call

It is helpful for some cases to know the id of the last received call. You can get it via:

var sessionId = await ConnectycubeFlutterCallKit.getLastCallId();

Then you can get the state of this call using getCallState.

Notify the plugin about processing the call on the Flutter app side

For dismissing the Incoming call screen (or the Call Kit for iOS) you should notify the plugin about these events. Use next functions for it:

ConnectycubeFlutterCallKit.reportCallAccepted(sessionId: uuid);
ConnectycubeFlutterCallKit.reportCallEnded(sessionId: uuid);

Clear call data

After finishing the call you can clear all data on the plugin side related to this call, call the next code for it

await ConnectycubeFlutterCallKit.clearCallData(sessionId: sessionId);

Manage the app visibility on the lock screen (Android only)

In case you need to show your app after accepting the call from the lock screen you can do it using the method

ConnectycubeFlutterCallKit.setOnLockScreenVisibility(isVisible: true);

After finishing that call you should hide your app under the lock screen, do it via

ConnectycubeFlutterCallKit.setOnLockScreenVisibility(isVisible: false);

Show Incoming call screen by push notification

In case you want to display the Incoming call screen automatically by push notification you can do it 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, you can do it using the next code:

CreateEventParams params = CreateEventParams();
params.parameters = {
    'message': "Incoming ${currentCall.callType == CallType.VIDEO_CALL ? "Video" : "Audio"} call",
    'call_type': currentCall.callType,
    'session_id': currentCall.sessionId,
    'caller_id': currentCall.callerId,
    'caller_name': callerName,
    'call_opponents': currentCall.opponentsIds.join(','),
    'signal_type': 'startCall',
    'ios_voip': 1,
 };

params.notificationType = NotificationType.PUSH;
params.environment = CubeEnvironment.DEVELOPMENT; // not important
params.usersIds = currentCall.opponentsIds.toList();

createEvent(params.getEventForRequest()).then((cubeEvent) {
      // event was created
}).catchError((error) {
      // something went wrong during event creation
});

For hiding the Incoming call screen via push notification use a similar request but with a different signal_type, it can be 'endCall' or 'rejectCall'.

You can check how this plugin works in our P2P Calls code sample.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].