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.5k stars 3.92k forks source link

🐛 [firebase_messaging] Notification Images setup problem iOS #4133

Closed aytunch closed 2 years ago

aytunch commented 3 years ago

Bug report

Describe the bug

In iOS, When trying to setup FCM(with image support) the app does not compile. The documentation steps result in errors.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a clean Flutter app and add FCM setup for iOS.
  2. Go to (Advanced, Optional) Allowing Notification Images and do the necessary steps.
  3. For the step named "Add target to the Podfile", copy paste the exact:
    target 'ImageNotification' do
    pod 'Firebase/Messaging'
    end
  4. Do the next 2 steps as written in the flutter fire docs
  5. Since there is no use_framewroks! in the docs, we get this error:
    
    [!] Unable to integrate the following embedded targets with their respective host targets (a host target is a "parent" target which embeds a "child" target like a framework or extension):

Expected behavior

FCM has Image capabilities as expected and the project compiles without error


Additional context

I tried both creating the Image Notification Service Extension as an Objective C file and a Swift file. Nothing changed Also I tried enabling the bitcode setting but still no luck.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B29 darwin-x64, locale en-TR) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [✓] Xcode - develop for iOS and macOS (Xcode 12.2) [!] Android Studio (version 4.1) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. [✓] VS Code (version 1.51.1) [✓] Connected device (1 available) ! Doctor found issues in 1 category. ```

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 2.10.4 Flutter SDK 1.22.4 bare_bones 1.0.0+1 dependencies: - auto_route 0.6.9 [flutter meta] - bloc 6.1.0 [meta] - camera 0.5.8+11 [flutter] - cloud_firestore 0.14.3 [flutter meta quiver firebase_core firebase_core_platform_interface cloud_firestore_platform_interface cloud_firestore_web] - cloud_functions 0.7.0+1 [meta flutter firebase_core firebase_core_platform_interface cloud_functions_platform_interface cloud_functions_web] - connectivity 2.0.1 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web] - cupertino_icons 1.0.0 - dartz 0.9.2 - firebase_auth 0.18.3 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter] - firebase_core 0.5.2 [firebase_core_platform_interface flutter quiver meta firebase_core_web] - firebase_messaging 7.0.3 [meta flutter firebase_core] - firebase_storage 5.0.1 [flutter firebase_core firebase_core_platform_interface firebase_storage_platform_interface quiver] - flushbar 1.10.4 [flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_bloc 6.1.0 [flutter bloc provider] - flutter_ffmpeg 0.3.0 [flutter] - flutter_localizations 0.0.0 [flutter intl characters collection meta path typed_data vector_math] - flutter_signin_button 1.1.0 [flutter font_awesome_flutter] - freezed 0.12.2 [analyzer build build_config meta source_gen freezed_annotation] - gallery_saver 2.0.1 [flutter path_provider http path] - get_it 5.0.1 [async meta] - google_sign_in 4.5.6 [google_sign_in_platform_interface flutter meta google_sign_in_web] - injectable 1.0.5 [get_it] - lamp 0.0.6 [flutter] - logger 0.9.4 - path 1.8.0-nullsafety.1 - path_provider 1.6.24 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - rxdart 0.24.1 - screen 0.0.5 [flutter] - sign_in_with_apple 2.5.4 [meta flutter] - uuid 2.2.2 [crypto convert] - video_player 1.0.0 [meta video_player_platform_interface video_player_web flutter] dev dependencies: - auto_route_generator 0.6.10 [build source_gen analyzer path build_runner auto_route] - bloc_test 7.1.0 [bloc test meta mockito] - build_runner 1.10.4 [args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style glob graphs http_multi_server io js logging meta mime path pedantic pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] - freezed_annotation 0.12.0 [collection json_annotation meta] - injectable_generator 1.0.6 [build source_gen path glob analyzer injectable collection] - json_serializable 3.5.0 [analyzer build build_config json_annotation meta path source_gen] - lint 1.3.0 dependency overrides: - analyzer 0.40.4 [_fe_analyzer_shared args charcode cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] transitive dependencies: - _fe_analyzer_shared 11.0.0 [meta] - args 1.6.0 - async 2.5.0-nullsafety.1 [collection] - boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner] - build 1.5.0 [analyzer async convert crypto logging meta path glob] - build_config 0.4.2 [checked_yaml json_annotation meta path pubspec_parse yaml] - build_daemon 2.1.4 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 1.4.3 [analyzer build crypto graphs logging meta path package_config pool pub_semver] - build_runner_core 6.0.3 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pedantic pool timing watcher yaml] - built_collection 4.3.2 [collection quiver] - built_value 7.1.0 [built_collection collection fixnum quiver] - characters 1.1.0-nullsafety.3 - charcode 1.2.0-nullsafety.1 - checked_yaml 1.0.2 [json_annotation source_span yaml] - cli_util 0.2.0 [path] - clock 1.1.0-nullsafety.1 - cloud_firestore_platform_interface 2.2.0 [flutter meta collection firebase_core plugin_platform_interface] - cloud_firestore_web 0.2.1 [flutter flutter_web_plugins http_parser meta firebase_core firebase_core_web cloud_firestore_platform_interface js] - cloud_functions_platform_interface 3.0.1 [flutter meta firebase_core plugin_platform_interface] - cloud_functions_web 3.0.1 [firebase_core cloud_functions_platform_interface flutter flutter_web_plugins firebase http_parser meta] - code_builder 3.5.0 [built_collection built_value collection matcher meta] - collection 1.15.0-nullsafety.3 - connectivity_for_web 0.3.1+4 [connectivity_platform_interface flutter_web_plugins flutter] - connectivity_macos 0.1.0+7 [flutter] - connectivity_platform_interface 1.0.6 [flutter meta plugin_platform_interface] - convert 2.1.1 [charcode typed_data] - coverage 0.14.1 [args logging package_config path source_maps stack_trace vm_service] - crypto 2.1.5 [collection convert typed_data] - dart_style 1.3.9 [analyzer args path source_span] - fake_async 1.2.0-nullsafety.1 [clock collection] - ffi 0.1.3 - file 5.2.1 [intl meta path] - firebase 7.3.2 [http http_parser js] - firebase_auth_platform_interface 2.1.3 [flutter meta firebase_core plugin_platform_interface] - firebase_auth_web 0.3.2 [flutter flutter_web_plugins meta http_parser intl firebase_core firebase_core_web firebase_auth_platform_interface js] - firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver] - firebase_core_web 0.2.1 [firebase_core_platform_interface flutter flutter_web_plugins meta js] - firebase_storage_platform_interface 1.0.1 [flutter meta collection firebase_core plugin_platform_interface] - fixnum 0.10.11 - flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math] - font_awesome_flutter 8.10.0 [flutter] - glob 1.2.0 [async collection node_io path pedantic string_scanner] - google_sign_in_platform_interface 1.1.2 [flutter meta quiver] - google_sign_in_web 0.9.2 [google_sign_in_platform_interface flutter flutter_web_plugins meta js] - graphs 0.2.0 - http 0.12.2 [http_parser path pedantic] - http_multi_server 2.2.0 [async] - http_parser 3.1.4 [charcode collection source_span string_scanner typed_data] - intl 0.16.1 [path] - io 0.3.4 [charcode meta path string_scanner] - js 0.6.3-nullsafety.1 - json_annotation 3.1.0 - logging 0.11.4 - matcher 0.12.10-nullsafety.1 [stack_trace] - meta 1.3.0-nullsafety.3 - mime 0.9.7 - mockito 4.1.3 [analyzer build code_builder collection dart_style matcher meta source_gen test_api] - nested 0.0.4 [flutter] - node_interop 1.1.1 [js] - node_io 1.1.1 [node_interop path] - node_preamble 1.4.12 - package_config 1.9.3 [path charcode] - path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 0.0.4+4 [flutter] - path_provider_platform_interface 1.0.3 [flutter meta platform plugin_platform_interface] - path_provider_windows 0.0.4+1 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.10.0-nullsafety.1 - platform 2.2.1 - plugin_platform_interface 1.0.3 [meta] - pool 1.5.0-nullsafety.1 [async stack_trace] - process 3.0.13 [file intl meta path platform] - provider 4.3.2+2 [flutter nested collection] - pub_semver 1.4.4 [collection] - pubspec_parse 0.1.5 [checked_yaml json_annotation pub_semver yaml] - quiver 2.1.3 [matcher meta] - shelf 0.7.9 [async collection http_parser path stack_trace stream_channel] - shelf_packages_handler 2.0.0 [path shelf shelf_static] - shelf_static 0.2.8 [convert http_parser mime path shelf] - shelf_web_socket 0.2.3 [shelf web_socket_channel stream_channel] - sky_engine 0.0.99 - source_gen 0.9.7+1 [analyzer async build dart_style glob meta path pedantic source_span] - source_map_stack_trace 2.1.0-nullsafety.2 [path stack_trace source_maps] - source_maps 0.10.10-nullsafety.1 [source_span] - source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph] - stack_trace 1.10.0-nullsafety.1 [path] - stream_channel 2.1.0-nullsafety.1 [async] - stream_transform 1.2.0 - string_scanner 1.1.0-nullsafety.1 [charcode source_span] - term_glyph 1.2.0-nullsafety.1 - test 1.16.0-nullsafety.5 [analyzer async boolean_selector coverage http http_multi_server io js node_preamble package_config path pedantic pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core] - test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - test_core 0.3.12-nullsafety.5 [analyzer async args boolean_selector collection coverage glob io meta package_config path pedantic pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api] - timing 0.1.1+2 [json_annotation] - typed_data 1.3.0-nullsafety.3 [collection] - vector_math 2.1.0-nullsafety.3 - video_player_platform_interface 2.2.0 [flutter meta] - video_player_web 0.1.4 [flutter flutter_web_plugins meta video_player_platform_interface] - vm_service 5.2.0 [meta] - watcher 0.9.7+15 [async path pedantic] - web_socket_channel 1.1.0 [async crypto stream_channel] - webkit_inspection_protocol 0.7.3 [logging] - win32 1.7.3 [ffi] - xdg_directories 0.1.2 [meta path process] - yaml 2.2.1 [charcode collection string_scanner source_span] ```

