FormidableLabs / react-native-app-auth

React native bridge for AppAuth - an SDK for communicating with OAuth2 providers
https://commerce.nearform.com/open-source/react-native-app-auth
MIT License
1.96k stars 438 forks source link

Redirect from browser with a different deep link than defined in redirectUrl config does not work #952

Closed ggarcia92 closed 1 month ago

ggarcia92 commented 3 months ago

Issue

We have a button at the authorization form that redirects to the app with a deep link different than the one configured in the redirectUrl, for example: the redirectUrl is myapp://redirect and the other button redirects to myapp://someother; in this scenario the browser get closed but iOS does not detect the deep link, so the method:

(BOOL) application: (UIApplication *)application
            openURL: (NSURL *)url
            options: (NSDictionary<UIApplicationOpenURLOptionsKey, id> *) options

is never executed. In other words, we cannot use deep links on the authentication page in iOS.

We were able to solve this in Android by modifying the AndroidManifest like this:

<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:theme="@style/AppTheme" android:supportsRtl="true">
    <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" 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="${appAuthRedirectScheme}" android:host="someother" />
      </intent-filter>
    </activity>

    <activity android:name="net.openid.appauth.RedirectUriReceiverActivity" android:exported="true" tools:node="replace">
      <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="${appAuthRedirectScheme}" android:host="redirect" />
      </intent-filter>
    </activity>
  </application>

Environment

carbonrobot commented 1 month ago

Sounds like you were able to solve the issue, if there is any additional information or help needed, please reopen and add additional details.