expo: Deep link into app in Expo client does not close the Chrome Custom Tabs browser

šŸ› Bug Report

Environment

Android Expo client. This bug does not occur in Android standalone apps.

Steps to Reproduce

  1. Open a web browser with WebBrowser.openBrowserAsync(url);
  2. Have that URL redirect back to your app (Linking.makeUrl())
  3. Notice that in Expo client for Android you need to manually close the browser by tapping the X button, but in a standalone app it closes as expected.

Expected Behavior

On Android because we cannot call WebBrowser.dismiss() we depend on the browser window closing when we redirect back to the app.

Actual Behavior

The browser window only closes on redirect in standalone apps.

Reproducible Demo

import React from 'react';
import { Button, StyleSheet, Text, View } from 'react-native';
import { AuthSession } from 'expo';

const FB_APP_ID = '2232923493627585';

export default class App extends React.Component {
  state = {
    result: null,
  };

  render() {
    return (
      <View style={styles.container}>
        <Button title="Open FB Auth" onPress={this._handlePressAsync} />
        {this.state.result ? (
          <Text>{JSON.stringify(this.state.result)}</Text>
        ) : null}
      </View>
    );
  }

  _handlePressAsync = async () => {
    try {
      let redirectUrl = AuthSession.getRedirectUrl();
      let result = await AuthSession.startAsync({
        authUrl:
          `https://www.facebook.com/v2.8/dialog/oauth?response_type=token` +
          `&client_id=${FB_APP_ID}` +
          `&redirect_uri=${encodeURIComponent(redirectUrl)}`,
      });
      this.setState({ result });
    } catch(e) {
      alert(e.message);
    }
  };
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

(be sure to set a scheme for the standalone app when testing there)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 20
  • Comments: 22 (9 by maintainers)

Most upvoted comments

This should be resolving the issue: #4882

It will be published after SDK 35 is released.

śr., 28 sie 2019 o 14:12 Michał Matyas notifications@github.com napisał(a):

Hey, it’s been three weeks, any news on publishing the latest Expo Client on the Google Play Store?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/expo/expo/issues/4524?email_source=notifications&email_token=ABOO5ZETEYONSXSI6KWLPETQGZTSBA5CNFSM4HWY3UGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5K43MA#issuecomment-525716912, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOO5ZGT4YMOJO6IOV7RZOLQGZTSBANCNFSM4HWY3UGA .

I also see this issue in our standalone production android app, and it’s preventing any android device from logging in with an AuthSession.

Here’s what happens:

  1. Click on a button that calls AuthSession.startAsync.
  2. This summons up a chrome tab, after i sign in, the chrome tab briefly says ā€œReturn to app ->ā€. Tapping on that does nothing. Then the chrome tab turns blank.
  3. When clicking on the ā€œXā€ on the chrome tab, then there’s an Error that you can’t dismiss the window, and the AuthSession promise never returns.

Screenshot_20190707-085447

This was working fine in SDK 32, but is now broken in SDK 33. This is causing us to remove logging in on android with third party auth with AuthSession.

Just tested on the android emulator with that expo .apk, works a treat, great job guys!

We cannot, temporarily, publish Expo Client update on Google Play Store. Could you please check this version and let us know if it works now?

Hey! I’ve just checked the issue, and the problem is that for some reason fix haven’t landed in newest Client version. However, when building standalone application it should work just fine. It is also included in expo-web-browser@6.0.0 for ejected and bare applications.

I am on releasing new version of client with that fix for SDK34.

Not in my testing i’ve done, performs exactly the same as v33, which is not working. The promise resolves still in the background, but the chrome custom tab stays open until you physically tap to close it. I can see the code change in #4882 is in the v34 release though, so clearly that hasn’t fixed the issue. Just testing also opening the page with the app redirect link using ā€˜open in chrome’ and the pressing it from there, works straight away, so it’s definitely the custom tab stuff that’s the issue.

So SDK34 doesn’t fix this? We’re trying to meet the 8/1 deadline for 64-bit Android apps & having to close the Chrome window manually is not a good user experience.

@mczernek since the fix was merged, any chance you could bump the package version and release it so we could see if it solved the issue? Thanks! 😃

Well this is annoying! I thought with the release of SDK34 this would fix the issue… it’s still an issue. You still have to close the chrome window manually and it doesn’t do it for you like it used to before this bug 😦

Is there a workaround for this?

Given that this seems to break our SSO workflow I guess there’s not way to finally upgrade to 33 at the moment 😦