[@capacitor/share] Android: sharing several images with text to WhatsApp only sends the text (intent type forced to */*)
Maintainer thường phản hồi trong vòng 29 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Start at the SharePlugin.shareFiles entry point and inspect how MIME types and ACTION_SEND_MULTIPLE intents are built. Reproduce the issue with several JPEG URIs and text, then verify that WhatsApp receives every image and the text while mixed or unknown types retain the documented fallback behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Report
Plugin(s)
@capacitor/share 8.0.2
Capacitor Version
Latest Dependencies:
@capacitor/cli: 8.5.2
@capacitor/core: 8.5.2
@capacitor/android: 8.5.2
@capacitor/ios: 8.5.2
Installed Dependencies:
@capacitor/ios: not installed
@capacitor/cli: 8.5.2
@capacitor/core: 8.5.2
@capacitor/android: 8.5.2
Platform(s)
Android
Current Behavior
Sharing several image files together with a text to WhatsApp only delivers the text: WhatsApp drops all the images. Sharing a single image with the same text works.
In SharePlugin.shareFiles, the intent type is forced to */* as soon as more than one file is shared, even when every file has a known MIME type:
String type = getMimeType(file);
if (type == null || filesList.size() > 1) {
type = "*/*";
}
intent.setType(type);
With three JPEG files, the ACTION_SEND_MULTIPLE intent is sent as */*, and WhatsApp treats it as a text-only share.
We confirmed it on a physical Android phone. Our logs showed the three files written to the cache and passed to Share.share, the plugin resolving with activityType: com.whatsapp, and still only the text reaching the conversation.
Expected Behavior
The intent should carry the common MIME type of the shared files, as Chrome's Web Share does: image/jpeg when all files are JPEG, image/* when they are mixed image types, and */* only when the types differ or are unknown. WhatsApp then receives all the images with the text.
Code Reproduction
import { Directory, Filesystem } from '@capacitor/filesystem'
import { Share } from '@capacitor/share'
// three small JPEGs written to the cache
const uris = []
for (const name of ['a.jpg', 'b.jpg', 'c.jpg']) {
const { uri } = await Filesystem.writeFile({ path: `share/${name}`, data: JPEG_BASE64, directory: Directory.Cache, recursive: true })
uris.push(uri)
}
await Share.share({ text: 'Three photos', files: uris })
// choose WhatsApp → only "Three photos" is sent
// with files: [uris[0]] → the photo and the text are sent
Other Technical Details
The following change fixes it for us. We apply it with patch-package, and three images plus the text now reach WhatsApp:
- String type = getMimeType(file);
- if (type == null || filesList.size() > 1) {
- type = "*/*";
- }
- intent.setType(type);
+ String type = getMimeType(file);
+ if (type == null) {
+ sharedType = "*/*";
+ } else if (sharedType == null) {
+ sharedType = type;
+ } else if (!sharedType.equals(type)) {
+ boolean bothImages = sharedType.startsWith("image/") && type.startsWith("image/");
+ sharedType = bothImages ? "image/*" : "*/*";
+ }
+ intent.setType(sharedType);
(sharedType is a String declared as null before the loop.)
We also set a ClipData covering every URI for ACTION_SEND_MULTIPLE, since the plugin currently only does it for a single file. That was not enough on its own: the MIME type was the deciding factor.
if (fileUris.size() > 1) {
ClipData clipData = ClipData.newRawUri("", fileUris.get(0));
for (int i = 1; i < fileUris.size(); i++) {
clipData.addItem(new ClipData.Item(fileUris.get(i)));
}
intent.setClipData(clipData);
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, fileUris);
}
Related: #2474 (unknown extensions also fall back to */*, which WhatsApp likewise discards).
- Ngôn ngữ chính
- Java
- Star
- 688
- Fork
- 692
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ionic-team/capacitor-plugins
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ionic-team/capacitor-plugins#2616 ·
Maintainer thường phản hồi trong vòng 29 ngày
-
[@capacitor/app] iOS: 'Expression implicitly coerced from String? to Any' warning in getAppLanguageĐang mởtriage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
ionic-team/capacitor-plugins#2604 ·
Maintainer thường phản hồi trong vòng 29 ngày
-
platform: ios
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
ionic-team/capacitor-plugins#2624 ·
Maintainer thường phản hồi trong vòng 29 ngày
-
bug(network): Android networkStatusChange re-queries the active network inside callbacks and fires on every capability changeCó thể đã có người làm @kcjonson đã nhận 10 ngày trước. Đang mởplatform: android
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 25/100
ionic-team/capacitor-plugins#2621 ·
Maintainer thường phản hồi trong vòng 29 ngày
-
bug(network): iOS getStatus() returns the last reachability callback value instead of reading current flagsCó thể đã có người làm @kcjonson đã nhận 10 ngày trước. Đang mởplatform: ios
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
ionic-team/capacitor-plugins#2620 ·
Maintainer thường phản hồi trong vòng 29 ngày
Tất cả issue của ionic-team/capacitor-plugins
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
EpssMirrorTask leaks temp file on failed download and has no request timeoutCó thể đã có người làm @someshhh-45 đã nhận hôm nay. Đang mởdefect in triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
DependencyTrack/dependency-track#7845 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: WriteFileTool shows "Error reading file" snippet for relative paths when baseDir is setCó thể đã có người làm @ShryukGrandhi đã nhận hôm nay. Đang mở
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 86/100
agentscope-ai/agentscope-java#3917 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/maven-checkstyle-plugin#735 ·
Maintainer thường phản hồi trong vòng 1 ngày