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

[firebase_auth]: NotificationService extension not working since iOS SDK 11.0.0 #13346

Open
1 task done
OutdatedGuy opened this issue Sep 17, 2024 · 11 comments
Open
1 task done
Labels
Needs Attention This issue needs maintainer attention. platform: ios Issues / PRs which are specifically for iOS. platform: macos Issues / PRs which are specifically for MacOS. plugin: auth type: bug Something isn't working

Comments

@OutdatedGuy
Copy link
Contributor

OutdatedGuy commented Sep 17, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Auth, Messaging

Which platforms are affected?

iOS, macOS

Description

The NotificationService extension to handle images from firebase messaging payload on iOS and macOS has stopped working since upgraded packages with iOS SDK 11.0.0.

Before upgrading all package that uses iOS 11.0.0 the NotificationService extension was working and compiling perfectly. But after upgrading packages I'm getting following error while compiling flutter app on iOS:

Error Logs

Failed to build iOS app
ARC Semantic Issue (Xcode): Receiver 'FIRAuth' for class message is a forward declaration
project/ios/Image%20Notification/NotificationService.m:24:8


ARC Semantic Issue (Xcode): No known class method for selector 'auth'
project/ios/Image%20Notification/NotificationService.m:24:16


ARC Semantic Issue (Xcode): No known instance method for selector 'canHandleURL:'
project/ios/Image%20Notification/NotificationService.m:24:22


Semantic Issue (Xcode): Property 'auth' not found on object of type 'FIRAuth'
project/ios/Image%20Notification/NotificationService.m:32:13


Encountered error while archiving for device.

NotificationService.m

//
//  NotificationService.m
//  Image Notification
//
//
//

#import "NotificationService.h"
#import "FirebaseMessaging.h"
#import "FirebaseAuth.h" // Add this line if you are using FirebaseAuth phone authentication
#import <UIKit/UIKit.h> // Add this line if you are using FirebaseAuth phone authentication

@interface NotificationService ()

@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;

@end

@implementation NotificationService

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
  if ([[FIRAuth auth] canHandleURL:url]) {
    return YES;
  }
  return NO;
}

- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
  for (UIOpenURLContext *urlContext in URLContexts) {
    [FIRAuth.auth canHandleURL:urlContext.URL];
  }
}

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    self.contentHandler = contentHandler;
    self.bestAttemptContent = [request.content mutableCopy];

    // Modify the notification content here...
    [[FIRMessaging extensionHelper] populateNotificationContent:self.bestAttemptContent withContentHandler:contentHandler];
}

- (void)serviceExtensionTimeWillExpire {
    // Called just before the extension will be terminated by the system.
    // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
    self.contentHandler(self.bestAttemptContent);
}

@end

Podfile

target 'Image Notification' do
  use_frameworks!
  pod 'Firebase/Auth' # Add this line if you are using FirebaseAuth phone authentication
  pod 'Firebase/Messaging'

  # ? Required to fix duplicate pod path error
  pod 'GoogleUtilities'
end

Reproducing the issue

  1. Create a flutter app
  2. Add firebase_core >= 3.4.0, firebase_messaging >=15.1.0 & firebase_auth >= 5.2.0
  3. Follow these steps from official documentation to add NotificationService
  4. Build app for iOS and see above mentioned crash

Firebase Core version

3.4.1

Flutter Version

3.24.3

Relevant Log Output

No response

Flutter dependencies

Expand Flutter dependencies snippet
Dart SDK 3.5.3
Flutter SDK 3.24.3
client_app_5amclub 7.7.5+34

