Every tap in your app goes one of three places. Pages on your own site load in the app, other sites open in an in-app browser, and files open in the phone's viewer. There's nothing to configure, and it works the same in Normal and Advanced Mode.
Links to your app's host stay in the app, including target="_blank" links and window.open calls. Turbo Drive keeps working as it does on the web.
A link to another host opens in an in-app browser: a Safari view on iOS and a Custom Tab on Android. People close it to get back to exactly where they were. The same happens when a link on your site redirects to another site, like a /partners/acme route that sends people to the partner's page.
Links with other schemes, like mailto:, tel:, and sms:, open in the app that handles them. An embedded iframe from another site, like a video or a map, loads in place.
Hosts have to match exactly, so www.example.com and example.com count as different sites. If your app runs on one of them, link to that one.
A link that returns a file opens it in a viewer instead of the web view. On iOS that's QuickLook, which can also share and save the file. On Android it's whatever app opens that type, like the PDF viewer or Google Calendar for an .ics, and the share sheet when no app can.
PDFs always open this way. For anything else, send the file as an attachment. send_data and send_file already do by default:
def show
respond_to do |format|
format.html
format.pdf { send_data @invoice.to_pdf, filename: "invoice.pdf" }
format.ics { send_data @invoice.to_ical, filename: "invoice.ics" }
end
end
For Active Storage, ask for an attachment in the link:
<%= link_to "Download", rails_blob_path(@report.file, disposition: "attachment") %>
The app downloads the file with the person's session, so files that need a signed-in user work like any other page. When your app redirects to a storage service, like Active Storage sending people to S3, the file still opens in the viewer, and your session cookie is never sent to the other host.
File links work with Turbo Drive on, so don't add data-turbo="false" to them.
A download built in JavaScript, from a blob: or data: URL, can't leave the web view. Generate the file on your server and link to it instead.
Android web views don't support navigator.share. Use a share button in the navigation bar, or call RubyNative.share() from your own button. Both open the native share sheet on iOS and Android.