markusaksli-nc commented 3 years ago

That guide is meant for the dev version of the plugin but I can confirm that I see the same with Xcode 12.2, flutter master 1.24.0-8.0.pre.268 and firebase_messaging: ^8.0.0-dev.8.

flutter doctor -v ``` [✓] Flutter (Channel master, 1.24.0-8.0.pre.268, on Mac OS X 10.15.7 19H2 darwin-x64, locale en-GB) • Flutter version 1.24.0-8.0.pre.268 at /Users/markus/development/flutter_master • Framework revision e803b13f01 (6 hours ago), 2020-11-16 22:55:59 -0800 • Engine revision f0e80100f7 • Dart version 2.12.0 (build 2.12.0-49.0.dev) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1) • Android SDK at /Users/markus/Library/Android/sdk • Platform android-30, build-tools 30.0.1 • Java binary at: /Users/markus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.6858069/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.2, Build version 12B45b • CocoaPods version 1.10.0 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.1) • Android Studio at /Users/markus/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.6858069/Android Studio.app/Contents • Flutter plugin can be installed from: � https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: � https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) [✓] Connected device (3 available) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.7 19H2 darwin-x64 • Web Server (web) • web-server • web-javascript • Flutter Tools • Chrome (web) • chrome • web-javascript • Google Chrome 86.0.4240.198 ! Error: Nevercode’s iPhone has recently restarted. Xcode will continue when Nevercode’s iPhone is unlocked. (code -14) • No issues found! ```
DFelten commented 3 years ago