dependencies:
- algolia_helper_flutter 1.1.0 [algolia_insights algoliasearch collection flutter logging meta rxdart]
- animated_text_kit 4.2.2 [flutter characters]
- app_links 6.3.2 [flutter app_links_linux app_links_platform_interface app_links_web]
- awesome_notifications 0.9.3+1 [flutter flutter_web_plugins plugin_platform_interface intl]
- badges 3.1.2 [flutter]
- cached_network_image 3.4.1 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image]
- cached_video_player_plus 3.0.3 [flutter flutter_cache_manager get_storage html video_player_android video_player_avfoundation video_player_platform_interface video_
player_web]                                                                                                                                                           - carousel_slider 5.0.0 [flutter]
- cloud_firestore 5.4.1 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- cloud_functions 5.1.1 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter]
- country_ip 3.0.0 [http]
- dart_ipify 1.1.1 [http]
- dotted_border 2.1.0 [flutter path_drawing]
- email_validator 3.0.0
- ensure_visible_when_focused 1.2.0 [flutter]
- firebase_analytics 11.3.1 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter]
- firebase_app_check 0.3.1+1 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter]
- firebase_auth 5.2.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 3.4.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_crashlytics 4.1.1 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- firebase_messaging 15.1.1 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- firebase_performance 0.10.0+6 [firebase_core firebase_core_platform_interface firebase_performance_platform_interface firebase_performance_web flutter]
- firebase_storage 12.3.0 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_dotenv 5.1.0 [flutter]
- flutter_easyloading 3.0.5 [flutter flutter_spinkit]
- flutter_tts 4.0.2 [flutter flutter_web_plugins]
- flutter_udid 3.0.0 [flutter crypto]
- font_awesome_flutter 10.7.0 [flutter]
- get_storage 2.1.1 [flutter get path_provider]
- google_fonts 6.2.1 [flutter http path_provider crypto]
- http 1.2.2 [async http_parser meta web]
- image_cropper 8.0.2 [flutter image_cropper_platform_interface image_cropper_for_web]
- image_picker 1.1.2 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_linux image_picker_macos image_picker_platform_interface image_p
icker_windows]                                                                                                                                                        - infinite_scroll_pagination 4.0.0 [flutter flutter_staggered_grid_view sliver_tools]
- intl 0.19.0 [clock meta path]
- just_the_tooltip 0.0.12 [flutter]
- lottie 3.1.2 [archive flutter http path vector_math]
- path 1.9.0
- path_provider 2.1.4 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- phone_form_field 9.2.7 [flutter flutter_localizations intl flutter_country_selector circle_flags phone_numbers_parser]
- pinput 5.0.0 [flutter universal_platform]
- progress_border 0.1.5 [flutter]
- provider 6.1.2 [collection flutter nested]
- razorpay_flutter 1.3.6 [eventify flutter fluttertoast package_info_plus]
- readmore 3.0.0 [flutter]
- receive_sharing_intent_plus 1.0.1 [flutter]
- share_plus 10.0.2 [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 web win32]                                                                                                                            - smart_auth 2.0.0 [flutter flutter_web_plugins]
- timeline_tile 2.0.0 [flutter]
- upgrader 11.1.0 [flutter device_info_plus html http os_detect package_info_plus shared_preferences url_launcher version xml]
- url_launcher 6.3.0 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launche
r_windows]                                                                                                                                                            - uuid 4.5.0 [crypto sprintf meta fixnum]
- wakelock_plus 1.2.8 [flutter flutter_web_plugins meta wakelock_plus_platform_interface win32 dbus package_info_plus web]

dev dependencies:
- flutter_lints 4.0.0 [lints]
- flutter_native_splash 2.4.1 [args flutter flutter_web_plugins html image meta path universal_io xml yaml ansicolor]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection
 leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]                                     - icons_launcher 2.1.7 [args image path universal_io yaml]
- package_rename 1.7.1 [args html logger yaml]

