Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Notification for call from firebase method onmessage while socket is connected. #110

Closed
1 of 9 tasks
Kushagra-Esmagico opened this issue Feb 17, 2025 · 9 comments
Closed
1 of 9 tasks
Assignees
Labels
bug Something isn't working

Comments

@Kushagra-Esmagico
Copy link

Bug Category

  • Credential Login
  • Token Login
  • Local Audio Issue
  • Remote Audio Issue
  • Audio Device Switching
  • Mute / Unmute
  • Hold / Unhold
  • Performance issues
  • Other

SDK Version
Which version of the SDK have you added from pub.dev? Feel free to add the whole dependency implementation:
: telnyx_webrtc: ^1.0.1

Describe the bug
Getting Notification for call from firebase method onmessage while socket is connected.

Expected behaviour
It should only notify via socket , INVITE method.

To Reproduce
Steps to reproduce the behaviour:

  1. Log on with credentials token
  2. And make sure app is open and socket connected state. It is happening intermittently.

** Device (please complete the following information):**

  • Emulator: false
  • Device/Browser Android device
  • OS Version: Android 13
@Kushagra-Esmagico Kushagra-Esmagico added the bug Something isn't working label Feb 17, 2025
@Oliver-Zimmerman
Copy link
Collaborator

Hi @Kushagra-Esmagico

Can you confirm the state of the application? Are you referring to when it is in the foreground or background? (obviously not terminated).

Also are you testing with the sample application or your own implementation?

@Kushagra-Esmagico
Copy link
Author

Hi @Oliver-Zimmerman , State of the application is foreground . I am testing with my own implementation .
It's happening intermittently .

@Oliver-Zimmerman
Copy link
Collaborator

@Kushagra-Esmagico Please be aware that the app behaves differently in debug build than it does for a production release builds on Android namely background connections such as the socket connection actually stay awake longer for a debug build then they do for a release build.

Please look into how we are handling background states here:
https://github.com/team-telnyx/flutter-voice-sdk/blob/main/lib/utils/background_detector.dart

Lastly please utilize the sample app (you can run firebase init to link your firebase to our sample) and test that way to confirm whether or not it is happening there. If not please reference our implementation for your own implementation.

Thanks!

@Kushagra-Esmagico
Copy link
Author

@Oliver-Zimmerman , I will run the sample app and try to implement the same .

@Oliver-Zimmerman
Copy link
Collaborator

@Kushagra-Esmagico can I close?

@Kushagra-Esmagico
Copy link
Author

@Oliver-Zimmerman The implementation in my code base is same as demo code , Sometime Telnyx server is sending the push notification for call . It happens when we just login into sip connection and try to make an inbound call . It is happening intermittently . Is there any threshold time frame that is used to make the decision if webrtc client is connected or not , based on that , it is sending socket message or notification message to connect the call ?

@Oliver-Zimmerman
Copy link
Collaborator

@Kushagra-Esmagico as soon as the socket connection is closed the user is unregistered on our backend and if there is a token associated with that user then we will send a push notification.

Sometimes if you are not manually disconnecting from the socket when you background the app, etc then it can take a couple of seconds for Android to terminate the socket connection.

This is why we have a state listener in our sample application to actually manually disconnect as soon as we background the application - so that we force the disconnection and deregisteration from our backend.

@Kushagra-Esmagico
Copy link
Author

@Oliver-Zimmerman
We are also doing the socket disconnection when app goes in background , But in issue , I am facing , When App is in foreground , And suppose user opens the notification drawer , and try to make an inbound call to client from Skype , it sends push notification while the socket is connected as app lifecycle is not Paused, from app lifecycle , it sends it in Inactive mode only . And these Issues , I am facing on Android only .

@Oliver-Zimmerman
Copy link
Collaborator

@Kushagra-Esmagico you need to disconnect from the socket when it is inactive in that case then.

Right now we area doing this:

        else if (state == AppLifecycleState.paused)
          {
            logger.i(
              'We are in the background setting fromBackground == true, DISCONNECTING',
            ),
            fromBackground = true,
            txClientViewModel.disconnect(),
          },
      },

It sounds like you need to do something like this:

        else if (state == AppLifecycleState.paused || state == AppLifecycleState.inactive)
          {
            logger.i(
              'We are in the background setting fromBackground == true, DISCONNECTING',
            ),
            fromBackground = true,
            txClientViewModel.disconnect(),
          },
      },

If I were you I would print the exact lifecycle states through the BackgroundDetector I made and make sure you are disconnecting and reconnecting where appropriate.

Ultimately I want to make it clear that you will not receive a push notification from firebase while connected to the socket. You have to be disconnected.

One thing I will highlight is that through the flutter_incoming_callkit library that we use you can pop a local notification when receiving a call at any time while still connected to the socket and this should appear in the notification tray.
https://pub.dev/packages/flutter_callkit_incoming

Ultimately though @Kushagra-Esmagico I'm not even sure if I can reproduce your issue. Here is a video example of a background push notification as well as a push notification when the notification tray is open on our sample app.

Screen.Recording.2025-02-26.at.09.47.21.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants