A
A
Andrey Okhotnikov2019-09-27 10:32:31
React Native
Andrey Okhotnikov, 2019-09-27 10:32:31

Pass data from webview to application?

I have an authorization page through a webview, how can I pass data to the application upon successful authorization?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Alexandrovich, 2019-09-27
@tsepen

place the function you need on your site

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>WebView1</title>
<meta forua="true" http-equiv="Cache-Control" content="max-age=0"/>
</head>
<script type="text/javascript">
function testEcho(test){
  alert(test);
}
</script>
</body>
</html>

then broadcast ref on Webview and call it in the required place like this
return this.webview&&this.webview.injectJavaScript("testEcho("+JSON.stringify({...result,token:this.state.accessToken})+");")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question