transitive dependencies:
- _flutterfire_internals 1.3.42 [collection firebase_core firebase_core_platform_interface flutter meta]
- algolia_client_core 1.24.1 [dio]
- algolia_client_insights 1.24.1 [algolia_client_core json_annotation collection]
- algolia_client_search 1.24.1 [algolia_client_core json_annotation collection]
- algolia_insights 1.0.1 [algolia_client_insights collection flutter hive logging meta path_provider rxdart uuid]
- algoliasearch 1.24.1 [algolia_client_core algolia_client_search algolia_client_insights json_annotation collection]
- ansicolor 2.0.3
- app_links_linux 1.0.3 [flutter app_links_platform_interface gtk]
- app_links_platform_interface 2.0.2 [flutter plugin_platform_interface]
- app_links_web 1.0.4 [flutter flutter_web_plugins app_links_platform_interface web]
- archive 3.6.1 [crypto path]
- args 2.5.0
- async 2.11.0 [collection meta]
- boolean_selector 2.1.1 [source_span string_scanner]
- cached_network_image_platform_interface 4.1.1 [flutter flutter_cache_manager]
- cached_network_image_web 1.3.1 [cached_network_image_platform_interface flutter flutter_cache_manager web]
- characters 1.3.0
- circle_flags 5.0.0 [flutter flutter_svg]
- clock 1.1.1
- cloud_firestore_platform_interface 6.4.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 4.3.0 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins]
- cloud_functions_platform_interface 5.5.35 [firebase_core flutter meta plugin_platform_interface]
- cloud_functions_web 4.10.0 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins]
- collection 1.18.0
- cross_file 0.3.4+2 [meta web]
- crypto 3.0.5 [typed_data]
- csslib 1.0.0 [source_span]
- dbus 0.7.10 [args ffi meta xml]
- device_info_plus 10.1.2 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta web win32 win32_registry]
- device_info_plus_platform_interface 7.0.1 [flutter meta plugin_platform_interface]
- diacritic 0.1.5
- dio 5.7.0 [async http_parser meta path dio_web_adapter]
- dio_web_adapter 2.0.0 [dio http_parser meta web]
- eventify 1.0.1
- fake_async 1.3.1 [clock collection]
- ffi 2.1.3
- file 7.0.0 [meta path]
- file_selector_linux 0.9.2+1 [cross_file file_selector_platform_interface flutter]
- file_selector_macos 0.9.4 [cross_file file_selector_platform_interface flutter]
- file_selector_platform_interface 2.6.2 [cross_file flutter http plugin_platform_interface]
- file_selector_windows 0.9.3+2 [cross_file file_selector_platform_interface flutter]
- firebase_analytics_platform_interface 4.2.3 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_analytics_web 0.5.10 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins]
- firebase_app_check_platform_interface 0.1.0+36 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_app_check_web 0.1.3 [_flutterfire_internals firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins web]
- firebase_auth_platform_interface 7.4.5 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 5.13.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser meta web]
- firebase_core_platform_interface 5.2.1 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.18.0 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_crashlytics_platform_interface 3.6.42 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_platform_interface 4.5.44 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 3.9.0 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins meta web]
- firebase_performance_platform_interface 0.1.4+42 [_flutterfire_internals firebase_core flutter plugin_platform_interface]
- firebase_performance_web 0.1.7 [_flutterfire_internals firebase_core firebase_core_web firebase_performance_platform_interface flutter flutter_web_plugins]
- firebase_storage_platform_interface 5.1.29 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_storage_web 3.10.0 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http meta 
web]                                                                                                                                                                  - fixnum 1.1.0
- flutter_cache_manager 3.4.1 [clock collection file flutter http path path_provider rxdart sqflite uuid]
- flutter_country_selector 1.0.12 [flutter flutter_localizations intl diacritic circle_flags phone_numbers_parser]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- flutter_plugin_android_lifecycle 2.0.22 [flutter]
- flutter_spinkit 5.2.1 [flutter]
- flutter_staggered_grid_view 0.7.0 [flutter]
- flutter_svg 2.0.10+1 [flutter http vector_graphics vector_graphics_codec vector_graphics_compiler]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- fluttertoast 8.2.8 [flutter flutter_web_plugins web]
- get 4.6.6 [flutter]
- gtk 2.1.0 [ffi flutter meta]
- hive 2.2.3 [meta crypto]
- html 0.15.4 [csslib source_span]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- image 4.2.0 [archive meta xml]
- image_cropper_for_web 6.0.2 [flutter flutter_web_plugins image_cropper_platform_interface web]
- image_cropper_platform_interface 7.0.0 [flutter plugin_platform_interface http]
- image_picker_android 0.8.12+13 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- image_picker_for_web 3.0.5 [flutter flutter_web_plugins image_picker_platform_interface mime web]
- image_picker_ios 0.8.12 [flutter image_picker_platform_interface]
- image_picker_linux 0.2.1+1 [file_selector_linux file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_macos 0.2.1+1 [file_selector_macos file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_platform_interface 2.10.0 [cross_file flutter http plugin_platform_interface]
- image_picker_windows 0.2.1+1 [file_selector_platform_interface file_selector_windows flutter image_picker_platform_interface]
- json_annotation 4.9.0 [meta]
- leak_tracker 10.0.5 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.5 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- lints 4.0.0
- logger 2.4.0
- logging 1.2.0
- matcher 0.12.16+1 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.11.1 [collection]
- meta 1.15.0
- mime 1.0.6
- nested 1.0.0 [flutter]
- octo_image 2.1.0 [flutter]
- os_detect 2.0.1
- package_info_plus 8.0.2 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface web win32 clock]
- package_info_plus_platform_interface 3.0.1 [flutter meta plugin_platform_interface]
- path_drawing 1.0.1 [vector_math meta path_parsing flutter]
- path_parsing 1.0.1 [vector_math meta]
- path_provider_android 2.2.10 [flutter path_provider_platform_interface]
- path_provider_foundation 2.4.0 [flutter path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface]
- path_provider_windows 2.3.0 [ffi flutter path path_provider_platform_interface]
- petitparser 6.0.2 [meta]
- phone_numbers_parser 9.0.0 [meta]
- platform 3.1.5
- plugin_platform_interface 2.1.8 [meta]
- rxdart 0.28.0
- share_plus_platform_interface 5.0.0 [cross_file flutter meta mime plugin_platform_interface path_provider uuid]
- shared_preferences 2.3.2 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_pre
ferences_web shared_preferences_windows]                                                                                                                              - shared_preferences_android 2.3.2 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.5.2 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.4.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.4.1 [flutter plugin_platform_interface]
- shared_preferences_web 2.4.2 [flutter flutter_web_plugins shared_preferences_platform_interface web]
- shared_preferences_windows 2.4.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- sky_engine 0.0.99
- sliver_tools 0.2.12 [flutter]
- source_span 1.10.0 [collection path term_glyph]
- sprintf 7.0.0
- sqflite 2.3.3+1 [flutter sqflite_common path]
- sqflite_common 2.5.4+3 [synchronized path meta]
- stack_trace 1.11.1 [path]
- stream_channel 2.1.2 [async]
- string_scanner 1.2.0 [source_span]
- synchronized 3.3.0+2
- term_glyph 1.2.1
- test_api 0.7.2 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- typed_data 1.3.2 [collection]
- universal_io 2.2.2 [collection meta typed_data]
- universal_platform 1.1.0
- url_launcher_android 6.3.10 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.3.1 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.2.0 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.2.0 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.3.2 [flutter plugin_platform_interface]
- url_launcher_web 2.3.3 [flutter flutter_web_plugins url_launcher_platform_interface web]
- url_launcher_windows 3.1.2 [flutter url_launcher_platform_interface]
- vector_graphics 1.1.11+1 [flutter http vector_graphics_codec]
- vector_graphics_codec 1.1.11+1
- vector_graphics_compiler 1.1.11+1 [args meta path_parsing xml vector_graphics_codec path]
- vector_math 2.1.4
- version 3.0.2
- video_player_android 2.7.3 [flutter video_player_platform_interface]
- video_player_avfoundation 2.6.1 [flutter video_player_platform_interface]
- video_player_platform_interface 6.2.2 [flutter plugin_platform_interface]
- video_player_web 2.3.2 [flutter flutter_web_plugins video_player_platform_interface web]
- vm_service 14.2.5
- wakelock_plus_platform_interface 1.2.1 [flutter plugin_platform_interface meta]
- web 1.0.0
- win32 5.5.4 [ffi]
- win32_registry 1.1.5 [ffi win32]
- xdg_directories 1.0.4 [meta path]
- xml 6.5.0 [collection meta petitparser]
- yaml 3.1.2 [collection source_span string_scanner]

