Flutter incoming call

Overview

flutter_incoming_call

A Flutter plugin to show incoming call in your Flutter app! Alpha version(not ready for production!)

Usage

To use this plugin:

  1. Configure android project: Just add to your manifest activity and receiver.
<activity
    android:name="com.github.alezhka.flutter_incoming_call.IncomingCallActivity"
    android:theme="@style/Theme.AppCompat"
    android:screenOrientation="portrait"
    android:showOnLockScreen="true">
    <intent-filter>
        <action android:name="com.github.alezhka.flutter_incoming_call.activity.ACTION_INCOMING_CALL" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

<receiver android:name="com.github.alezhka.flutter_incoming_call.CallBroadcastReceiver"
    android:enabled="true"
    android:exported="false"/>
  1. Configure Flutter plugin:
FlutterIncomingCall.configure(
    appName: 'example_incoming_call',
    duration: 30000,
    android: ConfigAndroid(
        vibration: true,
        ringtonePath: 'default',
        channelId: 'calls',
        channelName: 'Calls channel name',
        channelDescription: 'Calls channel description',
    ),
    ios: ConfigIOS(
        iconName: 'AppIcon40x40',
        ringtonePath: null,
        includesCallsInRecents: false,
        supportsVideo: true,
        maximumCallGroups: 2,
        maximumCallsPerCallGroup: 1,
    )
)
  1. Listen events:
FlutterIncomingCall.onEvent.listen((event) {
    if(event is CallEvent) { // Android | IOS
    } else if(event is HoldEvent) { // IOS
    } else if(event is MuteEvent) { // IOS
    } else if(event is DmtfEvent) { // IOS
    } else if(event is AudioSessionEvent) { // IOS
    }
});
  1. Call api:
FlutterIncomingCall.displayIncomingCall(String uid, String name, String avatar, String handle, String type, bool isVideo);
FlutterIncomingCall.endCall(String uuid);
FlutterIncomingCall.endAllCalls();

Demo

ios ios (Lockscreen) Android Android (Lockscreen)

Example

Check out the example in the example project folder for a working example.

Comments
  • Hello , How i can bring my app to foregound when user tap on accept button.

    Hello , How i can bring my app to foregound when user tap on accept button.

    Hello , I am implementing video calling using agora. Upon receiving fcm i can initiate incoming call using this plugin but when user hits acept screen how i can show calling screen.

    Any lead would be appciated .

    Thank you !

    enhancement 
    opened by TouseefAQ 6
  • Various fixes and improvements

    Various fixes and improvements

    Hi @Alezhka ,

    Awesome plugin—nice work on this! I'd been waiting for a while for someone to write this and I'm glad you did! I've integrated it into my own project and ran into a few issues—some bugs, others required extensions. I've included all those changes in this PR. I'm happy to tweak as you prefer.

    • FIXED: Incoming call screen was not being shown on my Android device when the phone’s screen was off. Incoming call activity requires the USE_FULL_SCREEN_INTENT permission to be declared in the AndroidManifest on newer versions of Android.
    • FIXED: Supplying a missing or incorrect iconName in the ConfigIOS object would prevent the incoming call notification from being displayed on iOS devices. Added some nil-checking to display a warning message instead of failing.
    • FIXED: An accepted call on iOS gets killed after duration, even if the call was accepted by the user. Corrected the timeout logic to end the call only if it isn’t being attended.
    • FIXED: Incoming MuteEvent and DMTFEvent events were not being dispatched. I corrected a copy-and-paste bug in the switch statement responsible for creating those events.
    • NOT FIXED: The Dart model DMTFEvent is misspelled; it should be DTMFEvent.
    • FIXED: The mute property on MuteEvent was always null. I fixed the name of the Map key used to populate it (was mute, but should be muted).
    • NOT FIXED: I’m not enough of an Android guy to know what’s right here, but in the README example, I had to change android:theme="@style/AppCompatTheme” to android:theme="@style/Theme.AppCompat" in order to get the call notification to be displayed. Perhaps others will run into this, too…?
    • IMPROVED: I needed a way to disable the “Keypad”, “Add Call” and “FaceTime” buttons on the iOS call screen. I added a new API (displayIncomingCallAdvanced) that offers several new named parameters for controlling this on iOS: supportsDTMF, supportsHolding, supportsGrouping and supportsUngrouping. I also changed the handle and handleType attributes to be nullable for cases where a handle is not desired (which has the effect of disabling the “FaceTime” button).
    • IMPROVED: I needed a way to prevent this plugin from changing my application’s existing AVAudioSession configuration (iOS). I suspect most applications that use this plugin will also be controlling their AVAudioSession elsewhere and will need fine-grained control over what attributes (if any) should be configured by flutter_incoming_call. To that extent, I added new boolean ConfigIOS attributes: avSessionSetCategory, avSessionSetMode, avSessionSetPreferredSampleRate, avSessionSetPreferredIOBufferDuration and avSessionSetActive. By default, all are true (current behavior), but client applications can enable/disable which parameters are set. (My application needs avSessionSetMode to be called, but none of the others, in order to function correctly).
    • IMPROVED: IDE directories were checked into source control (some containing files referencing paths local to your computer). I removed and .gitignore’d the Android Studio directories (.idea) … but perhaps having them checked in was intentional? Some folks swear by this practice. :)
    opened by defano 1
  • Unable to see the notifications. Only hears the sound.

    Unable to see the notifications. Only hears the sound.

    This is what I am getting

    E/MediaPlayerNative( 9511): trying to set audio attributes called in state 8
    D/CompatibilityChangeReporter( 9511): Compat change id reported: 160794467; UID 10152; state: ENABLED
    E/MethodChannel#flutter_incoming_call( 9511): Failed to handle method call
    E/MethodChannel#flutter_incoming_call( 9511): java.lang.IllegalArgumentException: com.example.call: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    E/MethodChannel#flutter_incoming_call( 9511): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    E/MethodChannel#flutter_incoming_call( 9511): 	at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
    E/MethodChannel#flutter_incoming_call( 9511): 	at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
    E/MethodChannel#flutter_incoming_call( 9511): 	at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
    E/MethodChannel#flutter_incoming_call( 9511): 	at com.github.alezhka.flutter_incoming_call.CallNotification.showCallNotification(CallNotification.kt:43)
    E/MethodChannel#flutter_incoming_call( 9511): 	at com.github.alezhka.flutter_incoming_call.FlutterIncomingCallPlugin.onMethodCall(FlutterIncomingCallPlugin.kt:73)
    E/MethodChannel#flutter_incoming_call( 9511): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
    E/MethodChannel#flutter_incoming_call( 9511): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
    E/MethodChannel#flutter_incoming_call( 9511): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
    E/MethodChannel#flutter_incoming_call( 9511): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
    E/MethodChannel#flutter_incoming_call( 9511): 	at android.os.Handler.handleCallback(Handler.java:938)
    E/MethodChannel#flutter_incoming_call( 9511): 	at android.os.Handler.dispatchMessage(Handler.java:99)
    E/MethodChannel#flutter_incoming_call( 9511): 	at android.os.Looper.loopOnce(Looper.java:201)
    E/MethodChannel#flutter_incoming_call( 9511): 	at android.os.Looper.loop(Looper.java:288)
    E/MethodChannel#flutter_incoming_call( 9511): 	at android.app.ActivityThread.main(ActivityThread.java:7842)
    E/MethodChannel#flutter_incoming_call( 9511): 	at java.lang.reflect.Method.invoke(Native Method)
    E/MethodChannel#flutter_incoming_call( 9511): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    E/MethodChannel#flutter_incoming_call( 9511): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
    E/flutter ( 9511): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, com.example.call: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    E/flutter ( 9511): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles., null, java.lang.IllegalArgumentException: com.example.call: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    E/flutter ( 9511): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
    E/flutter ( 9511): 	at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
    E/flutter ( 9511): 	at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
    E/flutter ( 9511): 	at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
    E/flutter ( 9511): 	at com.github.alezhka.flutter_incoming_call.CallNotification.showCallNotification(CallNotification.kt:43)
    E/flutter ( 9511): 	at com.github.alezhka.flutter_incoming_call.FlutterIncomingCallPlugin.onMethodCall(FlutterIncomingCallPlugin.kt:73)
    E/flutter ( 9511): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
    E/flutter ( 9511): 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
    E/flutter ( 9511): 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
    E/flutter ( 9511): 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
    E/flutter ( 9511): 	at android.os.Handler.handleCallback(Handler.java:938)
    E/flutter ( 9511): 	at android.os.Handler.dispatchMessage(Handler.java:99)
    E/flutter ( 9511): 	at android.os.Looper.loopOnce(Looper.java:201)
    E/flutter ( 9511): 	at android.os.Looper.loop(Looper.java:288)
    E/flutter ( 9511): 	at android.app.ActivityThread.main(ActivityThread.java:7842)
    E/flutter ( 9511): 	at java.lang.reflect.Method.invoke(Native Method)
    E/flutter ( 9511): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    E/flutter ( 9511): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
    E/flutter ( 9511): )
    E/flutter ( 9511): #0      StandardMethodCodec.decodeEnvelope
    E/flutter ( 9511): #1      MethodChannel._invokeMethod
    E/flutter ( 9511): <asynchronous suspension>
    E/flutter ( 9511): #2      FlutterIncomingCall.displayIncomingCall
    E/flutter ( 9511): <asynchronous suspension>
    E/flutter ( 9511):
    D/EGL_emulation( 9511): app_time_stats: avg=35606.44ms min=35606.44ms max=35606.44ms count=1
    Lost connection to device.
    Exited
    
    
    bug 
    opened by arslankaleem7229 0
  • I need  just a Notification Alert and as call dismiss Notification also dismiss CAn you please make that tone exension for me for free

    I need just a Notification Alert and as call dismiss Notification also dismiss CAn you please make that tone exension for me for free

    Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

    Describe the solution you'd like A clear and concise description of what you want to happen.

    Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

    Additional context Add any other context or screenshots about the feature request here.

    enhancement 
    opened by Manishmg3994 0
  • ios no incoming call Error

    ios no incoming call Error

    Describe the bug A clear and concise description of what the bug is.

    Expected behavior A clear and concise description of what you expected to happen.

    Screenshots If applicable, add screenshots to help explain your problem. Screen Shot 2021-12-28 at 10 01 41

    nothing show !!

    Please complete the following information:

    • iphone 13 pro max
    • ios 15.2

    Additional context Add any other context about the problem here.

    bug 
    opened by Basemshawwa 0
  • too many income call popup screens

    too many income call popup screens

    Describe the bug FlutterIncomingCall.displayIncomingCall(...) shows too many views and plays too many sounds. I have android native ring sound and now this new FlutterIncomingCall ring sound and melody at same time in my flutter app. That's wired.

    To Reproduce If the income call is happen, a small android call popup is displayed. At first native android ring tone is there, than FlutterIncomingCall ring tone comes up. Suddenly the FlutterIncomingCall mini popup is displayed and full screen FlutterIncomingCall underlying income call screen is visible. Means there are three layer of popups now. first on top the android native popup second the FlutterIncomingCall mini popup third the full screen FlutterIncomingCall underlying income call screen

    Expected behavior Native android income call popup is replaced by only one new FlutterIncomingCall screen.

    Screenshots If applicable, add screenshots to help explain your problem.

    Please complete the following information:

    • Device: Samsung
    • OS: android 11
    • flutter 2.9.0
    • dart 2.16.0

    Additional context I wish these two functions (FlutterIncomingCall screen) and FlutterIncomingCall "endCall" function are separated flutter plug-ins.

    bug 
    opened by s681562 0
  • Hang up does not work

    Hang up does not work

    Describe the bug FlutterIncomingCall.endAllCalls(); FlutterIncomingCall.endCall(...);

    These functions are not canceling current (income) call. The connection is still going, the phone call is still going.

    To Reproduce Call your phone or take a call with your phone. Use FlutterIncomingCall.endAllCalls(); or FlutterIncomingCall.endCall(...); Nothing is happen, the call is not finishing by FlutterIncomingCall code.

    Expected behavior Immediately stop the phone call programmatically.

    Screenshots nothing to show

    Please complete the following information:

    • Device: Samsung
    • OS: android 11
    • dart 2.16
    • flutter 2.8

    Additional context Add any other context about the problem here.

    I worked under Android native. Hang up a current phone call is working well by this code below. My code in android java. Please fix your flutter plugin.

    @RequiresApi(api = Build.VERSION_CODES.P)
    public static void hangup(Context context) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            TelecomManager tcm = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
            if (tcm != null) {
                try {
                    if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ANSWER_PHONE_CALLS)
                            != PackageManager.PERMISSION_GRANTED) {
                        return;
                    }
    
                    tcm.endCall();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        else {
            Class classTelephony = null;
            try {
                TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
                classTelephony = Class.forName(telephonyManager.getClass().getName());
                Method methodGetITelephony = classTelephony.getDeclaredMethod("getITelephony");
                methodGetITelephony.setAccessible(true);
                Object telephonyInterface = methodGetITelephony.invoke(telephonyManager);
                Class telephonyInterfaceClass = Class.forName(telephonyInterface.getClass().getName());
                Method methodEndCall = telephonyInterfaceClass.getDeclaredMethod("endCall");
                methodEndCall.invoke(telephonyInterface);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        }
    }
    
    bug 
    opened by s681562 0
