ably / ably-flutter

A wrapper around our Cocoa and Java client library SDKs, providing iOS and Android support for those using Flutter and Dart.
https://ably.com/download
Apache License 2.0
60 stars 16 forks source link

FirebaseMessaging.onBackgroundMessage is not called after install ably_flutter: ^1.2.34 #556

Open tharro opened 2 weeks ago

tharro commented 2 weeks ago
@pragma('vm:entry-point')
Future<void> _ablyMessagingBackgroundHandler(ably.RemoteMessage message) async {
  print("Handling a background message: ");
}
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  print("Handling a background message: ${message.data}");
  await Firebase.initializeApp();
}
void main() async { 
    WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp();
    ably.Push.notificationEvents
        .setOnBackgroundMessage(_ablyMessagingBackgroundHandler);
    FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
    Bloc.observer = SimpleBlocObserver();
    runApp(EasyLocalization(
        supportedLocales: const [Locale('en', 'US')],
        path: 'assets/translations',
        fallbackLocale: const Locale('en', 'US'),
        child: const BlocManager()));
}

_ablyMessagingBackgroundHandler also not called

pubspec.yaml firebase_core: ^2.12.0 firebase_messaging: ^14.6.0 firebase_analytics: ^10.4.0 firebase_crashlytics: ^3.3.0 flutter_local_notifications: ^17.2.1 device_info_plus: ^10.0.1 ably_flutter: ^1.2.34

If I remove ably_flutter, it's working

┆Issue is synchronized with this Jira Task by Unito

ttypic commented 2 weeks ago

Hey @tharro,

Thank you very much for reporting this issue! Could you please let us know on which platform this issue occurs—Android, iOS, or both? Additionally, could you share a verbose log from your app? Lastly, does the problem occur immediately after installing ably_flutter, even if ably.Push.notificationEvents.setOnBackgroundMessage(_ablyMessagingBackgroundHandler); hasn’t been called?

tharro commented 2 weeks ago

Hey @tharro,

Thank you very much for reporting this issue! Could you please let us know on which platform this issue occurs—Android, iOS, or both? Additionally, could you share a verbose log from your app? Lastly, does the problem occur immediately after installing ably_flutter, even if ably.Push.notificationEvents.setOnBackgroundMessage(_ablyMessagingBackgroundHandler); hasn’t been called?

Yep, both. The problem occur immediately after installing ably_flutter event if ably.Push.notificationEvents.setOnBackgroundMessage(_ablyMessagingBackgroundHandler); hasn’t been called. I will show verbose log soon

tharro commented 1 week ago

When I remove 'ably_flutter'. _firebaseMessagingBackgroundHandler is working. If re-install 'ably_flutter', it's not working.

10.25.0 - [FirebaseAnalytics][I-ACS023220] Analytics screen reporting is enabled. Call Analytics.logEvent(AnalyticsEventScreenView, parameters: [...]) to log a screen view event. To disable automatic screen reporting, set the flag FirebaseAutomaticScreenReportingEnabled to NO (boolean) in the Info.plist Connecting to VM Service at ws://127.0.0.1:64818/WY61PCmy5PM=/ws flutter: FCM Token: crIQvIgFDUf0naqG0ipOwN:APA91bGEUuLb8uDA3frtwPixZoYxfw6k4eewn1coWDKnyq_uMujvaLpjxYM6ZRGXVjf1CP_2R37kmZzjdpf3EHt9pULoGh-ZsReGO1kiksFu7NXBtA_EbCW5E6t2EzG3GgQIfT_2GpeK flutter: \^[[90m[🌎 Easy Localization] [DEBUG] Localization initialized<…> flutter: \^[[90m[🌎 Easy Localization] [DEBUG] Start<…> flutter: \^[[90m[🌎 Easy Localization] [DEBUG] Init state<…> flutter: \^[[90m[🌎 Easy Localization] [DEBUG] Build<…> flutter: \^[[90m[🌎 Easy Localization] [DEBUG] Init Localization Delegate<…> flutter: \^[[90m[🌎 Easy Localization] [DEBUG] Init provider<…> flutter: \^[[34m[🌎 Easy Localization] [WARNING] Localization key [key_press_again_to_exit_app] not found<…> flutter: \^[[90m[🌎 Easy Localization] [DEBUG] Load Localization Delegate<…> flutter: \^[[90m[🌎 Easy Localization] [DEBUG] Load asset from assets/translations<…> flutter: SetConversationSelected() flutter: Handling a background message: {call_id: 83b6e974-4f89-4ca6-a044-80e5ed244e3c, action: CALL, caller: Tharo}