proyecto26 / react-native-inappbrowser

📱InAppBrowser for React Native (Android & iOS) 🤘
https://www.npmjs.com/package/react-native-inappbrowser-reborn
MIT License
1.29k stars 218 forks source link

`openAuth` never resolves on Android. Chrome says "Navigation is unreachable: myapp://..." when redirectUri is invoked #441

Closed rcorrie closed 7 months ago

rcorrie commented 7 months ago

This is only occurring on my Android device. When I call openAuth, the promise is never resolved.

I inspected my Android Chrome session, and I see this error in the console:

Screenshot 2023-11-16 at 6 52 30 AM

Here is the code I use to launch openAuth

const result = await InAppBrowser.openAuth(url, AUTH_REDIRECT_URI, {
  // iOS Properties
  ephemeralWebSession: false,
  enableBarCollapsing: true,
  // Android Properties
  showTitle: false,
  enableUrlBarHiding: true,
  enableDefaultShare: false,
  showInRecents: true,
  toolbarColor: Theme.primaryDarker,
  secondaryToolbarColor: Theme.primaryDarker,
  navigationBarColor: Theme.primaryDarker,
  navigationBarDividerColor: Theme.primaryDarkest,
})
if (result?.type === 'success' && result.url) {
  Linking.openURL(result.url)
}

I have made sure that I added my url scheme in AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/BootTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
          <action android:name="android.intent.action.VIEW"/>
          <category android:name="android.intent.category.DEFAULT"/>
          <category android:name="android.intent.category.BROWSABLE"/>
          <data android:scheme="myapp"/>
        </intent-filter>
      </activity>
    </application>
</manifest>
rcorrie commented 7 months ago

Closing this issue, I found a small typo in my redirectUri. Fixing that solved my issue.