question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
wayneblosscommented, May 8, 2020

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 from react-native:

                 Expo.FileSystem.downloadAsync(
                    urlToYourFile,
                    Expo.FileSystem.documentDirectory + `test.pdf`)
                    .then(({ uri }) => {
                      
                        Share.share({
                            url: uri,
                            title: 'title share',         
                        });
                    })
                    .catch(error => {
                        console.error(error);
                    });

So, I tried that in my experimental code - with import { Share } from "react-native"; and then making a special case for iOS:

  if (Platform.OS === "ios") {
      // Also for iOS, to show the Mail and Contacts sharing options, we need
      // use the bare React-Native facility to do that.
      // const result =
      await Share.share({
        message: fileName,
        title: "Share file",
        url: localFileUrl,
      });
      // console.log("Share.share result: ", result); // prints:
      //    Object {
      //      "action": "sharedAction",
      //      "activityType": "com.apple.UIKit.activity.Mail",
      //    }
    } else {
      // const result =
      await shareAsync(localFileUrl);
      // console.log("shareAsync result: ", result);
    }

It works!

4reactions
kidrocacommented, May 11, 2020

I have the exact same problem, copying the file to the FileSystem.cacheDirectory did not help using FileSystem.getContentUriAsync just returns the same file:// path

console.log('filePath: ', filePath);
const contentUri = await FileSystem.getContentUriAsync(filePath);
console.log('contentUri: ', contentUri);

await Sharing.shareAsync(contentUri, {
  dialogTitle,
  mimeType: 'application/pdf',
  UTI: 'com.adobe.pdf',
});
 filePath:  file:///var/mobile/Containers/Data/Application/DF32C1B1-1A8D-4890-8481-90C43D0CEB2A/Library/Caches/20200511-
MY123-1.pdf
contentUri:  file:///var/mobile/Containers/Data/Application/DF32C1B1-1A8D-4890-8481-90C43D0CEB2A/Library/Caches/2020051
1-MY123-1.pdf

This an ejected bare expo project, but the mail or messages option did not appear even before ejecting

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mail option is missing from share menu - Apple Community
Open Apple Mail, and goto preferences, under the general tab, the first selection is "Default Email Reader". If this is set to Gmail,...
Read more >
Mail App Disappeared from iPhone? How to Find & Restore It ...
Is your Mail app not showing on iPhone ? If your Mail icon has disappeared from your iPhone, here's how to get it...
Read more >
iPhone Mail App Missing? Here's The Fix! [Two-Step Guide]
It's possible the Mail app is missing on your iPhone because you've restricted yourself from using it! Open Settings and tap Screen Time....
Read more >
Change your Gmail settings - iPhone & iPad - Google Support
On your iPhone or iPad, open the Gmail app . At the top left, tap Menu Menu and then Settings . Settings you...
Read more >
Apple's Mail App Is Actually Useful Now: 10 Things to Try
With iOS 15 and iPadOS 15, Apple adds a few new tricks to its Mail app. Can these new features get you to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found