简体   繁体   中英

Universal links not working in iOS simulator

I'm trying too get a universal link working in the simulator so I can test it out. As this is a work project I don't have a compatible device I can use. Thus trying to make this work on a simulator.

I've done everything I can find on the web to try and make this work:

  1. Added the associated domains to the app and set the domain as applinks:192.168.50.200?mode=developer . I'm using the web server on my Synology NAS to test this out.
  2. Added the application(_:continue:restorationHandler:) method to the app delegate, logged the incoming URL and returned true .
  3. Created a .well-known/apple-app-site-association file in the NAS's web server.
  4. Tried using simctl , iMessage and Safari to open a matching URL that should then open in the app.

But step 4 doesn't work. Instead the simulator just opens the URL as a web page.

I've installed proxyman and it shows the web page URL being sent to the server and the response coming back, but at no time is a request sent from the simulator for the apple-app-site-association file. No matter how I try and invoke things.

A number of blogs I've read say that you should be able to test universal links in the simulator using a number of the techniques I've tried. But they don't work for me. I've tried this on an iOS 11.4 and a 13 simulator.

Any ideas? I'm fresh out.

I've since found data in the console. I'm seeing

Task <377F99B3-B58C-4D9B-BCC2-FE36E4D9569B>.<2> finished with error [-999] Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://192.168.50.200/.well-known/apple-app-site-association, NSErrorFailingURLKey=https://192.168.50.200/.well-known/apple-app-site-association, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <377F99B3-B58C-4D9B-BCC2-FE36E4D9569B>.<2>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <377F99B3-B58C-4D9B-BCC2-FE36E4D9569B>.<2>, NSLocalizedDescription=cancelled}

so it looks like it is calling the server, but there is nothing indicating why the request is being cancelled.

Figured it out. It was because my NAS server's web server didn't have a valid cert that would satisfy Apple's TLS. For testing purposes I ended up using ngrok to provide a valid cert and redirect into my NAS. It's a bit of a pain because every time you start then grok tunnel it generates a random but unique domain, but for testing purposes it works perfectly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM