masashi-sutou / flutter_ios_voip_kit

One-to-one video call using CallKit and PushKit with flutter iOS app.
MIT License
67 stars 45 forks source link

When App is Terminated Flutter Callback Events are not working. #5

Closed saurav0171 closed 4 years ago

saurav0171 commented 4 years ago

Whenever app is in terminated state and I hit Voip notification, it successfully hits on my device and shows calling screen. But on accepting call it doesnt hit callback events onDidReceiveIncomingPush and onDidAcceptIncomingCall. Can you please help?

masashi-sutou commented 4 years ago

@saurav0171 Thank you for reporting.

onDidReceiveIncomingPush is not called when the app is not running, because app is not yet running when didReceiveIncomingPushWith is called. This wasn't well explained, so I'll add a comment in the next version.

On the other hand, onDidAcceptIncomingCall can be called even if the app is not running. This is because the app is already running when the incoming call screen is displayed for CallKit.

Please make sure the app is calling FlutterIOSVoIPKit.instance.onDidAcceptIncomingCall in the Dart class(e.g.: main.dart) that is called immediately after the app is launched with VoIP notifications.

saurav0171 commented 4 years ago

Thanks for your guidance I appreciate it. Adding to the discussion, I tried calling FlutterIOSVoIPKit.instance.onDidAcceptIncomingCall in main.dart. But unfortunately it didn't work. Steps to reproduce: 1: Voip Notification hits when app is in terminated state. 2: Call picked and it went into app from the beginning and didnt go into FlutterIOSVoIPKit.instance.onDidAcceptIncomingCall method.

On Mon, Jul 20, 2020 at 8:34 PM masashi-sutou notifications@github.com wrote:

@saurav0171 https://github.com/saurav0171 Thank you for reporting.

onDidReceiveIncomingPush is not called when the app is not running, because app is not yet running when didReceiveIncomingPushWith is called. This wasn't well explained, so I'll add a comment in the next version.

On the other hand, onDidAcceptIncomingCall can be called even if the app is not running. This is because the app is already running when the incoming call screen is displayed for CallKit.

Please make sure the app is calling FlutterIOSVoIPKit.instance.onDidAcceptIncomingCall in the Dart class(ex: main.dart) that is called immediately after the app is launched with VoIP notifications.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/masashi-sutou/flutter_ios_voip_kit/issues/5#issuecomment-661095934, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQLACEO23QMJGBBLU7ORP7LR4RMGFANCNFSM4PCLOJ2Q .

saurav0171 commented 4 years ago

Moreover, when app is opened via Voip Notification, it runs from very beginning and FlutterIOSVoIPKit.instance.onDidAcceptIncomingCall didn't call.

saurav0171 commented 4 years ago

Can you please let me know the method which is triggered in dart file when the app first opens via Voip Notifications?

masashi-sutou commented 4 years ago

Steps to reproduce: 1: Voip Notification hits when app is in terminated state. 2: Call picked and it went into app from the beginning and didnt go into

Is the incoming call screen of CallKit displayed at 2? If you see the incoming call screen of CallKit, is your app running after tapped Accept button(swipe when iPhone is locked)?

Can you please let me know the method which is triggered in dart file when the app first opens via VoIP Notifications?

There is no such method. This is because when the VoIP notification arrives, the app isn't running yet, so I can't call the Dart code (If it is possible to call, it will be helpful to give a PR). If your app launches after you accept(swipe or accept button) on the incoming screen I think it will be triggered callbacks in main.dart.

import 'package:flutter/material.dart';
import 'package:flutter_ios_voip_kit/flutter_ios_voip_kit.dart';

void main() {
  runApp(MaterialApp(
    home: Home(),
  ));
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  final voIPKit = FlutterIOSVoIPKit.instance;

  @override
  void initState() {
    super.initState();
    voIPKit.onDidAcceptIncomingCall = (String channelId, String callerId) {
      // Use local storage(e.g.: shared_preferences) to save the logs and check if it has been invoked.
    };

    voIPKit.onDidRejectIncomingCall = (String channelId, String callerId) {
      // Use local storage(e.g.: shared_preferences) to save the logs and check if it has been invoked.
    };
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('example'),
      ),
      body: Container(),
    );
  }
}
saurav0171 commented 4 years ago

Thanks buddy. You are a true genius.

Ranjithsp6 commented 4 years ago

If onDidReceiveIncomingPush is not called when the app is not running then how to get the payload data in this case. Can you let me know guys the possibilities to get the payload

PeppeTapick commented 4 years ago

If onDidReceiveIncomingPush is not called when the app is not running then how to get the payload data in this case. Can you let me know guys the possibilities to get the payload

I have the same problem. Is there any chance to get the payload from app terminated?

saurav0171 commented 4 years ago

You need to get this by making channels and communicating with native ios files.

On Wed, Sep 23, 2020 at 9:40 AM PeppeTapick notifications@github.com wrote:

If onDidReceiveIncomingPush is not called when the app is not running then how to get the payload data in this case. Can you let me know guys the possibilities to get the payload

I have the same problem

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/masashi-sutou/flutter_ios_voip_kit/issues/5#issuecomment-697122612, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQLACEI4GNDMCNXXTB3VPDLSHFYLJANCNFSM4PCLOJ2Q .

PeppeTapick commented 4 years ago

Hey man,

Thank you for your reply. By any chance, do you have some code example on how to do that? I am a bit weak native side..

On Wed, Sep 23, 2020 at 2:49 PM saurav0171 notifications@github.com wrote:

You need to get this by making channels and communicating with native ios files.

On Wed, Sep 23, 2020 at 9:40 AM PeppeTapick notifications@github.com wrote:

If onDidReceiveIncomingPush is not called when the app is not running then how to get the payload data in this case. Can you let me know guys the possibilities to get the payload

I have the same problem

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/masashi-sutou/flutter_ios_voip_kit/issues/5#issuecomment-697122612 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AQLACEI4GNDMCNXXTB3VPDLSHFYLJANCNFSM4PCLOJ2Q

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/masashi-sutou/flutter_ios_voip_kit/issues/5#issuecomment-697148086, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ2LU5PLGEDDRNA4VCSEJRDSHGD45ANCNFSM4PCLOJ2Q .

rekonvald commented 3 years ago

Hi @PeppeTapick, have you found solution? have the same problem(

sunilsinghchaudhary00 commented 3 months ago

check here i already give a workaround related to this https://stackoverflow.com/questions/78667613/flutter-callkit-incoming-accept-call-not-working-when-app-is-terminated