callkeep icon indicating copy to clipboard operation
callkeep copied to clipboard

How to show a custom Incoming Call Screen like Whatsapp, Telegram etc.

Open imariman opened this issue 4 years ago • 32 comments

I want to show a custom Incoming Call Screen instead system's default Incoming Call Screen. Is it possible with this package? I would appreciate if anyone can help me about how to do that? Thanks.

Example Picture (Left Picture): http://www.filmytales.com/wp-content/uploads/2020/04/1587834231telegram-group-video-call-screen_1587979613-701x526.jpg

imariman avatar Jan 11 '21 18:01 imariman

You need to develop a call UI in the app.

cloudwebrtc avatar Jan 11 '21 23:01 cloudwebrtc

I couldn't find any example or information about that. Let say I developed a UI, how can I change this UI with the default Call Screen? I would appreciate if you give a little bit detail or share some links about that issue. Thank you very much.

imariman avatar Jan 11 '21 23:01 imariman

I am also looking for a solution to this. If you found the solution please don't hesitate to share.

aikd101 avatar Jan 19 '21 05:01 aikd101

I would also like to see an example.

aponski avatar Feb 02 '21 15:02 aponski

I am looking for solution also

rekonvald avatar Mar 02 '21 19:03 rekonvald

I have solved this problem by using another package called "connectycube_flutter_call_kit". Link: https://pub.dev/packages/connectycube_flutter_call_kit

By default, this package uses its custom UI which includes the Connectycube logo, but you can change it by yourself. In Windows, once I download the package, the directory of package becomes "C:\Users<username>\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\connectycube_flutter_call_kit-0.0.1-dev.1". Open Android Studio, and change "Android/src/main/res/layout/activity_incoming_call.xml".

Good luck.

imariman avatar Mar 02 '21 19:03 imariman

