Introduction

On mobile devices, Descope supports running flows for authentication. However, Android App Links, which Descope uses to handle redirection and token exchange, are blocked by default in certain browsers, like Opera. Developers will need to set up a custom scheme and include it in the flow parameters.

Setting up a Custom Scheme

To set a custom scheme, add the below in your Android Manifest file:

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <!-- replace with something unique. this will only be used as a backup for Opera and some other browsers. -->
    <data android:scheme="myapp" android:host="auth" />
</intent-filter>

Then, when starting the flow, include the "backupCustomScheme" field. This will only apply to Android users whos default browser won't open App Links automatically.

import { useFlow } from '@descope/react-native-sdk'

const flow = useFlow()
const { session, manageSession } = useSession()

try {
  // When starting a flow for an authenticated user, provide the authentication info
  let flowAuthentication = undefined
  if (session) {
    const flowAuthentication = {
      /** The flow ID about to be run. */
      flowId: 'flow-id',
      /** The refresh JWT from an active descope session */
      refreshJwt: session.refreshJwt,
    }
  }
  const backupCustomScheme = "myapp://auth";
  const resp = await flow.start('<URL_FOR_FLOW_IN_SETUP_#1>', '<URL_FOR_APP_LINK_IN_SETUP_#2>', backupCustomScheme, flowAuthentication)
  await manageSession(resp.data)
} catch (e) {
  // handle errors
}