Additional context and comments

No response

@OutdatedGuy OutdatedGuy added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Sep 17, 2024
@SelaseKay
Copy link
Contributor

New versions have been rolled out. Kindly try again with those and provide feedback.

@SelaseKay SelaseKay added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Sep 18, 2024
@OutdatedGuy
Copy link
Contributor Author

@SelaseKay still having the same issue using firebase_core: 3.5.0, firebase_messaging: 15.1.2 & firebase_auth: 5.3.0

@google-oss-bot google-oss-bot removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Sep 18, 2024
@SelaseKay SelaseKay added plugin: messaging platform: macos Issues / PRs which are specifically for MacOS. platform: ios Issues / PRs which are specifically for iOS. labels Sep 18, 2024
@antonderevyanko
Copy link

It seems, I have the same issue. iOS notifications worked properly with firebase_core: 3.3.0 and firebase_messaging: 15.0.4 versions. After update to firebase_core: 3.4.0 (and iOS Firebase/Core 11.0.0 respectively) pushes stopped to work.
On Android everything works correctly.

@OutdatedGuy
Copy link
Contributor Author

@SelaseKay looking at the error logs I had provided I think the problem is with the firebase_auth plugin rather than firebase_messaging. Can you confirm once and update the labels?

@GoldenSoju
Copy link

Xcode now shows me the error message Property 'auth' not found on object of type 'FIRAuth' in my NotificationService. I just updated to the newest versions.

@OutdatedGuy OutdatedGuy changed the title [firebase_messaging]: NotificationService extension not working since iOS SDK 11.0.0 [firebase_auth]: NotificationService extension not working since iOS SDK 11.0.0 Sep 24, 2024
@SerdarNur
Copy link

After upgrading firebase dependencies we have the same problem now in our flutter project.

@OutdatedGuy
Copy link
Contributor Author

@SelaseKay still having the same issue using firebase_core: 3.6.0, firebase_messaging: 15.1.3 & firebase_auth: 5.3.1 which are using Firebase iOS SDK 11.2.0

