1

I have implemented deep linking for Android and iOS, below method works perfectly with android but I am facing problem with iOS.

It navigates to the page of app link but comes back to main screen automatically.

Below is the implementation of my method. I have followed everything from MSDN for deep linking.

protected override async void OnAppLinkRequestReceived(Uri uri)
{
    string appDomain = "https://" + "mydomain.com".ToLowerInvariant() + "/";
    if (!uri.ToString().ToLowerInvariant().StartsWith(appDomain, StringComparison.Ordinal))
        return;

    string pageUrl = uri.ToString().Replace(appDomain, string.Empty).Trim();
    var parts = pageUrl.Split('?');
    string page = parts[0];
    string pageParameter = parts[1].Replace("id=", string.Empty);

    var formsPage = Activator.CreateInstance(Type.GetType(page));
    var jobItemPage = formsPage as JobDetail;
    
    if (jobItemPage != null)
    {
        jobItemPage.BindingContext = new JobDetailViewModel(int.Parse(pageParameter));
        await MainPage.Navigation.PushAsync(formsPage as Page);
    }

    base.OnAppLinkRequestReceived(uri);
}

Below is my apple-app-site-association file:

{
"applinks": {
 "apps": [],
 "details": [
   {
     "appID": "MyTeamIdPrefix.com.deepLinking",
     "paths": [ "*" ]
    }
   ]
  }
}
Zeeshan shaikh
  • 341
  • 1
  • 5
  • 24
  • refer to https://stackoverflow.com/questions/39181728/universal-links-deep-linking-not-working-on-iphone-but-works-on-ipad – Wen xu Li Oct 22 '21 at 09:40
  • The above link is a different issue, my app is being opened while clicking the link but it doesn't redirect to the page – Zeeshan shaikh Oct 22 '21 at 11:41
  • Run under debugger, with a breakpoint at start of that method. Another breakpoint on line `await MainPage.Navigation.PushAsync(formsPage as Page);`. Does it stop at both breakpoints? If not, try again, using Step Over to do lines one at a time. On what line does it not do what is expected? – ToolmakerSteve Oct 26 '21 at 06:26
  • Yes, it comes one time at MainPage.Navigation.PushAsync(formsPage as Page) and App navigates to it but it automatically goes back right after that. – Zeeshan shaikh Oct 26 '21 at 08:23

1 Answers1

0
  1. Make sure your Associated Domains in Apple Developer is enabled.

  2. Created apple-app-site-association. And there is no error in the content.

  3. Enable Associated Domain and add the domain of the website in the Entitlements.plist file.

Wen xu Li
  • 1,698
  • 1
  • 4
  • 7
  • I have followed all above steps, do I need to have a valid path in apple-app-site-association file ? I have used /*/ in paths so it should allow all redirections. – Zeeshan shaikh Oct 25 '21 at 12:37
  • Yes, the json format inside needs to be written in accordance with the regulations. – Wen xu Li Oct 26 '21 at 01:17
  • I have edited my question and added the apple-app-site-association file content, can you check – Zeeshan shaikh Oct 26 '21 at 04:11
  • The link in the comment above contains information about apple-app-site-association. It seems to judge whether your file is correct or not. You can test it through the link provided by him. – Wen xu Li Oct 26 '21 at 09:41