import * as Linking from 'expo-linking'; import * as WebBrowser from 'expo-web-browser'; import React from 'react'; import { StyleSheet } from 'react-native'; import Button from '../../components/Button'; import Configurator, { ConfiguratorChoiceType } from '../../components/Configurator'; import HeadingText from '../../components/HeadingText'; import MonoText from '../../components/MonoText'; const openAuthSessionConfigurationChoices: ConfiguratorChoiceType[] = [ { name: 'shouldPrompt', title: 'Should prompt', initial: false, }, { name: 'createTask', title: 'Create task', initial: true, }, ]; export default function OpenAuthSessionAsyncDemo() { const [options, setOptions] = React.useState<{ shouldPrompt?: boolean; createTask?: boolean }>( {} ); const [authResult, setAuthResult] = React.useState( null ); const openAuthSession = React.useCallback(async () => { const redirectUrl = Linking.makeUrl('redirect'); const result = await WebBrowser.openAuthSessionAsync( `https://fake-auth.netlify.com?state=faker&redirect_uri=${encodeURIComponent( redirectUrl )}&prompt=${options.shouldPrompt ? 'consent' : 'none'}`, redirectUrl, { createTask: options.createTask } ); setAuthResult(result); }, [options]); return ( <> openAuthSessionAsync