Description
Is there an existing issue for this?
- I have searched the existing issues.
Which plugins are affected?
Messaging
Which platforms are affected?
Android
Description
I am using the ABTO SIP SDK in my Flutter app, and I've implemented a SipChannel using MethodChannel for communication between Flutter and native code.
class SipChannel extends ValueNotifier<void> {
static const CHANNEL_NAME = "com.voip.sdk.channel";
MethodChannel? platform;
Object? arguments;
String methodName = "";
SipChannel() : super('') {
platform = const MethodChannel(CHANNEL_NAME);
platform?.setMethodCallHandler(handleMethod);
}
Future<dynamic> handleMethod(MethodCall call) async {
debugPrint("SipChannel handleMethod " + call.arguments.toString());
methodName = call.method;
arguments = call.arguments;
notifyListeners();
}
}
However, when I enable Firebase background message handling with the following line:
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
the method channel's handleMethod is not triggered for SIP registration events, even though the native side logs the events as expected.
For example, in SipWrapper.java, the logs indicate that the events are occurring, but the method channel call does not reach the Flutter side:
phone.setRegistrationStateListener(new OnRegistrationListener() {
@Override
public void onRegistered(long p0) {
Log.d("DEBUG_SIP_WRAPPER", "onRegistered");
channel.invokeMethod(RESULT_REGISTERED, null);
}
@Override
public void onUnRegistered(long p0) {
Log.d("DEBUG_SIP_WRAPPER", "onUnRegistered");
channel.invokeMethod(RESULT_UNREGISTERED, null);
}
@Override
public void onRegistrationFailed(long p0, int p1, String p2) {
if (p1 == 100) return;
Log.d("DEBUG_SIP_WRAPPER", "onRegistrationFailed: " + p0 + ", " + p1 + ", " + p2);
channel.invokeMethod(RESULT_REG_FAILED, null);
}
});
If I comment out the Firebase background message handler line, the method channel works as expected, and the SIP SDK events are passed correctly to Flutter.
Expected Behavior:
The handleMethod should be invoked even when Firebase background message handling is enabled.
Actual Behavior:
When Firebase background message handling is enabled, handleMethod is not triggered, even though native logs indicate that the SIP registration events are occurring.
Reproducing the issue
Steps to Reproduce:
-
Enable Firebase background message handling in the app using:
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
-
Set up the MethodChannel in Flutter as shown in the code above.
-
Register the SIP SDK and observe that handleMethod is not triggered despite native logs confirming the events.
-
Comment out the Firebase background message handler line and observe that the method channel works as expected.
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 15.0.1 24A348 darwin-arm64, locale en-OM)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] Connected device (5 available)
[✓] Network resources
Firebase Core version
2.24.2
Flutter Version
3.24.3
Relevant Log Output
No response
Flutter dependencies
Expand Flutter dependencies
snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.
Additional context and comments
No response