Thank you, but for Android we just can call backToForeground and see custom incoming call, the main difficulty is with ios(

rekonvald avatar Mar 02 '21 19:03 rekonvald

@Imariman, how did you register their plugin in the application file? ConnectycubeFlutterCallKitPlugin.registerWith fails for me. Thanks.

jenniestrongbow avatar Mar 10 '21 18:03 jenniestrongbow

@jenniestrongbow I wrote my own method.


.Application.kt

override fun registerWith(registry: PluginRegistry) {

com.connectycube.flutter.connectycube_flutter_call_kit.ConnectycubeFlutterCallKitPlugin().registerWith(registry.registrarFor("com.connectycube.flutter.connectycube_flutter_call_kit.ConnectycubeFlutterCallKitPlugin")); }


ConnectycubeFlutterCallKitPlugin.kt

fun registerWith(registrar: PluginRegistry.Registrar) { mainActivity = registrar.activity() registrar.addNewIntentListener(this) onAttachedToEngine(registrar.context(), registrar.messenger()) }

imariman avatar Mar 10 '21 18:03 imariman

@imariman thanks! Could you please publish a very simple flutter example explaining on how to use their plugin? I'm really struggling.

All I want to be able to do is show a full screen incoming call screen inside the FCM's onBackgroundMessage method.

How can I handle the accept/reject buttons in flutter?

Thanks

jenniestrongbow avatar Mar 13 '21 04:03 jenniestrongbow

@imariman, thanks to you, I managed to show the full screen notification.

Can you pls show me how to handle the accept / reject buttons?

Thanks

jenniestrongbow avatar Mar 13 '21 11:03 jenniestrongbow

@jenniestrongbow Happy to hear you have managed to show the screen you want. Handling accept/reject buttons is the easiest part. ConnectycubeFlutterCallKit.instance.init() method has two parameters; "onCallAccepted" and "onCallRejected". Just write your logic there and it works.

imariman avatar Mar 13 '21 12:03 imariman

@imariman thanks again. Last question. The init method has no impact as the showCallNotification method cannot be used with an instance. How do I use init and showCallNotification using the same instance? Thanks

jenniestrongbow avatar Mar 13 '21 22:03 jenniestrongbow

@jenniestrongbow Methods like showCallNotification, setOnLockScreenVisibility are static methods, you can't call a static method like ConnectycubeFlutterCallKit.instance.showCallNotification . The static method belongs to a class instead of class instances.

Just init the ConnectycubeFlutterCallKit with your logic, and set the fields of showCallNotification. Example code below.

` ConnectycubeFlutterCallKit.instance.init( onCallAccepted: ( String sessionId, int callType, int callerId, String callerName, Set opponentsIds, ) async { // Your Logic Here When user presses Green Button on the screen. return null; }, onCallRejected: (String sessionId, int callType, int callerId, String callerName, Set opponentsIds) { // Your Logic Here When user presses Red Button on the screen. return null; }, ); await ConnectycubeFlutterCallKit.setOnLockScreenVisibility( isVisible: true, );

    await ConnectycubeFlutterCallKit.showCallNotification(
      sessionId: sessionId,
      callType: type == "video" ? 1 : 0,
      callerName: number,
      callerId: 0,
      opponentsIds: s, 
    );

`

Hope it helps.

imariman avatar Mar 13 '21 23:03 imariman

@imariman you are a gentleman, thanks a million for your help!!!

jenniestrongbow avatar Mar 13 '21 23:03 jenniestrongbow

@imariman When app is in terminated how did u connect to socket.... can u help me that?.. socket connection works in background in flutter?... how did u figured that

sarathvs41 avatar Apr 22 '21 14:04 sarathvs41

@sarathvs41 I used Firebase Messaging to handle background messages when app is terminated. Once you trigger "onBackgroundMessage", you can show notification or add data to database. Once user clicks to notification, app starts and you can make your socket connetion to your server. There are some other alternatives like "background_fetch" but since firebase messaging solved my problem I didn't take a deep look at it.

imariman avatar Apr 22 '21 14:04 imariman

@imariman Thanks for your reply

sarathvs41 avatar Apr 22 '21 15:04 sarathvs41

@imariman I am also following your suggestions related showing call notification from onBackgroundMessage . I am able to show incoming call notification and full screen (when phone is in locked state). Can you please suggest how you managed to handle accept/reject buttons events when app is in background? I tried to apply listeners onCallAccepted and onCallRejected, but they are not working when they are set from onBackgroundMessage (or at any part in code) and app is in background.

chetansharmapsi avatar Apr 26 '21 09:04 chetansharmapsi

@imariman I am also following your suggestions related showing call notification from onBackgroundMessage . I am able to show incoming call notification and full screen (when phone is in locked state). Can you please suggest how you managed to handle accept/reject buttons events when app is in background? I tried to apply listeners onCallAccepted and onCallRejected, but they are not working when they are set from onBackgroundMessage (or at any part in code) and app is in background.

I am not sure, but It seems issue at my side is because of old flutter and firebase_messaging version.

chetansharmapsi avatar Apr 28 '21 04:04 chetansharmapsi

@imariman thanks for mentioning the package that solves Many developers problems,

I have used the plugin which you have suggested and it works when app in background mode (onCallAccepted is called - and I do my logic based on the accept/reject). but when the app is in killed state lam getting notification to accept/reject but onCallAccepted is not called , the same happens when app is in locked mode.

can you please help on this to get it done.

Thanks in advance.

aravindhkumar23 avatar May 27 '21 10:05 aravindhkumar23

@aravindhkumar23 can you share a simple example app using this plugin? I could not find a way to show the call screen.

suzanpradhan avatar Jun 13 '21 20:06 suzanpradhan

How To handle onCallAccepted in App Kill State? I use Firebase background Notification triggered but not answer. With my Function

isuru19963 avatar Aug 27 '21 08:08 isuru19963

for this we can use /packages/connectycube_flutter_call_kit

kjkartik avatar Nov 12 '21 16:11 kjkartik

can you provide me the source code for that file or project

Manishmg3994 avatar Jan 24 '22 06:01 Manishmg3994

@imariman What is the sessionId in CallEvent method, can you share the example of this plugin

Thanks in advance.

palashsethiya avatar Jul 07 '22 14:07 palashsethiya

@imariman I am developing an app in flutter. Actually, I need to display my custom incoming and outgoing call screens instead of the default call screens. Kindly help me to solve this. Thanks in advance

ShanthiniMM avatar Dec 26 '22 05:12 ShanthiniMM

@imariman @jenniestrongbow can you please share the source code

BhaskarTrigsy avatar Jan 18 '23 11:01 BhaskarTrigsy

Thank you a million @imariman you are a gentleman, you have no idea how much value you gave us

fuadj avatar Feb 17 '23 07:02 fuadj

@BhaskarTrigsy the source is part of the project https://pub.dev/packages/connectycube_flutter_call_kit. the example project is a pretty basic architecture where you include the package in your yaml file and the project does the rest. To test if the integration into your project is working, send an FCM message with your device's token.

fuadj avatar Feb 17 '23 07:02 fuadj