firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.63k stars 3.95k forks source link

[firebase_messaging]: New FCM is already subscribed to the older topics. #12567

Closed sumittiware closed 5 months ago

sumittiware commented 5 months ago

Is there an existing issue for this?

Which plugins are affected?

Messaging

Which platforms are affected?

Android, iOS

Description

We have been facing an weird issue with FCM lately, where out users are still getting the notification even if they logout of the app. We are using Flutter for out android application, and a backend service that subscribes the FCM token to specific topics. Now when the user logs out of our application we delete the existing FCM token of the device using following method : await FirebaseMessaging.instance.deleteToken(); And after the token is deleted we get new token from the firebase method using final String? fcmToken = await FirebaseMessaging.instance.getToken(); what we have noticed is that the fcmToken which is different from the older token, but is still subscribed to the topic to which older token was subscribed. It should give a fresh token right which is not subscribed to any topic, right?, or is this an expected behaviour and we need to do some manual un-subscription from our end to avoid this issue? Please help!!

Reproducing the issue

static Future<void> forceRefreshFCMToken() async {
    final SharedPreferenceHelper prefHelper =
        GetIt.I.get<SharedPreferenceHelper>();
    final UserRepository userRepository = GetIt.I.get<UserRepository>();
    final DeviceRegisterInfo oldDeviceRegisterInfo =
        DeviceRegisterInfo.fromJson(await prefHelper.getRegisteredDeviceInfo());
    await FirebaseMessaging.instance.deleteToken();
    final String? fcmToken = await FirebaseMessaging.instance.getToken();
    if (fcmToken != null) {
      await prefHelper.updateDeviceInfo(
        deviceInfo: DeviceRegisterInfo(
          deviceId: oldDeviceRegisterInfo.deviceId,
          fcmToken: fcmToken,
        ).toJson(),
      );
      final DeviceRegisterInfo newDeviceRegisterInfo =
          DeviceRegisterInfo.fromJson(
              await prefHelper.getRegisteredDeviceInfo());
      UpsertDeviceResponse? upsertResponse;
      final Map<String, dynamic> deviceInfo = await getDeviceInfo();
      try {
        upsertResponse = await userRepository.upsertDevice(
          upsertDeviceRequest: UpsertDeviceRequest(
            deviceId: newDeviceRegisterInfo.deviceId,
            fcmToken: newDeviceRegisterInfo.fcmToken,
            deviceInfo: deviceInfo,
          ),
        );
      } catch (error, stack) {
        FirebaseCrashlytics.instance.recordError(error, stack);
      }

      if (upsertResponse != null) {
        await prefHelper.updateDeviceInfo(
          deviceInfo: newDeviceRegisterInfo
              .copyWith(
                userMapped: upsertResponse.userMapped,
                deviceSynced: true,
              )
              .toJson(),
        );
      }
    }
  }

This the code, if you see lines

await FirebaseMessaging.instance.deleteToken();
final String? fcmToken = await FirebaseMessaging.instance.getToken(); 

We delete the existing token with deleteToken() method and get new token in the next line.

The new token which we have got, is already subscribed to all the topics, while we still haven't made any calls to our BE service for the subscription.

Firebase Core version

2.17.0

Flutter Version

3.10.0

Relevant Log Output

No response

Flutter dependencies

