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.

When launching a Chrome Custom Tab (through `openBrowserAsync`) on Android, the intent does not persists

See original GitHub issue

🐛 Bug Report

Environment

  Expo CLI 3.0.10 environment info:
    System:
      OS: macOS 10.14.6
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 12.6.0 - ~/.nvm/versions/node/v12.6.0/bin/node
      Yarn: 1.16.0 - ~/.yarn/bin/yarn
      npm: 6.10.1 - ~/.nvm/versions/node/v12.6.0/bin/npm
    IDEs:
      Xcode: 10.3/10G8 - /usr/bin/xcodebuild
    npmGlobalPackages:
      expo-cli: 3.0.10

App target is both iOS and Android apps using Expo SDK 34.

Steps to Reproduce

On PR #4882 , there was a code change that made Custom Tabs opened in Android no longer show up in the device history.

https://github.com/expo/expo/pull/4882/files#diff-181a67a85ff6d2497b2ab4301faf3769R133-R134

That means when we call an external link in our app (on *Android devices), and the user briefly leaves the view, it closes on them.

Scenario 1:

  1. The user clicks the menu item which makes a openBrowserAsync call to a url.

  2. The user views their task list.

  3. The chrome custom tab dismisses itself without me tapping on anything.

app_switch

Scenario 2:

  1. The user clicks the menu item which makes a openBrowserAsync call to a url.

  2. The user navigates home on their device.

  3. The chrome custom tab dismisses itself in the background and the user cannot return to it.

app_home

Expected Behavior

I am expecting the custom chrome tab to persist if I leave the app and return. Just like how it behaves on our iOS app.

If the user leaves the app to check on something else, we shouldn’t close their session in case they were in the middle of finishing something up.

Actual Behavior

The custom chrome tab is closed immediately when the app is put in the background/loses focus.

Reproducible Demo

https://snack.expo.io/@kylegfs/call-openbrowserasync

In the demo, tap purple the button.

On Android, if you leave the app (by going home, or viewing the other opened apps), the web browser goes away (bad!).

On iOS, if you leave the app, the web browser stays (good!).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
cruzachcommented, Mar 23, 2020

openAuthSessionAsync falls back to openBrowserAsync, so the options you pass to it will trickle-down to openBrowserAsync

We do need to update the docs to reflect this, but you can see that it’s the case by taking a look at the javascript source

0reactions
GuyAvrahamcommented, Mar 23, 2020

@cruzach Thanks, now I see it. I used import { AuthSession } from 'expo'; As shown here: https://docs.expo.io/versions/latest/sdk/auth-session/#example

But then after reading your comment, I found the ‘showInRecents’ implemented on AuthSession when importing it from expo-auth-session instead of from ‘expo’.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chrome Custom Tabs - Intent not being triggered (Android)
I am able to successfully launch the Google Chrome Tabs in my Fragment class (Where I have got 2 buttons: A button that...
Read more >
Android Custom Tabs best practices - Chrome Developers
The solution is to try to launch the Intent and use FLAG_ACTIVITY_REQUIRE_NON_BROWSER to ask Android to avoid browsers when launching. If a ...
Read more >
Chrome Custom tab not triggering url scheme intent
1. Authenticate through a OpenId Connect code flow with Chrome custom tabs and redirect the user to the app thanks to a custom...
Read more >
Intent Filters and Custom Tabs - Chris Horner
Lately I've been working on a project that uses intent filters to open deep links in an app. I'd never done this before,...
Read more >
@expo/cli | Yarn - Package Manager
... way to build and run universal React Native apps for iOS, Android, and the web ... not released in any SDK will...
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