Mail and Messages apps missing from iOS expo-sharing menu.
See original GitHub issue🐛 Bug Report
Environment
Expo CLI 3.18.6 environment info:
System:
OS: Linux 4.19 Manjaro Linux
Shell: 5.0.16 - /bin/bash
Binaries:
Node: 13.13.0 - /usr/bin/node
Yarn: 1.22.4 - /usr/bin/yarn
npm: 6.14.4 - /usr/bin/npm
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6392135
npmGlobalPackages:
expo-cli: 3.18.6
iOS: 13.4.1
Steps to Reproduce
Use expo-sharing
as documented. Code shown below.
Expected Behavior
Mail and Messages apps should be visible in the share menu in iOS.
Actual Behavior
Mail and Messages apps are not visible in the share menu in iOS. Every other app that I can share with is visible. This happens for every file type tested so far: PDF and “Office Spreadsheet”.
Reproducible Demo
NOTE: In later tests, I tried adding the UTI
option of "com.adobe.pdf"
to the call to shareAsync
(imported from expo-sharing
).
const allowed = await isAvailableAsync();
if (!allowed) {
throw new Error("Not allowed");
}
let { url, fileName } = data;
// NOTE: For iOS we had to replace all spaces in filename
fileName = fileName.replace(/ /g, "_");
const localFileUrl = await downloadUrl(url, fileName);
const result = await shareAsync(localFileUrl);
Example value for localFileUrl
being shared, from testing: file:///var/mobile/Containers/Data/Application/3C04E999-9999-432D-999B-8ADDA0E9999/Documents/ExponentExperienceData/%2540accountname%252Fapplicationname/Xxxxxx_Xxxx_99999999_99999999.pdf
Other notes
This might be the answer - https://stackoverflow.com/questions/46531572/uidocumentinteractioncontroller-does-not-open-other-app-in-ios-11/46937932#46937932
The problem was that I was trying to share a URL to a file inside the app bundle. It seems Apple’s apps have permission to access that URL but third-party apps don’t. I solved this by first copying the resource to the cache directory and then using that cache directory URL for sharing.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (1 by maintainers)
Here’s the answer - https://forums.expo.io/t/a-possible-way-to-show-a-share-menu-with-expo-without-detaching/9125/4
The code shows using the
Share.share
method fromreact-native
:So, I tried that in my experimental code - with
import { Share } from "react-native";
and then making a special case for iOS:It works!
I have the exact same problem, copying the file to the
FileSystem.cacheDirectory
did not help usingFileSystem.getContentUriAsync
just returns the samefile://
pathThis an ejected bare expo project, but the mail or messages option did not appear even before ejecting