title: Opening a dynamic link from a WebView inside React native App
body: <p>I have a requirement to open an App screen using user selections on a website, where when user select an item it should openup the relevant page in the Mobile App.
  But the website should be loaded inside a webview within the same APP.
  Here I used Firebase dynamic links to manage this navigation.</p>
  
  <p>I can open up the website from chrome browser in the emulator and open up the App navigated to exact page as required.
  But when I click the same component from the webview within the app it throws up the following error and App wont open up the page that the firebase dynamic link should open up as in the first case of the chrome browser.</p>
  
  <pre><code>Can't open url: intent://example.page.link/getapp#Intent;package=com.google.android.gms;action=com.google.firebase.dynamiclinks.VIEW_DYNAMIC_LINK;scheme=https;S.browser_fallback_url=https://play.google.com/store/apps/details%3Fid%3Dcom.ubercab;end;
  </code></pre>
  
  <p>My implementation is as follows,</p>
  
  <p><strong>WebApp</strong></p>
  
  <p>App.js</p>
  
  <pre><code>function App() {  
  
    return (
  
      &lt;div&gt;
        &lt;Button variant="primary"&gt;
          Open this in your App
        &lt;/Button&gt;
        &lt;Banner url={"https://testingapp.page.link/getapp"}/&gt;
      &lt;Banner url={"https://testingapp.page.link/getapp"}/&gt;
      &lt;Banner url={"https://testingapp.page.link/getapp"}/&gt;
      &lt;Banner url={"https://testingapp.page.link/getapp"}/&gt;
      &lt;/div&gt;
  
    );
  }
  </code></pre>
  
  <p>Banner.js</p>
  
  <pre><code>const Banner=(props)=&gt;{
      const classes = useStyles();
      const [expanded, setExpanded] = React.useState(false);
  
      const styles = {
          cardAction: {
              display: 'block',
              textAlign: 'initial',
              height: '100%'
          }
      }
  
  
  
    return (
        &lt;div onClick={() =&gt; window.open(props.url, "_blank")}&gt;
            &lt;Card className={classes.root}&gt;
                &lt;CardMedia
                    className={classes.media}
                    image= {banner}
                    title="Offer"
                /&gt;
            &lt;/Card&gt;
        &lt;/div&gt;
  
    );
          };
  
  export default Banner;
  </code></pre>
  
  <p><strong>On the Mobile App side</strong>:</p>
  
  <p>App.jsx</p>
  
  <pre><code>import React, { useEffect } from 'react';
  import { StyleSheet, Text, View, Button } from 'react-native';
  import dynamicLinks from '@react-native-firebase/dynamic-links';
  import { WebView } from 'react-native-webview';
  import { NavigationContainer } from '@react-navigation/native';
  import { createStackNavigator } from '@react-navigation/stack';
  function DetailsScreen({ navigation }) {
    return (
      &lt;View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}&gt;
        &lt;Text&gt;Details Screen&lt;/Text&gt;
      &lt;/View&gt;
    );
  }
  
  function HomeScreen({ navigation }) {
    async function buildLink() {
      console.log('building link');
      const link = await dynamicLinks().buildLink({
        link: 'https://invertase.io',
        // domainUriPrefix is created in your firebase console
        domainUriPrefix: 'https://testingapp.page.link',
        // optional set up which updates firebase analytics campaign
        // "banner". This also needs setting up before hand
        analytics: {
          campaign: 'banner',
        },
      });
  
      return link;
    }
  
  
    const handleDynamicLink = link =&gt; {
      // Handle dynamic link inside your own application
      console.log('Received URfffL:' + link.url);
      if (link.url === 'https://example.com/packageview') {
        console.log('hit package view');
        navigation.push('packageview');
      }
    };
  
    useEffect(() =&gt; {
      const unsubscribe = dynamicLinks().onLink(handleDynamicLink);
      // When the is component unmounted, remove the listener
  
      dynamicLinks()
        .getInitialLink()
        .then(link =&gt; {
          console.log('Received URL:' + link.url);
          if (link.url === 'https://example.com/packageview') {
            console.log('hit package view');
            navigation.push('packageview');
          }
        });
  
  
      return () =&gt; unsubscribe();
  
  
    }, []);
    return (   
        &lt;WebView source={{ uri: 'http://10.0.2.2:3000/' }}/&gt;   
    );
  }
  
  
  export default function App() {
  
  
  
    const Stack = createStackNavigator();
  
      return (
        &lt;NavigationContainer&gt;
        &lt;Stack.Navigator&gt;
          &lt;Stack.Screen name="Home" component={HomeScreen} /&gt;
          &lt;Stack.Screen name="packageview" component={DetailsScreen} /&gt;
        &lt;/Stack.Navigator&gt;
      &lt;/NavigationContainer&gt;
      );
  
  }
  
  const styles = StyleSheet.create({
    container: {
      flex: 1,
      backgroundColor: '#fff',
      alignItems: 'center',
      justifyContent: 'center',
    },
  });
  </code></pre>
  
  <p>Do anyone have any experience in anything related to this? On what's going wrong in here?</p>