React native 如何在react native中从浏览器检索url?

React native 如何在react native中从浏览器检索url?,react-native,instagram-api,React Native,Instagram Api,我对react native非常陌生,我想为我的应用程序创建Instagram身份验证,我需要它的访问令牌。如文档中所述,我必须访问此链接,当用户授权并验证应用程序后,我将被重定向到此链接,从那里我可以获取我的访问令牌。但我无法实现这一点,因为我不知道在重定向到这个位置后如何从react native中的url检索令牌 我正在使用WebBrowser(Expo)打开应用程序中的链接 PS:我正在为我的react本机应用程序使用CRNA cli,其示例如下所示: import Instag

我对react native非常陌生,我想为我的应用程序创建Instagram身份验证,我需要它的访问令牌。如文档中所述,我必须访问此链接,当用户授权并验证应用程序后,我将被重定向到此链接,从那里我可以获取我的访问令牌。但我无法实现这一点,因为我不知道在重定向到这个位置后如何从react native中的url检索令牌

我正在使用WebBrowser(Expo)打开应用程序中的链接


PS:我正在为我的react本机应用程序使用CRNA cli,其示例如下所示:

    import InstagramLogin from 'react-native-instagram-login'
<View>
    <TouchableOpacity onPress={()=> this.refs.instagramLogin.show()}>
        <Text style={{color: 'white'}}>Login</Text>
    </TouchableOpacity>
    <InstagramLogin
        ref='instagramLogin'
        clientId='xxxxxxxxxx'
        scopes={['public_content', 'follower_list']}
        onLoginSuccess={(token) => this.setState({ token })}
        onLoginFailure={(data) => console.log(data)}
    />
</View>
从'react native instagram login'导入InstagramLogin
this.refs.instagramLogin.show()}>
登录
this.setState({token})}
onLoginFailure={(数据)=>console.log(数据)}
/>

这表明令牌将位于调用的应用程序状态(onLoginSucess/Failure)内。从那里访问令牌

从示例中可以看出:

    import InstagramLogin from 'react-native-instagram-login'
<View>
    <TouchableOpacity onPress={()=> this.refs.instagramLogin.show()}>
        <Text style={{color: 'white'}}>Login</Text>
    </TouchableOpacity>
    <InstagramLogin
        ref='instagramLogin'
        clientId='xxxxxxxxxx'
        scopes={['public_content', 'follower_list']}
        onLoginSuccess={(token) => this.setState({ token })}
        onLoginFailure={(data) => console.log(data)}
    />
</View>
从'react native instagram login'导入InstagramLogin
this.refs.instagramLogin.show()}>
登录
this.setState({token})}
onLoginFailure={(数据)=>console.log(数据)}
/>

这表明令牌将位于调用的应用程序状态(onLoginSucess/Failure)内。从那里访问令牌

您可以使用“”作为重定向url来实现访问令牌

使用
webView中的链接

例如:


您可以使用“”作为重定向url来实现访问令牌

使用
webView中的链接

例如:


实际上,我正在使用expo cli,因此无法使用上述解决方案。实际上,我正在使用expo cli,因此无法使用上述解决方案。
_onLoadAddNewCardView(state) {

   console.warn("RES=" + state.url);// Your url with ACCESS TOKEN

   let responseString = state.url;
   responseString = responseString.replace("https://localhost/?", "");

   // Here you will get the ACCESS TOKEN
}