Owner
Sturov Aleksey
Mobile developer
Sturov Aleksey
Call Kit is a prebuilt feature-rich call component, which enables you to build one-on-one and group voice/video calls into your app with only a few lines of code.

Call Kit (ZegoUIKitPrebuiltCall) Call Kit is a prebuilt feature-rich call component, which enables you to build one-on-one and group voice/video calls

ZEGOCLOUD 9 Dec 26, 2022
Api Call Check flutter - A new Flutter project that demonstrates api calling and displays them in a scrollable list

api_fetch A new Flutter project that demonstrates api calling and displays them

Babish Shrestha 0 Jan 2, 2022
Animated video call screens for flutter

Animated video call screens Animations: click on your video to zoom click on right bottom arrow up to open more options double click at the coming cal

Benjamin Mahmić 55 Sep 4, 2022
Home app - A dynamic flutter app which can be used to generate alerts, set alarms and send sms or call someone

first_app A dynamic flutter app which can be used to generate alerts, set alarms

null 0 Apr 9, 2022
Api-Call - A basic mobile application for Networking in Flutter(API)

Github Api Call ?? ?? ?? Introduction This project is an basic mobile applicatio

navee-ramesh 5 Nov 11, 2022
API call using Dio package and GetX in Flutter.

API call demo This demo is to get API data using Dio package and I have also used GetX package for state management. I have implemented two ways to di