Expand Flutter dependencies snippet
```yaml art SDK 3.0.5 Flutter SDK 3.10.5 app 5.0.2+336 dependencies: - android_path_provider 0.3.0 [flutter] - any_link_preview 3.0.0 [flutter html http shared_preferences string_validator url_launcher] - audio_session 0.1.13 [flutter flutter_web_plugins rxdart meta] - cached_network_image 3.3.0 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image] - camera 0.10.5+9 [camera_android camera_avfoundation camera_platform_interface camera_web flutter flutter_plugin_android_lifecycle] - carousel_slider 4.2.1 [flutter] - clippy_flutter 2.0.0-nullsafety.1 [flutter] - cloud_firestore 4.9.3 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - collection 1.17.1 - confetti 0.7.0 [flutter vector_math] - connectivity_plus 2.3.9 [flutter connectivity_plus_platform_interface connectivity_plus_linux connectivity_plus_macos connectivity_plus_web connectivity_plus_windows] - country_code_picker 3.0.0 [flutter collection] - crypto 3.0.3 [typed_data] - dartz 0.10.1 - debounce_throttle 2.0.0 [meta simple_observable] - device_info_plus 8.1.0 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta win32] - dio 4.0.6 [http_parser path] - dots_indicator 2.1.0 [flutter] - emoji_picker_flutter 1.5.2 [flutter flutter_web_plugins plugin_platform_interface shared_preferences] - equatable 2.0.5 [collection meta] - expandable_text 2.3.0 [flutter] - facebook_app_events 0.19.0 [flutter] - figma_squircle 0.5.3 [vector_math flutter] - file_picker 5.3.1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32] - firebase_analytics 10.1.5 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_core 2.17.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.3.7 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_dynamic_links 5.0.16 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_messaging 14.6.9 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_storage 11.2.8 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - flick_video_player 0.5.0 [flutter video_player provider wakelock_plus universal_html dio path_provider] - flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine] - flutter_cache_manager 3.3.1 [clock collection file flutter http path path_provider rxdart sqflite uuid] - flutter_cached_pdfview 0.4.2 [flutter flutter_pdfview flutter_cache_manager path_provider path] - flutter_dotenv 5.0.2 [flutter] - flutter_form_builder 9.1.1 [flutter intl] - flutter_inappwebview 5.8.0 [flutter] - flutter_local_notifications 16.2.0 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone] - flutter_localizations 0.0.0 [flutter intl characters clock collection js material_color_utilities meta path vector_math] - flutter_mobx 2.0.6+5 [flutter mobx] - flutter_modular 5.0.3 [flutter_modular_annotations modular_core meta flutter] - flutter_parsed_text 2.2.1 [flutter] - flutter_rating_bar 4.0.1 [flutter] - flutter_screenutil 5.7.0 [flutter] - flutter_sound 9.2.13 [path_provider recase uuid provider path synchronized logger flutter flutter_sound_platform_interface flutter_sound_web] - flutter_svg 1.1.6 [flutter meta path_drawing vector_math xml] - form_builder_validators 9.0.0 [flutter flutter_localizations intl] - freezed_annotation 2.2.0 [collection json_annotation meta] - get_it 7.2.0 [async collection] - growthbook_sdk_flutter 2.1.0+0 [dio flutter json_annotation tuple] - image_picker 0.8.7 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_platform_interface] - in_app_purchase 3.1.5 [flutter in_app_purchase_android in_app_purchase_platform_interface in_app_purchase_storekit] - in_app_update 4.0.1 [flutter] - injectable 1.5.4 [get_it] - intl 0.18.0 [clock meta path] - json_annotation 4.8.1 [meta] - liquid_swipe 3.0.0 [flutter provider] - logging 1.1.0 - lottie 2.5.0 [archive flutter path vector_math] - media_info 0.11.0 [mime flutter] - mime 1.0.4 - mobx 2.2.0 [meta] - nb_utils 4.6.21 [flutter shared_preferences fluttertoast connectivity_plus] - ntp 2.0.0 - open_filex 4.3.2 [flutter ffi] - package_info_plus 4.2.0 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32] - path_provider 2.0.13 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - percent_indicator 4.2.3 [flutter] - permission_handler 11.0.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface] - photo_manager 2.7.2 [flutter] - photo_view 0.14.0 [flutter] - provider 6.0.5 [collection flutter nested] - razorpay_flutter 1.3.5 [flutter eventify fluttertoast package_info_plus] - receive_sharing_intent 1.4.5 [flutter] - scrollable_positioned_list 0.3.8 [flutter collection] - share_plus 7.0.0 [cross_file meta mime flutter flutter_web_plugins share_plus_platform_interface file url_launcher_web url_launcher_windows url_launcher_linux url_launcher_platform_interface ffi win32] - sliver_tools 0.2.12 [flutter] - sms_autofill 2.3.0 [pin_input_text_field flutter] - sticky_headers 0.3.0+2 [flutter] - synchronized 3.0.0+3 - upgrader 6.5.0 [flutter device_info_plus html http os_detect package_info_plus shared_preferences url_launcher version xml] - url_launcher 6.1.10 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - uuid 3.0.7 [crypto] - video_compress 3.1.1 [flutter] - video_thumbnail 0.5.3 [flutter] - visibility_detector 0.3.3 [flutter] - webengage_flutter 1.2.4 [flutter] - win32 4.1.4 [ffi] dev dependencies: - analyzer 5.13.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - build_runner 2.3.3 [args async analyzer build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - cloud_firestore_odm_generator 1.0.0-dev.45 [analyzer build build_config cloud_firestore_odm collection freezed_annotation json_annotation meta recase source_gen] - dart_code_metrics 5.7.5 [analyzer analyzer_plugin ansicolor args collection crypto dart_code_metrics_presets file glob html http meta path platform pub_updater source_span uuid xml yaml] - dependency_validator 3.2.2 [args build_config checked_yaml glob io json_annotation logging package_config path pub_semver pubspec_parse yaml] - flutter_launcher_icons 0.11.0 [args checked_yaml cli_util image json_annotation path yaml] - flutter_lints 2.0.1 [lints] - flutter_native_splash 2.2.9 [args flutter flutter_web_plugins html image js lint meta path universal_io xml yaml] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph] - freezed 2.2.0 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation] - injectable_generator 1.5.5 [build source_gen path glob analyzer code_builder dart_style injectable collection] - json_serializable 6.6.2 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper] - mobx_codegen 2.1.1 [analyzer build build_resolvers meta mobx path source_gen] - modular_test 2.0.0 [modular_core] - translations_cleaner 0.0.5 [args glob] dependency overrides: - fluttertoast 8.0.9 [flutter flutter_web_plugins] - modal_bottom_sheet 3.0.0-pre [flutter] transitive dependencies: - _fe_analyzer_shared 61.0.0 [meta] - _flutterfire_internals 1.3.7 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer_plugin 0.11.2 [analyzer collection dart_style pub_semver yaml] - ansicolor 2.0.1 - archive 3.3.6 [crypto path pointycastle] - args 2.3.1 - async 2.11.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - build 2.3.1 [analyzer async convert crypto glob logging meta path] - build_config 1.1.1 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 3.1.1 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.0.10 [analyzer async build crypto graphs logging path package_config pool pub_semver stream_transform yaml] - build_runner_core 7.2.7 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.4.4 [built_collection collection fixnum meta] - cached_network_image_platform_interface 3.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.1.0 [cached_network_image_platform_interface flutter flutter_cache_manager] - camera_android 0.10.7 [camera_platform_interface flutter flutter_plugin_android_lifecycle stream_transform] - camera_avfoundation 0.9.13+10 [camera_platform_interface flutter stream_transform] - camera_platform_interface 2.5.0 [cross_file flutter plugin_platform_interface stream_transform] - camera_web 0.3.1+3 [camera_platform_interface flutter flutter_web_plugins stream_transform] - characters 1.3.0 - charcode 1.3.1 - checked_yaml 2.0.1 [json_annotation source_span yaml] - cli_util 0.3.5 [meta path] - clock 1.1.1 - cloud_firestore_odm 1.0.0-dev.51 [cloud_firestore flutter json_annotation meta] - cloud_firestore_platform_interface 5.16.2 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.7.2 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.4.0 [built_collection built_value collection matcher meta] - connectivity_plus_linux 1.3.1 [flutter connectivity_plus_platform_interface meta nm] - connectivity_plus_macos 1.2.6 [connectivity_plus_platform_interface flutter] - connectivity_plus_platform_interface 1.2.4 [flutter meta plugin_platform_interface] - connectivity_plus_web 1.2.5 [connectivity_plus_platform_interface flutter_web_plugins flutter js] - connectivity_plus_windows 1.2.2 [connectivity_plus_platform_interface flutter] - convert 3.1.0 [typed_data] - cross_file 0.3.3+4 [js meta] - csslib 0.17.2 [source_span] - dart_code_metrics_presets 1.8.0 - dart_style 2.2.4 [analyzer args path pub_semver source_span] - dbus 0.7.8 [args ffi meta xml] - device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface] - eventify 1.0.1 - fake_async 1.3.1 [clock collection] - ffi 2.0.1 - file 6.1.4 [meta path] - firebase_analytics_platform_interface 3.3.22 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.1+13 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.8.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.6.7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_dynamic_links_platform_interface 0.2.3+31 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 4.5.8 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.5.8 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_storage_platform_interface 4.4.7 [collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.6.8 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - fixnum 1.0.1 - flutter_local_notifications_linux 4.0.0+1 [dbus ffi flutter flutter_local_notifications_platform_interface path xdg_directories] - flutter_local_notifications_platform_interface 7.0.0+1 [flutter plugin_platform_interface] - flutter_modular_annotations 0.0.2 [flutter] - flutter_pdfview 1.2.5 [flutter] - flutter_plugin_android_lifecycle 2.0.9 [flutter] - flutter_sound_platform_interface 9.2.13 [flutter meta plugin_platform_interface logger] - flutter_sound_web 9.2.13 [flutter_sound_platform_interface flutter logger flutter_web_plugins meta js] - flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math] - frontend_server_client 3.2.0 [async path] - glob 2.1.1 [async collection file path string_scanner] - graphs 2.2.0 [collection] - html 0.15.2 [csslib source_span] - http 0.13.5 [async http_parser meta path] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - image 3.3.0 [archive meta xml] - image_picker_android 0.8.6+1 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 2.1.12 [flutter flutter_web_plugins image_picker_platform_interface] - image_picker_ios 0.8.6+9 [flutter image_picker_platform_interface] - image_picker_platform_interface 2.6.3 [cross_file flutter http plugin_platform_interface] - in_app_purchase_android 0.2.4+3 [collection flutter in_app_purchase_platform_interface json_annotation] - in_app_purchase_platform_interface 1.3.3 [flutter plugin_platform_interface] - in_app_purchase_storekit 0.3.5+2 [collection flutter in_app_purchase_platform_interface json_annotation] - io 1.0.4 [meta path string_scanner] - js 0.6.7 [meta] - lint 1.10.0 - lints 2.0.1 - logger 1.3.0 - matcher 0.12.15 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.2.0 - meta 1.9.1 - modular_core 2.0.3+1 [characters meta modular_interfaces] - modular_interfaces 2.0.2 - nested 1.0.0 [flutter] - nm 0.5.0 [dbus] - octo_image 2.0.0 [flutter] - os_detect 2.0.1 - package_config 2.1.0 [path] - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path 1.8.3 - path_drawing 1.0.1 [vector_math meta path_parsing flutter] - path_parsing 1.0.1 [vector_math meta] - path_provider_android 2.0.24 [flutter path_provider_platform_interface] - path_provider_foundation 2.1.3 [flutter path_provider_platform_interface] - path_provider_linux 2.1.10 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.0.6 [flutter platform plugin_platform_interface] - path_provider_windows 2.1.7 [ffi flutter path path_provider_platform_interface win32] - permission_handler_android 11.1.0 [flutter permission_handler_platform_interface] - permission_handler_apple 9.1.4 [flutter permission_handler_platform_interface] - permission_handler_platform_interface 3.12.0 [flutter meta plugin_platform_interface] - permission_handler_windows 0.1.3 [flutter permission_handler_platform_interface] - petitparser 5.0.0 [meta] - pin_input_text_field 4.4.1 [flutter] - platform 3.1.0 - plugin_platform_interface 2.1.4 [meta] - pointycastle 3.6.2 [collection convert js] - pool 1.5.1 [async stack_trace] - process 4.2.4 [file path platform] - pub_semver 2.1.3 [collection meta] - pub_updater 0.3.0 [http json_annotation process pub_semver] - pubspec_parse 1.2.1 [checked_yaml collection json_annotation pub_semver yaml] - recase 4.1.0 - rxdart 0.27.7 - share_plus_platform_interface 3.2.1 [cross_file flutter meta mime plugin_platform_interface path_provider uuid] - shared_preferences 2.0.18 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - shared_preferences_android 2.0.17 [flutter shared_preferences_platform_interface] - shared_preferences_foundation 2.1.5 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.1.5 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_platform_interface 2.1.1 [flutter plugin_platform_interface] - shared_preferences_web 2.0.6 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.1.5 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.4.0 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.3 [shelf stream_channel web_socket_channel] - simple_observable 2.0.0 [meta] - sky_engine 0.0.99 - source_gen 1.2.6 [analyzer async build dart_style glob meta path source_span yaml] - source_helper 1.3.3 [analyzer collection source_gen] - source_span 1.9.1 [collection path term_glyph] - sqflite 2.3.0 [flutter sqflite_common path] - sqflite_common 2.5.0 [synchronized path meta] - stack_trace 1.11.0 [path] - stream_channel 2.1.1 [async] - stream_transform 2.1.0 - string_scanner 1.2.0 [source_span] - string_validator 0.3.0 - term_glyph 1.2.1 - test_api 0.5.1 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher] - timezone 0.9.2 [path] - timing 1.0.1 [json_annotation] - tuple 2.0.1 - typed_data 1.3.1 [collection] - universal_html 2.2.1 [async csslib charcode collection html meta source_span typed_data universal_io] - universal_io 2.2.0 [collection meta typed_data] - url_launcher_android 6.0.25 [flutter url_launcher_platform_interface] - url_launcher_ios 6.0.18 [flutter url_launcher_platform_interface] - url_launcher_linux 3.0.6 [flutter url_launcher_platform_interface] - url_launcher_macos 3.0.4 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.1.2 [flutter plugin_platform_interface] - url_launcher_web 2.0.16 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.0.8 [flutter url_launcher_platform_interface] - vector_math 2.1.4 - version 3.0.2 - video_player 2.6.0 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web] - video_player_android 2.4.1 [flutter video_player_platform_interface] - video_player_avfoundation 2.3.9 [flutter video_player_platform_interface] - video_player_platform_interface 6.0.2 [flutter plugin_platform_interface] - video_player_web 2.0.15 [flutter flutter_web_plugins video_player_platform_interface] - wakelock_plus 1.1.3 [flutter flutter_web_plugins meta wakelock_plus_platform_interface win32 dbus package_info_plus js] - wakelock_plus_platform_interface 1.1.0 [flutter plugin_platform_interface meta] - watcher 1.0.2 [async path] - web_socket_channel 2.3.0 [async crypto stream_channel] - xdg_directories 0.2.0+3 [meta path process] - xml 6.1.0 [collection meta petitparser] - yaml 3.1.1 [collection source_span string_scanner] ```

