6
votes

Is there a solution to view or open PDF Files using Expo (without Expo eject)? It's not necessary to open file inside App, it's can be a local filemanager.

What i tried:

1

1 Answers

11
votes

My solution:

Use FileSystem.getContentUriAsync() and Expo IntentLauncher

import * as FileSystem from 'expo-file-system';
import * as IntentLauncher from 'expo-intent-launcher';

FileSystem.getContentUriAsync(uri).then(cUri => {
  IntentLauncher.startActivityAsync('android.intent.action.VIEW', {
      data: cUri.uri,
      flags: 1,
      type: 'application/pdf'
   });
});

enter image description here