Compiling works when adding this and setting bitcode to no for the ImageNotification target:

target 'ImageNotification' do
  use_frameworks!

  pod 'Firebase/Messaging'
end

image

aytunch commented 3 years ago

@DFelten compiling works when use_frameworks is added however it crashes once it compiles.

VictorUvarov commented 3 years ago

Compiling works when adding this and setting bitcode to no for the ImageNotification target:

target 'ImageNotification' do
  use_frameworks!

  pod 'Firebase/Messaging'
end

image

Disabling bit_code and use_frameworks! did the trick! Thanks. Is this only needed for projects that have swift support?

boucher commented 3 years ago

Compiling works when adding this and setting bitcode to no for the ImageNotification target:

target 'ImageNotification' do
  use_frameworks!

  pod 'Firebase/Messaging'
end

image

Disabling bit_code and use_frameworks! did the trick! Thanks. Is this only needed for projects that have swift support?

Doing this will get everything to build, but it doesn't seem to actually run the notification service extension. Looking through the console, there's an unhelpful error that just says "Couldn't load extension" and another that then notes "Notification request was marked as mutable but no service extension is available".

I haven't figured it out yet, but looking elsewhere it seems like it may be related to limits on size/memory that could cause the extension to fail to load.

Yahhi commented 3 years ago

Had the same problem. Updated all libraries (at this moment versions are firebase_core: ^0.7.0 firebase_messaging: "^8.0.0-dev.13" firebase_crashlytics: ^0.4.0 I did everything including use_frameworks! and "enable bitcode", but with no luck. The build was successful, but without images in notifications. As for me, this thread solved the problem https://stackoverflow.com/questions/39663903/ios10-unnotificationserviceextension-not-called Especially setting Deployment target the same as in Runner in XCode (there is an answer with image and steps the thread)

markusaksli-nc commented 3 years ago

I was able to follow the steps of the guide with the latest versions of the plugins (firebase_core: ^0.7.0 and firebase_messaging: ^8.0.0-dev.14) and build a dev IPA with them even using bitcode. The image notifications work just fine.

However the documentation does not mention adding use_frameworks! to the podfile.

To those of you who got the app to compile but did not receive an image I would remind you of https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification where it is specified that

Contains the URL of an image that is going to be downloaded on the device and displayed in a notification. JPEG, PNG, BMP have full support across platforms. Animated GIF and video only work on iOS. WebP and HEIF have varying levels of support across platforms and platform versions. Android has 1MB image size limit.

VictorUvarov commented 3 years ago

Especially setting Deployment target the same as in Runner in XCode (there is an answer with image and steps the thread)

Setting the deployment to the same version solved this for me as well. My main Runner was ios 10.0, but the extension was automatically set to ios 14.4

inf0rmatix-old commented 3 years ago

Pushing the thread since use_frameworks!

is still missing from the documentation which cost me some time till I found this thread.

Thank you guys!

fullflash commented 3 years ago

unable to build with lates libraries.

`

.........../ios/build/Debug-iphoneos/PromisesObjC/FBLPromises.framework/FBLPromises' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '..../ios/build/Debug-iphoneos/PromisesObjC/FBLPromises.framework/FBLPromises' for architecture arm64 `

tryed with bitcode on and off use_frameworks!

on xcode 12.4 no bitcode option for target ImageExtension

mminhlequang commented 3 years ago
Screen Shot 2021-04-08 at 15 54 52

I just add "use_frameworks!" and it work :))

diegoveloper commented 3 years ago

Hey people, for those who managed to configure it, how do you send the image in the payload? Do you have some example of the notification that you send?.

mminhlequang commented 3 years ago

Hey people, for those who managed to configure it, how do you send the image in the payload? Do you have some example of the notification that you send?.

