问题
I have implemented google sign-in in my app. The problem is when I go to Safari for the sign in I want the user to be redirected back to my app.
The first approach that I tried was using Custom URL scheme. This worked, however the user was shown a pop-up saying 'Do you want to open (app name)
'.
It appears the solution to this pop-up is Universal Links, which I have implemented. I can seamlessly now navigate to my app from Notes and other apps. However, when I tried this inside my app, it doesn't work and the user is redirected to the website instead of the app.
For testing, I created a website and added a button to it, which was linked to my original website. When I open that website in Safari and click the button, my app opens. So why doesn't the redirection from google sign-in to my website open my app?
回答1:
Universal Links do not work with automatic redirects. They must be triggered via some sort of user action. The link URL also needs to be on a different domain/subdomain from the page where the link is being clicked (e.g., example.dom
and link.example.com
).
Based on your description of link behavior from Notes and other apps, it appears your configuration is correct and you are simply attempting to do something that Universal Links does not support.
For others who find this question via Google and do not have links from Notes working correctly, try the Universal Links validator tool from Branch.io (full disclosure: I'm on the Branch team).
来源:https://stackoverflow.com/questions/44706216/universal-link-does-not-work-in-safari