title: Receives a dynamic link and navigates to the desired page Xamarin.Form but Xamarin.Android is not working
body: <p>I want to write code that receives a dynamic link and navigates to the desired page.</p>
  <p>So I wrote the below, and both iOS and Android receive it.</p>
  <p>Xamarin.Form code</p>
  <pre><code>public partial class MainPage : ContentPage
      {
  
          public MainPage()
          {   
              InitializeComponent();
              MessagingCenter.Subscribe&lt;App, TestModel&gt;((App)Xamarin.Forms.Application.Current, &quot;dynamicLink&quot;, getURl);
          }
  
        
  
          private  void getURl(App sourece, TestModel model)
          {   
              Console.WriteLine(model.page);
              Navigation.PushAsync(model.page);
          }
      }
  </code></pre>
  <p>Xamarin.Android code</p>
  <pre><code>class OnSuccessListner : Java.Lang.Object, IOnSuccessListener
      {
          void IOnSuccessListener.OnSuccess(Java.Lang.Object result)
          {
              var link = result.JavaCast&lt;PendingDynamicLinkData&gt;();
              Android.Net.Uri deeplink = null;
              if (link != null)
              {
                  Console.WriteLine(&quot;received&quot;);
                  deeplink = link.Link;
                  Console.WriteLine($&quot;{deeplink}&quot;);
                  var Model = new TestModel();
                  if (deeplink.Path == &quot;/Test&quot;)
                  {   
  
                     switch(deeplink.GetQueryParameter(&quot;ModelName&quot;))
                      {
                          case &quot;Test1&quot;:
                              Model = new TestModel { page = new Test1() };
                              break;
                          case &quot;Test2&quot;:
                              Model = new TestModel { page = new Test2() };
                              break;
                          default:
                              Console.WriteLine(&quot;Not Value&quot;);
                              break;
                      }
                  }
  
                  MessagingCenter.Send((App)Xamarin.Forms.Application.Current, &quot;dynamicLink&quot;, Model);
              }
          }
  
      }
  </code></pre>
  <p>Xamarin.iOS</p>
  <pre><code>public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
          {   
  
              return DynamicLinks.SharedInstance.HandleUniversalLink(userActivity.WebPageUrl, (dynamicLink, error) =&gt; {
                  if (error != null)
                  {
                      System.Console.WriteLine(error.LocalizedDescription);
                      return;
                  }
                  var compoents = new NSUrlComponents(dynamicLink.Url, false);
                  var queryitems = compoents.QueryItems;
                  var Model = new TestModel();
                  if(compoents.Path == &quot;/Test&quot;)
                  {
                      var queryitem = (from item in queryitems
                                  where item.Name == &quot;ModelName&quot;
                                  select item).First();
                      if(queryitem != null)
                      {
                          switch (queryitem.Value)
                          {
                              case &quot;Test1&quot;:
                                  Model = new TestModel { page = new Test1() };
                                  break;
                              case &quot;Test2&quot;:
                                  Model = new TestModel { page = new Test2() };
                                  break;
                              default:
                                  Console.WriteLine(&quot;Not Value&quot;);
                                  break;
                          }
                      }
                  }
  
                  Console.WriteLine(dynamicLink);
  
                  MessagingCenter.Send((App)Xamarin.Forms.Application.Current, &quot;dynamicLink&quot;, Model);
                  // Handle Universal Link
              });
  </code></pre>
  <p>However, on Android, there is a problem that MessagingCenter listens twice and an error of &quot;System.InvalidOperationException: 'Page must not already have a parent.'
  &quot;</p>
  <p>So I modified the method. I change my Moethod like this.</p>
  <pre><code>private async void getURl(App sourece, TestModel model)
          {   
             
              if(Device.RuntimePlatform == Device.iOS)
              {
                  Console.WriteLine($&quot;{model.page} - iOS&quot;);
                  await Navigation.PushAsync(model.page);
              } else
              {
                  Console.WriteLine($&quot;{model.page} - Android&quot;);
                  await Navigation.PushAsync(model.page);
                  MessagingCenter.Unsubscribe&lt;App, TestModel &gt;((App)Xamarin.Forms.Application.Current, &quot;dynamicLink&quot;);
                  
              }
              
          }
  </code></pre>
  <p>MessagingCenter received it once, but it doesn't move to the page.</p>
  <p>May I know what the problem is!?</p>