Dhola Hardik 42 Dec 11, 2022
Create flutter project with all needed configuration in two minutes (theme, localization, connect to firebase, FCM, local notifications, safe API call, error handling, animation..etc)

Flutter GetX Template Flutter Getx template to make starting project fast and easy . Introduction We all face the same problem when we want to start a

Emad Beltaje 150 Jan 7, 2023
Pokemon App with animations, beautiful UI and network call.

?? Pokemon-App Pokemon App with animations, beautiful UI and network call. ?? ScreenShots ✨ Requirements Any Operating System (ie. MacOS X, Linux, Win

Festus Olusegun 26 Jul 16, 2021
Agora - Highlight Active Speaker in a video call

Highlight Active Speaker in a video call When a meeting or video chat is complet

null 3 Nov 23, 2022
GetX Architecture for large scale project, This project include - pagination, pull to refresh, localization, network call and advance error handling

GetX Architecture for large scale project, This project include - pagination, pull to refresh, localization, network call and advance error handling

Wai Han Ko 5 Nov 29, 2022
🆙🚀 Flutter application upgrade/ Flutter App Upgrade /Flutter App Update/Flutter Update / download Plug-in

???? Flutter application upgrade/ Flutter App Upgrade /Flutter App Update/Flutter Update / download Plug-in (with notice bar progress), supports full upgrade, hot update and incremental upgrade

PengHui Li 344 Dec 30, 2022
ABC of Flutter widgets. Intended for super beginners at Flutter. Play with 35+ examples in DartPad directly and get familiar with various basic widgets in Flutter

Basic Widgets Examples This is aimed for complete beginners in Flutter, to get them acquainted with the various basic widgets in Flutter. Run this pro

Pooja Bhaumik 815 Jan 3, 2023
Minha primeira aplicação android utilizando Flutter feito no curso de Flutter da Cod3r Cursos Online. O foco dessa aplicação foi um contato inicial com o Flutter.

expenses Expenses é uma aplicação android simples feita em Flutter para controlar despesas pessoais. A aplicação consiste em: Listar transações feitas

Guilherme Teixeira Ais 2 Apr 19, 2022
Flutter Github Following Application, Using Flutter Provider and Flutter HTTP to get data from Github API.

Flutter Github Following Application Watch it on Youtube Previous Designs Checkout my Youtube channel Installation Please remember, after cloning this

Mohammad Rahmani 110 Dec 23, 2022
Flutter RSS feed parsing - A demo application of flutter which parse RSS XML contents to the flutter application

Flutter RSS feed parsing demo This is demo application of flutter which shows ho

Nyakuri Levite 3 Nov 15, 2022
Boris Gautier 1 Jan 31, 2022
Code for Flutter Talk from Flutter Vikings 2022: Custom User Interactions in Flutter

Custom User Interactions - Flutter Vikings 2022 A companion app for the Flutter Vikings 2022 talk - Custom User Interactions with Shortcuts, Intents,

Justin McCandless 9 Sep 16, 2022
Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flutter app.

Flutter Tutorial - User Profile Page UI 1/2 Create a Flutter User Profile Page UI where you can access and edit your user's information within your Fl

Johannes Milke 46 Dec 6, 2022
Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flutter app.

Flutter Tutorial - User Profile Page UI #2 Create a Flutter User Profile Page UI where you can access and edit your user's information within your Flu

Johannes Milke 45 Dec 15, 2022