@russellwheatley
Copy link
Member

Hey @OutdatedGuy - I noticed that the notification extension helper has changed on iOS. See the documentation for iOS notification extension here

It seems you essentially should update the notification extension helper to something like this:

@interface NotificationService () <NSURLSessionDelegate>
@property(nonatomic) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property(nonatomic) UNMutableNotificationContent *bestAttemptContent;
@end

@implementation NotificationService

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    self.contentHandler = contentHandler;
    self.bestAttemptContent = [request.content mutableCopy];

    // Modify the notification content here as you wish
    self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [modified]",
    self.bestAttemptContent.title];

  // Call FIRMessaging extension helper API.
  [[FIRMessaging extensionHelper] populateNotificationContent:self.bestAttemptContent
                                            withContentHandler:contentHandler];

}

Could you let me know if this works for you? If so, I can update the documentation for Flutter on the Firebase website 🙏

@russellwheatley russellwheatley added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Sep 27, 2024
@OutdatedGuy
Copy link
Contributor Author

@russellwheatley, I tried with the updated didReceiveNotificationRequest functions and top imports but still having the issue.

The issue is in firebase_auth which is used in these functions application & scene maybe for Silent APN auth notification for Firebase Auth.

Error Logs

flutter build ipa

Archiving com.example.app...
Automatically signing iOS for device deployment using specified development team in Xcode project: xyz
Running pod install...                                              5.3s
Running Xcode build...                                                  
Xcode archive done.                                         71.9s
Failed to build iOS app
ARC Semantic Issue (Xcode): Receiver 'FIRAuth' for class message is a forward declaration
/users/project/ios/Image%20Notification/NotificationService.m:24:8


ARC Semantic Issue (Xcode): No known class method for selector 'auth'
/users/project/ios/Image%20Notification/NotificationService.m:24:16


ARC Semantic Issue (Xcode): No known instance method for selector 'canHandleURL:'
/users/project/ios/Image%20Notification/NotificationService.m:24:22


Semantic Issue (Xcode): Property 'auth' not found on object of type 'FIRAuth'
/users/project/ios/Image%20Notification/NotificationService.m:32:13


Encountered error while archiving for device.

My Updated file

//
//  NotificationService.m
//  Image Notification
//
//
//

#import "NotificationService.h"
#import "FirebaseMessaging.h"
#import "FirebaseAuth.h" // Add this line if you are using FirebaseAuth phone authentication
#import <UIKit/UIKit.h> // Add this line if you are using FirebaseAuth phone authentication

@interface NotificationService () <NSURLSessionDelegate>

@property(nonatomic) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property(nonatomic) UNMutableNotificationContent *bestAttemptContent;

@end

@implementation NotificationService

- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
  if ([[FIRAuth auth] canHandleURL:url]) {
    return YES;
  }
  return NO;
}

- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
  for (UIOpenURLContext *urlContext in URLContexts) {
    [FIRAuth.auth canHandleURL:urlContext.URL];
  }
}

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    self.contentHandler = contentHandler;
    self.bestAttemptContent = [request.content mutableCopy];

    // Modify the notification content here as you wish
    self.bestAttemptContent.title = [NSString stringWithFormat:@"%@ [modified]",
    self.bestAttemptContent.title];

    // Call FIRMessaging extension helper API.
    [[FIRMessaging extensionHelper] populateNotificationContent:self.bestAttemptContent
                                            withContentHandler:contentHandler];

}

- (void)serviceExtensionTimeWillExpire {
    // Called just before the extension will be terminated by the system.
    // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
    self.contentHandler(self.bestAttemptContent);
}

@end

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Sep 29, 2024
@OutdatedGuy
Copy link
Contributor Author

OutdatedGuy commented Oct 19, 2024

@russellwheatley I was testing some things out and replaced #import "FirebaseAuth.h" to #import <FirebaseAuth/FirebaseAuth.h> and got this issue:

Modules Issue (Xcode): Definition of 'FIRAuth' must be imported from module 'FirebaseAuth.Swift' before it is required

@OutdatedGuy
Copy link
Contributor Author

@russellwheatley finally made it work by replacing

#import "FirebaseMessaging.h"
#import "FirebaseAuth.h" // Add this line if you are using FirebaseAuth phone authentication

with just

#import "Firebase.h"

Do you know why this is happening? Does this have any repercussions like increase in app size?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Attention This issue needs maintainer attention. platform: ios Issues / PRs which are specifically for iOS. platform: macos Issues / PRs which are specifically for MacOS. plugin: auth type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants