fluttercommunity / plus_plugins

Flutter Community Plus Plugins
BSD 3-Clause "New" or "Revised" License
1.55k stars 937 forks source link

[Bug]: Sharing Images on iOS does not work for WhatsApp, Gmail and others #1689

Closed ryanheitner closed 5 months ago

ryanheitner commented 1 year ago

Platform

iOS 16

Plugin

share_plus

Version

6.3.2

Flutter SDK

3.7.5

Steps to reproduce

Sharing with Android seems fine but on iPhone we get issues.

1) Before choosing the app to share with I see a message next to the image of Plain Text and 1 Document, rather than the subject or Text

2) With Email - I do not see the subject but get the text as the subject. 3) With WhatsApp I get the Text but not the subject of the image 4) With Airdrop I get a message ... cannot receive all the messages at the same time 5)Instagram I get a something went wrong 6) Messanger I get the image but no text or subject 7) Slack I get the text but no image

Telegram I get the text and the image.

Code Sample

final File cachedFile = await DefaultCacheManager()
        .getSingleFile(productDetailsEntity!.productMainImage);   
final tempDirPath = (await getTemporaryDirectory()).path;
final file = await File('$tempDirPath/image.png').create();
await file.writeAsBytes(cachedFile.readAsBytesSync());
                   Share.shareFiles(
                      [file.path],
                      mimeTypes: ['image/png'],
                      text:"My Text",
                      subject:"My Subject",
                    );

### Logs

```shell
na

Flutter Doctor

[✓] Flutter (Channel stable, 3.7.7, on macOS 13.2.1 22D68 darwin-arm64, locale en-IL)
    • Flutter version 3.7.7 on channel stable at /opt/homebrew/Caskroom/flutter/3.7.7/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2ad6cd72c0 (6 weeks ago), 2023-03-08 09:41:59 -0800
    • Engine revision 1837b5be5f
    • Dart version 2.19.4
    • DevTools version 2.20.1

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/ryanheitner/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.12.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/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 11.0.15+0-b2043.56-8887301)

[✓] Connected device (5 available)
    • LM F100 (mobile)           • LMF100EMWb9402b8a                    • android-arm64  • Android 12 (API 31)
    • Ryan’s iPhone (mobile)     • 00008101-00024C2C36B8001E            • ios            • iOS 16.3.1 20D67
    • iPhone 14 Pro Max (mobile) • F1084377-AB3D-4ACB-AFE6-09F28A786E3D • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 13.2.1 22D68 darwin-arm64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 112.0.5615.49

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

Checklist before submitting a bug

EtcGonza commented 1 year ago

Same here. I can't send images with text with ios. Works on android but on IOS doesn't.

thassio-vinicius commented 1 year ago

I'm having the same issue. Any solutions or workarounds besides having to choose between text and files?

MirzaIkhsan commented 1 year ago

any updates?

CatrielCaruso commented 1 year ago

Hi! Sharing images and text same time on IOS does not work for whatsApp. But you can sharing only one, image or text. I suggestion a solutions: if (Platform.isAndroid) { Share.shareXFiles([XFile(file.path)], text: 'text-example'); } else if (Platform.isIOS) { Share.shareXFiles([XFile(file.path)]); }

mixaza commented 1 year ago

Hi! Sharing images and text same time on IOS does not work for whatsApp. But you can sharing only one, image or text. I suggestion a solutions: if (Platform.isAndroid) { Share.shareXFiles([XFile(file.path)], text: 'text-example'); } else if (Platform.isIOS) { Share.shareXFiles([XFile(file.path)]); }

This works for WhatsApp and Instagram.

immex-tech commented 1 year ago

Would really like to have a fix for this issue on iOS. on iOS, sharing image(s)+ text works great for Twitter though. Not for WhatsApp.

yasht01 commented 10 months ago

Is there any fix for this? Currently facing this on Android and iOS.

rsys-harsh-saini commented 9 months ago

i am getting the same issue. Is there any fix for sending both image and text together???

bahag-chandrana commented 8 months ago

Additionally In iOS, when saving the file to the folder it saves the text as an additional text file. I am not sure if this is the expected behaviour. At least its not documented. This can be easily reproduced in the example app from the share_plus package by changing the example as shown below.

https://github.com/fluttercommunity/plus_plugins/blob/5e5c9db8d640f80ae170f3738489a900328eda75/packages/share_plus/share_plus/example/lib/main.dart#L243-L252

final shareResult = await Share.shareXFiles(
      [
        XFile.fromData(
          buffer.asUint8List(data.offsetInBytes, data.lengthInBytes),
          name: 'flutter_logo.png',
          mimeType: 'image/png',
        ),
      ],
      sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
      text: 'Share XFile from Assets',
    );

Simulator Screen Recording - iPhone 15 Pro Max - 2024-01-04 at 17 13 59

Djihanegh commented 8 months ago

Im facing the same problem, I can't share both image and text in the same time on WhatsApp ( Android ) . any solutions ?

mustafa-707 commented 7 months ago

facing same issue here , i just can send image only or text only cant do both together

vishweshsoni commented 5 months ago

Any solution ? @mustafa-707 @Djihanegh

miquelbeltran commented 5 months ago

Hi all, the share_plus plugin uses the native activityViewController method to share media with other apps.

The problem is that the plugin cannot avoid the limits either set by Apple or by the 3rd party apps developers.

For example, the inability to set the subject line on Outlook for iOS is also being reported by those who implement iOS apps using swift directly, e.g. here: https://stackoverflow.com/q/33894713 and they end up doing "hacks" like adding a lot of empty space and similar. Or for example, Whatsapp explicitly forbidding sharing text and image at the same time: https://stackoverflow.com/a/37224091

Moving forward, I'd recommend you to search for "activityViewController" + the name of the app you have problems with on StackOverflow, and see what they discuss there.