Save or export Expo-generated file on Android

Goal
Allow user to download, save, or export a PDF generated by Expo’s Print.printToFileAsync

Problem
React Native’s Share.share API does not accept url option for Android, so only message is shareable

Code

// works only on iOS
const savePDF = async formData => {
  const { uri } = await Print.printToFileAsync({ html: generateForm(formData) });
  const result = await Share.share({ message: '', url: uri });
  if (result.action === 'dismissedAction') return;
}

Comments
How can I implement this feature for Android? The PDF exists in Expo’s FileSystem, but I’m not sure how I can allow end users to access it themselves. Is this possible without ejecting from Expo?

3 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.