How to open iOS app when user scans a QR Code with an URL in it - ios

I want to create a QR Code that contains a URL like https://example.com in it and when an user scans that, if they have the app installed on the phone, to open the app instead of going to the browser. Is that possible? I've looked at App Links and Universal Links and I can't see to get it to trigger off of a QR Code or with HTTPS instead of some custom URL.

Scanning QR code containing a URL with standard Camera app results in prompt to open the link in Safari. If the link in question is Universal Link and you do have the associated app installed, the prompt shows your app instead of Safari. If a user taps on that prompt your app is brought to foreground and application(_:userActivity:restorationHandler:) is called. It seems like it's not documented anywhere, but most likely it's an intended behavior and it's definitely working.

Related

Universal link after installing app wont open from Safari

Senario: User scans a QR code with a unique universal link into our app to "redeem" their code.
They scan the code which goes to a webpage with a link to download the app.
The user downloads the app.
Returns to the web page and there is a link within the page which is the same link as the QR code.
We assume tapping the (same) URL would trigger the universal link but it does not.
The universal link works fine from email or other apps (after its been installed)
How can we fix this bad UX, is there a HTML component or redirect we need to consider when tapping the basic link on the Web page. How can we make the link initiate the "deeplink" into the app now its installed. The banner at the top is displayed but its not the ideal flow.
The user cannot scan the QR code again - they must go through the download and "reopen" app in one flow.
Universal links do not trigger in Safari. This is intentional behavior confirmed by Apple engineers in the forums (sorry, don't have a link right now). Their reasoning: if you're already in the browser eco-system you usually do not want to be redirected to an app, but want to stay in the browser.
What you can do is have your app implement a custom URL scheme, and your web page can then check if your custom URL scheme is supported and open it.

Is there a way to avoid opening the link in browser

When using Huawei App Links (Because Firebase dynamic link doesn't work for Huawei App Gallery), this is the kind of long link that is generated.
https://example.drcn.agconnect.link/?deeplink=https%3A%2F%2Fexample.com%2Freferral%2F3c3432x&android_deeplink=https%3A%2F%2Fexample.com%2Freferral%2F3c3432x&android_open_type=2&android_package_name=com.example.mobile
When clicked on this link on an Android(Google) device where my app is not installed, I see these options:
"Open" - opens the deep link i.e https://example.com/referral/3c3432x in a browser
"Download" - opens the Google play store app with my app page
The download behavior is fine, but I don't want the open behavior, since that link actually does not exist. I understand this link still be accessed on a desktop and might try to go to the link on a browser, but for now we are okay showing 404 in such cases.
Is there a way to avoid the "Open" option? Or better would be to stop showing this screen and immediately redirect to application if installed or play store of not installed. Just like how Firebase does.
I even tried the option of landing_page_type=2 as listed here: https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-applinking-createlinks-defined-0000001055514692 but that doesn't seem to work, it always show the Open/Download page irrespective of the value.

How do different formats of "path" behave in the apple app site association file

we are currently in the process of linking our web portal to our native app (iOS). In the first step, we will try to implement some Deeplinks.
Therefore it is planned to host the "apple app site association file" on the domain (e.g portal.example.com) and provide deeplinks with the help of Universal Links. However, before we start the implementation, there are some questions left:
Let's say we have only 3 URLs that should deeplink to the app. Each of them will get an own row in the paths section:
portal.example.com/functions/firstfunction
portal.example.com/functions/secondfunction
portal.example.com/functions/thirdfunction
If the User now opens the first URL, he will be asked if he wants to open it in the app, right? Let's pretend the user accepts and opens the URL in the app. What happens if he then goes back to the portal and tries to open the second URL? Will he be asked again, or will the app remember the decision and open any URL from the aasa file in the app?
What happens if we use wildcards and write the path like this:
"portal.example.com/functions/*"
Thank you and bg!
Let me first correct you:
If you use 'universal links', and you open any url, then it will not first ask you that "open in app" and then if denies then to webpage.
But it will be work in this manner:
You must be opening URL in iOS device's safari browser(it will not work for other browsers).
It will first open the webpage. If it finds 'apple-app-site-association' file on that website + It also finds the app with same path in its associated domains section installed on device. Then it will show top bar like below image:
Now, if use clicks on this OPEN button, then only your app is going to be opened. If you come back from app to website, this will remain as it is on top.
Answer to your second question: If you provide only specific domains, then the above popup will be visible only for specific webpages. If you are using wildcards, then all webpages which comes under that wild card, will have top bar like above image.
One more thing to note while you are developing above feature: Universal links get associated while you install the app OR update to new version. So, while developing app - let you have installed app without any associated domains, now you added associated domains in app, and installed app again(via xcode) on your device, and open the webpage in safari. Then above will not work. To make it work, either you have to remove/uninstall the app first and then install it again OR you have to change the version.

Firebase Dynamic Links IOS

I have setup firebase for receiving universal links and custom url schemes. I have 2 issues here,
Clicking links on the app like whatsapp opens the browser but not the
app, however, if I get the link to the notes app and open it, it
shows an option of "open in app" after doing this, everytime I open
it in whatsApp it seems to work fine.
When I try to open links via chrome from the email app, it redirects
to the app via custom url scheme, however the problem is that, the
next time I open the app, it tends to repeat the action. Although I
have already handled the custom url scheme previously, I dont know
why its trying to do it again, kinda freaks me away.

iOS Universal Link App Store redirect

I have universal links working correctly, when the app is installed I see how the link opens the app, and when it's not installed opens the url in safari.
Actually what I would like to do is to redirect and go to the app store, so users can download the app directly.
Im going to include a redirect on the html file, because I know universal links don't support redirects a the http server config level (anyway I think this is for the manifest file only, apple-apps-site-association)
Anyone can confirm if this is the right way to do it, or the only way to do it? I don't like the idea to open safari first, load my html (with the redirect only) and then go to the store. Looks like there's no easier way to do it.
You're right: server-side redirects aren't allowed for the apple-app-site-association file. However, I believe once the user opens a Universal Link and (assuming the app is not installed) lands on the URL, all options are on the table (server-side, or otherwise).
If the page on the other end of your Universal Links URL contains an instant JS redirection to your app's App Store page, that should work just fine. Something like this:
window.location = 'itms-apps://itunes.apple.com/us/app/imdb-movies-tv/id342792525'
But yes, no matter how you do it, Safari is still going to open. It'll flash past so quickly that the user likely won't even notice. Here's a real-time recording I just made of the Branch.io deep linking service's demo app doing exactly this process:
From here: https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html
"When you support universal links, iOS 9 users can tap a link to your website and get seamlessly redirected to your installed app without going through Safari. If your app isn’t installed, tapping a link to your website opens your website in Safari."
You're not doing it wrong, that's just how they work.

Resources