Hi. This example for send message firebase with endpoint Content-Type: application/json Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA

{ "message":{ "token" : "...", "notification" : { "body" : "This is an FCM notification that displays an image.!", "title" : "FCM Notification", }, "apns": { "payload": { "aps": { "mutable-content": 1 } }, "fcm_options": { "image": "url-to-image" } } } }

diegoveloper commented 3 years ago

hi @lqmminh thanks for the answer, I'm trying using CURL for sending the push but it doesn't work for me .

I tried different ways but none of those worked :(. I receive the push notification but I don't see the image.

DATA='{"mutable-content": true, "apns": { "payload": { "aps": { "mutable-content": 1 } }, "fcm_options": { "image": "https://i.ytimg.com/vi/jn6m33x05Fw/maxresdefault.jpg" } }, "notification": {"image": "https://i.ytimg.com/vi/jn6m33x05Fw/maxresdefault.jpg", "body": "Take a look","title": "Hey, Did you receive this push?"}, "priority": "high", "data": {"click_action": "FLUTTER_NOTIFICATION_CLICK"}, "to": "token_id"}'
curl https://fcm.googleapis.com/fcm/send -H "Content-Type:application/json" -X POST -d "$DATA" -H "Authorization: key=MYKEY.

I'm using firebase_messaging: 8.0.0-dev.15

mminhlequang commented 3 years ago

hi @lqmminh thanks for the answer, I'm trying using CURL for sending the push but it doesn't work for me .

I tried different ways but none of those worked :(. I receive the push notification but I don't see the image.

DATA='{"mutable-content": true, "apns": { "payload": { "aps": { "mutable-content": 1 } }, "fcm_options": { "image": "https://i.ytimg.com/vi/jn6m33x05Fw/maxresdefault.jpg" } }, "notification": {"image": "https://i.ytimg.com/vi/jn6m33x05Fw/maxresdefault.jpg", "body": "Take a look","title": "Hey, Did you receive this push?"}, "priority": "high", "data": {"click_action": "FLUTTER_NOTIFICATION_CLICK"}, "to": "token_id"}'
curl https://fcm.googleapis.com/fcm/send -H "Content-Type:application/json" -X POST -d "$DATA" -H "Authorization: key=MYKEY.

I'm using firebase_messaging: 8.0.0-dev.15

This message send success?

diegoveloper commented 3 years ago

hi @lqmminh thanks for the answer, I'm trying using CURL for sending the push but it doesn't work for me . I tried different ways but none of those worked :(. I receive the push notification but I don't see the image.

DATA='{"mutable-content": true, "apns": { "payload": { "aps": { "mutable-content": 1 } }, "fcm_options": { "image": "https://i.ytimg.com/vi/jn6m33x05Fw/maxresdefault.jpg" } }, "notification": {"image": "https://i.ytimg.com/vi/jn6m33x05Fw/maxresdefault.jpg", "body": "Take a look","title": "Hey, Did you receive this push?"}, "priority": "high", "data": {"click_action": "FLUTTER_NOTIFICATION_CLICK"}, "to": "token_id"}'
curl https://fcm.googleapis.com/fcm/send -H "Content-Type:application/json" -X POST -d "$DATA" -H "Authorization: key=MYKEY.

I'm using firebase_messaging: 8.0.0-dev.15

This message send success?

Yes

markusaksli-nc commented 3 years ago

@diegoveloper The image can just be in the notification object and it should work on both Android and iOS. Since you are sending the curl request to the deprecated API it should look something like this:

        {
            "to": token,
            "notification": {
                "title": "Title",
                "body": "Body",
                "image": "https://i.ibb.co/SPYWphH/37d.jpg"
            }
        }

However I recommend you take a look at https://github.com/FirebaseExtended/flutterfire/issues/4611#issuecomment-757917877 for an example of how to use the recommended FCM v1 HTTP API

diegoveloper commented 3 years ago

@markusaksli-nc I tried with the json you posted but I got the same results, I get the notification without image :/.

VictorUvarov commented 3 years ago

If you are using firebase-node-sdk

import * as admin from "firebase-admin";

const message: admin.messaging.Message = {
      token,
      notification: {
        title: "Title",
        body: "Body"
        imageUrl: "https://picsum.photos/200",
      },
      apns: {
        payload: {
          aps: {
            mutableContent: true,
          },
        },
      },
    };

admin.messaging().send(message);
diegoveloper commented 3 years ago

@diegoveloper The image can just be in the notification object and it should work on both Android and iOS. Since you are sending the curl request to the deprecated API it should look something like this:

        {
            "to": token,
            "notification": {
                "title": "Title",
                "body": "Body",
                "image": "https://i.ibb.co/SPYWphH/37d.jpg"
            }
        }

However I recommend you take a look at #4611 (comment) for an example of how to use the recommended FCM v1 HTTP API

it worked for Android, but not for iOS , do you know if the deprecated API is compatible with rich notifications in iOS?

sullenel commented 3 years ago

@diegoveloper Setting the "Destination" in Build phases -> Embed app extensions to "Plugins" fixed it for me a while ago.

Screen Shot 2021-04-15 at 11.13.07.png

markusaksli-nc commented 3 years ago

@diegoveloper The image I linked worked on both Android and iOS for me on both the deprecated API and v1. When you use the image property keep this in mind

Contains the URL of an image that is going to be downloaded on the device and displayed in a notification. JPEG, PNG, BMP have full support across platforms. Animated GIF and video only work on iOS. WebP and HEIF have varying levels of support across platforms and platform versions. Android has 1MB image size limit. Quota usage and implications/costs for hosting image on Firebase Storage: https://firebase.google.com/pricing

diegoveloper commented 3 years ago

@diegoveloper Setting the "Destination" in Build phases -> Embed app extensions to "Plugins" fixed it for me a while ago.

Screen Shot 2021-04-15 at 11.13.07.png @sullenel

It was already selected.

@diegoveloper The image I linked worked on both Android and iOS for me on both the deprecated API and v1. When you use the image property keep this in mind

Contains the URL of an image that is going to be downloaded on the device and displayed in a notification. JPEG, PNG, BMP have full support across platforms. Animated GIF and video only work on iOS. WebP and HEIF have varying levels of support across platforms and platform versions. Android has 1MB image size limit. Quota usage and implications/costs for hosting image on Firebase Storage: https://firebase.google.com/pricing @markusaksli-nc

I didn't have luck with that :/

These are my configs following this page https://firebase.flutter.dev/docs/messaging/apple-integration/#advanced-optional-allowing-notification-images:

Screen Shot 2021-04-15 at 9 51 27 AM

Screen Shot 2021-04-15 at 9 52 11 AM

Screen Shot 2021-04-15 at 9 54 16 AM

And I had to add this on my AppDelegate.swift, because I had some issues with FirebaseAuth.

Screen Shot 2021-04-15 at 9 52 43 AM

Any help?

The push is sent but without image.

ashish12s3 commented 3 years ago

I tried all suggestions but didn’t work for me, I'm using xcode 12.4 with m1 chip. below error log

Undefined symbols for architecture arm64: "_OBJCCLASS$_FlutterStandardTypedData", referenced from: objc-class-ref in firebase_remote_config(FLTFirebaseRemoteConfigPlugin.o) "_OBJCCLASS$_FlutterEventChannel", referenced from: objc-class-ref in cloud_firestore(FLTFirebaseFirestorePlugin.o) objc-class-ref in firebase_auth(FLTFirebaseAuthPlugin.o) "_FlutterMethodNotImplemented", referenced from: -[FLTFirebaseFirestorePlugin handleMethodCall:result:] in cloud_firestore(FLTFirebaseFirestorePlugin.o) -[FLTFirebaseAnalyticsPlugin handleMethodCall:result:] in firebase_analytics(FLTFirebaseAnalyticsPlugin.o) -[FLTFirebaseAuthPlugin handleMethodCall:result:] in firebase_auth(FLTFirebaseAuthPlugin.o) -[FLTFirebaseCorePlugin handleMethodCall:result:] in firebase_core(FLTFirebaseCorePlugin.o) -[FLTFirebaseCrashlyticsPlugin handleMethodCall:result:] in firebase_crashlytics(FLTFirebaseCrashlyticsPlugin.o) -[FLTFirebaseMessagingPlugin handleMethodCall:result:] in firebase_messaging(FLTFirebaseMessagingPlugin.o) -[FLTFirebaseRemoteConfigPlugin handleMethodCall:result:] in firebase_remote_config(FLTFirebaseRemoteConfigPlugin.o) ... "_FlutterEndOfEventStream", referenced from: ___63-[FLTTransactionStreamHandler onListenWithArguments:eventSink:]_block_invoke.318 in cloud_firestore(FLTTransactionStreamHandler.o) "_OBJCMETACLASS$_FlutterStandardWriter", referenced from: _OBJCMETACLASS$_FLTFirebaseFirestoreWriter in cloud_firestore(FLTFirebaseFirestoreWriter.o) "_OBJCMETACLASS$_FlutterStandardReaderWriter", referenced from: _OBJCMETACLASS$_FLTFirebaseFirestoreReaderWriter in cloud_firestore(FLTFirebaseFirestoreUtils.o) "_OBJCCLASS$_FlutterStandardReaderWriter", referenced from: _OBJCCLASS$_FLTFirebaseFirestoreReaderWriter in cloud_firestore(FLTFirebaseFirestoreUtils.o) "_OBJCCLASS$_FlutterStandardWriter", referenced from: _OBJCCLASS$_FLTFirebaseFirestoreWriter in cloud_firestore(FLTFirebaseFirestoreWriter.o) "_OBJCMETACLASS$_FlutterStandardReader", referenced from: _OBJCMETACLASS$_FLTFirebaseFirestoreReader in cloud_firestore(FLTFirebaseFirestoreReader.o) "_OBJCCLASS$_FlutterError", referenced from: objc-class-ref in cloud_firestore(FLTQuerySnapshotStreamHandler.o) objc-class-ref in firebase_core(FLTFirebasePlugin.o) "_OBJCCLASS$_FlutterMethodChannel", referenced from: objc-class-ref in cloud_firestore(FLTFirebaseFirestorePlugin.o) objc-class-ref in firebase_analytics(FLTFirebaseAnalyticsPlugin.o) objc-class-ref in firebase_auth(FLTFirebaseAuthPlugin.o) objc-class-ref in firebase_core(FLTFirebaseCorePlugin.o) objc-class-ref in firebase_crashlytics(FLTFirebaseCrashlyticsPlugin.o) objc-class-ref in firebase_messaging(FLTFirebaseMessagingPlugin.o) objc-class-ref in firebase_remote_config(FLTFirebaseRemoteConfigPlugin.o) ... "_OBJCCLASS$_FlutterStandardMethodCodec", referenced from: objc-class-ref in cloud_firestore(FLTFirebaseFirestorePlugin.o) "_OBJCCLASS$_FlutterStandardReader", referenced from: _OBJCCLASS$_FLTFirebaseFirestoreReader in cloud_firestore(FLTFirebaseFirestoreReader.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

bhanuka96 commented 3 years ago

Still, open this bug? we are waiting since 2020-Nov

sm2017 commented 2 years ago

Is Allowing Notification Images works at all? I exactly follow guide but the image is not shown

shahmirzali49 commented 2 years ago

any progress ?

Flucadetena commented 2 years ago

Please solve this problem and add the support for swift. Notifications are supper important, and without images they are.... sad :_(

fgadea commented 2 years ago

This stack-overflow https://stackoverflow.com/questions/64901180/running-cocoapods-on-apple-silicon-m1, it solves the problem for now on mac M1.

Install ffi sudo arch -x86_64 gem install ffi Re-install dependencies arch -x86_64 pod install

BoshiLee commented 2 years ago

Compiling works when adding this and setting bitcode to no for the ImageNotification target:

target 'ImageNotification' do
  use_frameworks!

  pod 'Firebase/Messaging'
end

image

Disabling bit_code and use_frameworks! did the trick! Thanks. Is this only needed for projects that have swift support?

Pod install is fine, but flutter run failed after did these steps.

BoshiLee commented 2 years ago

Compiling works when adding this and setting bitcode to no for the ImageNotification target:

target 'ImageNotification' do
  use_frameworks!

  pod 'Firebase/Messaging'
end

image

Disabling bit_code and use_frameworks! did the trick! Thanks. Is this only needed for projects that have swift support?

Pod install is fine, but flutter run failed after did these steps.

found solution for my case. Please follow steps above and check this: check bundle id is same as parent, if you have multiple environments. if your bundle id with parent in dev is com.company.productname.dev the target should be com.company.productname.dev.imagenotification. Screenshot 2021-09-07 at 12 25 58

AndrewSheetMetal commented 2 years ago

Setting the Configuration to "none" in Runner->Info fixed it for me. See: https://github.com/OneSignal/OneSignal-Flutter-SDK/issues/389#issuecomment-841639524

josedavidrp commented 2 years ago

Does anyone got it to work? I tried to follow all steps from here a couple of times and no luck.

EDIT 2: If you use that tutorial, remember to check that the iOS target version of the extension matches the app target version.

EDIT 1: I tried a non-flutter tutorial from medium and I got it to work. The only problem im having is with firebaseMessaging.getInitialMessage but I think is not linked to this. Tutorial: https://medium.com/macoclock/rich-push-notifications-in-ios-78b688f15520

This is the example code for it to work, it doesn't even need "apns" or "mutable-content" tags, just to link the image twice one as "image" in notification and other as "image_url" on root, dont ask me why, I just know that it works for me: { "notification": { "title": "title", "body": "body...", "image":"https:image" }, "data": { "keyname": "any value", "image_url":"https:image" }, "to" : "tokenofdevice" }

keshavbhusal1 commented 2 years ago

Step 1:

Add “use_framework!” In ImageNotifcation

target 'ImageNotification' do use_frameworks!

pod 'Firebase/Messaging' end

Step 2:

Add pod 'GoogleUtilities' in both target like below:

platform :ios, '11.0'

ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', { 'Debug' => :debug, 'Profile' => :release, 'Release' => :release, }

def flutter_root generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), FILE) unless File.exist?(generated_xcode_build_settings_path) raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" end

File.foreach(generated_xcode_build_settings_path) do |line| matches = line.match(/FLUTTER_ROOT\=(.*)/) return matches[1].strip if matches end raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do use_frameworks! use_modular_headers!

flutter_install_all_ios_pods File.dirname(File.realpath(FILE))

pod 'GoogleUtilities'

end

post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) end end

target 'ImageNotification' do use_frameworks! pod 'Firebase/Messaging'

pod 'GoogleUtilities'

end

russellwheatley commented 2 years ago

As mentioned above, there should be a use_frameworks! flag under the target. The documentation PR has now been merged here & documentation update will follow in due course. Thanks.

dragouf commented 2 years ago

I fixed the issue by using use_frameworks! but I have another problem.

Now I have multiple targets with differents identifier I'm unable to sign the application with my ad-hoc provisioning profile since it target only a single identifier.

Does anyone know how to solve this problem ?

priyesh-bit commented 2 years ago

If anyone still facing same issue then check below

after adding a NotificationServiceExtension please Check your deployment target on Service Extension.

by default the Extension deployment target is set to iOS 13.1 ( depending on your sdk version ), so you need a device with same iOS version OR you have to choose a lower value to match your device iOS

customized

Ref & Credit