iOS 10 Custom URL Scheme no longer working

2019-09-13 16:48发布

问题:

I have an app with a custom URL scheme set up, and I added the URL to the LSApplicationQueriesSchemes array in the Info.plist.

If I go straight into Safari on the device or simulator and hit myapp:// then the app will open up. However, I have an externally hosted website with a servlet that calls response.redirect("myapp://") and when this is called, the app does not open.

The servlet redirect works in iOS 9 and below. What changed in iOS 10 so that this call no longer works?

It's odd that if I type in the URL by hand into Safari on the device, it works fine. But going to my website in Safari on the device and clicking the button which calls the response.redirect does not work. I am completely flummoxed by this.

回答1:

I actually had to solve this by changing the way the servlet that sent the redirect worked. It only works if you click a link and are redirected from the html page now. Before iOS 10, I had it working so that you clicked a button which submitted a form and the redirect occurred from the servlet. Changing the logic and structure of that servlet, I now have a straight href link which invokes the callback URL, and that works. So nothing fixed in iOS - I'm still not sure what changed, presumably in Safari, to break this, but there you go.