plus_plugins
plus_plugins copied to clipboard
[Bug]: Sharing Images on iOS does not work for WhatsApp, Gmail and others
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.
-
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
-
With Email - I do not see the subject but get the text as the subject.
-
With WhatsApp I get the Text but not the subject of the image
-
With Airdrop I get a message ... cannot receive all the messages at the same time 5)Instagram I get a something went wrong
-
Messanger I get the image but no text or subject
-
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
- [X] I Google'd a solution and I couldn't find it
- [X] I searched on StackOverflow for a solution and I couldn't find it
- [X] I read the README.md file of the plugin
- [X] I'm using the latest version of the plugin
- [X] All dependencies are up to date with
flutter pub upgrade
- [X] I did a
flutter clean
- [X] I tried running the example project
Same here. I can't send images with text with ios. Works on android but on IOS doesn't.
I'm having the same issue. Any solutions or workarounds besides having to choose between text and files?
any updates?
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)]); }
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.
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.
Is there any fix for this? Currently facing this on Android and iOS.
i am getting the same issue. Is there any fix for sending both image and text together???
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',
);
Im facing the same problem, I can't share both image and text in the same time on WhatsApp ( Android ) . any solutions ?
facing same issue here , i just can send image only or text only cant do both together
Any solution ? @mustafa-707 @Djihanegh
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.