Additional context and comments

No response

TarekkMA commented 5 months ago

Thank you @sumittiware for reporting this issue. I've been able to replicate it.

sumittiware commented 5 months ago

Hi @TarekkMA thank you for the response, was this issue always there or is newly introduced?

TarekkMA commented 5 months ago

I'm unsure if this behavior is new. I've reported an issue on the Firebase repository to clarify whether it's a bug, intended functionality, or if there's another issue at play.

princebansal commented 5 months ago

@TarekkMA Any updates on this?

TarekkMA commented 5 months ago

I've opened an issue regarding this at https://github.com/firebase/firebase-android-sdk/issues/5824. We're currently awaiting confirmation from the Firebase team to determine if this behavior is intended or a bug. You can add a 👍 to the original issue to indicate its importance/priority.

princebansal commented 5 months ago

I've opened an issue regarding this at firebase/firebase-android-sdk#5824. We're currently awaiting confirmation from the Firebase team to determine if this behavior is intended or a bug. You can add a 👍 to the original issue to indicate its importance/priority.

Thanks a lot. Can you please also add needs-attention label to the issue? That would help in the escalations.

TarekkMA commented 5 months ago

@princebansal, I don't have control over firebase-android-sdk. Let's just wait for couple of days and see what the Firebase team says about it.

TarekkMA commented 5 months ago

@princebansal @sumittiware, This seem to be working as intended.

From the reply I got from the firebase repo (https://github.com/firebase/firebase-android-sdk/issues/5824):

The invalidated tokens aren't immediately deleted. Our internal jobs run on a daily basis and thus the deletion and invalidation of FCM tokens should be done in a day or so.

The best course of action would be to just subscribe and unsubscribe to topics as needed. Take note that both subscribe and unsubscribe calls are done in the background, and there are no hooks that allows the SDK to detect when the subscribe/unsubscribe call completes, so there's also no guarantee how long the call may take, but I think it'll be a lot shorter compared to the 1 day duration.