apple-app-site-association correct configuration - ios

I am trying to implement an associated domain for an app I'm working on. So far, I have:
Enabled the Associated Domains capability of the app
Added all required domains with applinks:www.domain.com
added an apple-app-site-association file to the root of my server, and when that didn't work also to the .wellknown on my server
This didn't work. When I go to the page that is supposed to open a view controller in my app, it doesn't redirect but only show the banner instead. When I tap the 'Open' button on the banner, however, the right view controller in my app is shown.
Then:
I tried changing the mime type of the file, from application/json
to application/pkcs7-mime.
I verified there is no .json extension
I verified that my server returns a valid response code (200), doesn't redirect, provides the file over https (I havent encrypted
it).
I verified the file has valid JSON.
I even checked in my browser whether it finds the file and it does.
Finally, I have copy-pasted the URL in notepad on the iPhone, long-pressed it and the option 'Open in App' appeared.
Nothing appears to be wrong, yet iOS doesn't link to the app in any circumstances, it only shows the Banner.
What am I missing here? How can I get safari to open my app instead of just showing the banner?
P.S. please note: The website of this project is an asp .net application

Related

Custom URL Scheme Failing within own app

I have a custom URL scheme that I've been using successfully in my app during development for a few months now. We have some web pages that we load in some WKWebViews, and some of those links use our custom URL scheme to call our own app, which then takes action based on those URLs.
Today I deleted the app on my phone and reinstalled it in an attempt to work out a different bug I was having.
Suddenly, tapping on these links does nothing. I cannot find an error being thrown anywhere. Not in the console, not anywhere. I've attempted to dig way down into the various WKWebView delegate methods, but it seems like WKWebView isn't even trying to do anything with these URLs.
However, if I attempt to open one of these URLs in Safari, Safari will ask me if I want to open the URL in my app, which will then load and handle the URL.
Has anyone else seen this? Or have any ideas of where to look to track this down?
I've tried:
Removing and re-adding the URL scheme in my info.plist
Changing the scheme to a new value, then removing it and adding it back in info.plist
Deleting the app
Rebooting my phone
The issue has turned out to be something related to Turbolinks. Somehow there are situations where the page load event isn't firing, and Turbolinks then does not call code we need to activate some elements on the page.

Custom URL scheme without confirmation prompt (Swift)

I've found two options to open my app from a Safari web page: a custom URL scheme created in my app project's Info.plist or Apple's Universal Linking. Obviously the custom URL scheme is the easiest one to set up, but the problem I'm having with this is that Safari shows a confirmation window asking "Open myapp?" first and the user has to tap OK before the app actually opens. I want my app to open automatically as the scheme is opened, and I'm being told the only way to do this is through Universal Linking (please correct me if this is not true). If this is true, however, I would like to know if it's possible in any way to put the required apple-app-site-association file on a http:// domain instead of https://? According the official Apple documentation the format of a correct Universal Link starts explicitly with https:// but my domain name can't be loaded on https:// without redirecting a few times and that messes up the web services I've written to execute other tasks in my app. The two main questions I'm left with after this issue:
1) Is it really impossible to work around the confirmation prompt using a custom URL scheme (myscheme://)? If it's not impossible, how can I do this?
2) If I have to use Apple Universal Linking, can I use a http:// domain? If so, how do I do it? Right now if I load up the universal link, it just shows the dictionary inside the apple-app-site-association file, which I'm pretty sure is not supposed to happen. I'm told it's supposed to send a NSUserActivity object to my app delegate. How can I accomplish this with a http:// link?
It is not possible to trigger a custom URI scheme without showing an alert to the user. This used to be possible in iOS 8, but iOS 9 started showing the alert for all apps. And iOS 10.3 has extended that even to the App Store itself. You cannot bypass this. Universal Links were created to replace URI schemes for this behavior, so you do need to use them instead.
From your description, I believe you may be misunderstanding how Universal Links work. To answer the literal questions you asked first, no the Universal Link URL itself does not need to be on the https:// protocol, and yes, the apple-app-site-association must be served over https:// without redirects.
However, it sounds like you're trying to serve the content of the apple-app-site-association file for every Universal Link. That is not the correct implementation — the AASA file is hosted only at https://example.com/apple-app-site-association, and iOS automatically retrieves it when the app is installed. After that, any URL on example.com that matches the criteria in the AASA file will be eligible for Universal Links.
All of that said, you really don't want to built out this system on your own. I suggest looking into Firebase Dynamic Links or Branch.io (full disclosure: I'm on the Branch team).
Is it really impossible to work around the confirmation prompt using a custom URL scheme (myscheme://)? If it's not impossible, how can I do this?
That is possible with some hacky tricks and BAD user experience. It requires user to press "add to home screen" button, so I don't recommend this solution in most cases.
set your app scheme like myapp
create the following html file and put it into the web
window.onload = function() {
if (("standalone" in window.navigator) && window.navigator.standalone) {
window.location.href = 'myapp://open'
}
}
open the html file with safari and "add to home screen"
open the home screen icon and your native app will launch
The point is the meta tag.
<meta name="apple-mobile-web-app-capable" content="yes" />
Without this, safari will launch and confirmation prompt will appear.

Firebase App Indexing Test always fails

When using the implementation test from
https://firebase.google.com/docs/app-indexing/ios/test
I always get the following error:
ERROR:Google did not find App content associated with the URL.
I made sure that universal links work (i.e. open the app instead of browser on iOS device) for the entered url (which is a https:// url).
What could be the reason for this behaviour?

iPhone http:// URL redirection

The main task I'm trying to achieve is to open my app with a URL.
Adding the custom URL scheme to the appName-Info.plist everything works fine using the corresponding handleOpenUrl: etc etc.
My point is that my app has got a webSite as well. So what I'm trying to do is, given an url to my users (tiny, short url doesn't matter) combine together these 3 different cases:
If the user opens the URL from his iPhone and he's got the app installed: open the iPhone app;
If the user opens the URL from his iPhone and he hasn't got the app installed: open the iTunes store URL of the app;
If the user open the the URL from his phone (android, tablet, etc) , or from the web, show the web page instead.
My problem is that I can achieve all these tasks separately but I cannot combine all together.
Note: tried to add the http://myApp.com to the UrlScheme but of course didn't work coz the http:// is managed by Safari in the iPhone.
Any idea? Help and suggestions would be really appreciated. Tks a lot chaps.
This SO question seems to have the answer you're looking for:
Check if the user-agent is that of an iPhone/iPod Touch
Check for an appInstalled cookie
If the cookie exists and is set to true, set window.location to your-uri:// (or do the redirect server side)
If the cookie doesn't exist, open a "Did you know Your Site Name has an iPhone application?" modal with a "Yep, I've already got it", "Nope, but I'd love to try it", and "Leave me alone" button.
The "Yep" button sets the cookie to true and redirects to your-uri://
The "Nope" button redirects to "http://itunes.com/apps/yourappname" which will open the App Store on the device
The "Leave me alone" button sets the cookie to false and closes the modal
The other option I've played with but found a little clunky was to do the following in Javascript:
This would solve one of your problems, it will link the user to the app page:
itms-apps://itunes.com/apps/APPNAME

How to add a link to start a file download in a Rails Facebook canvas app

In our Rails app that runs in Facebook canvas, we have a workflow where a logged in user can build a document and then download it.
When the file is ready we show a link to it. This is just a Rails action that renders using send_file in dev or head (with proper NGINX config) in production. This part works fine.
In order to have the file start downloading without opening a new browser tab, we had the link target an empty iframe.
This was working, but a while back, presumably due to a security change by Facebook, our link stopped working. The JavaScript errors show:
Refused to display document because display forbidden by X-Frame-Options.
Users can still open the link in a new tab and it will download the file and a quick fix is to make the link open a new browser tab, but that isn't as good of a user experience.
We tried changing the X-Frame-Options in the headers and/or using meta tags, but this is canvas (running in an iframe), so that just stopped those views from displaying.
I also tried this form solution, but it didn't do anything (I could have been doing it wrong).
Is there any way we can build a button or link that will start the file download without opening a new browser tab?
Do you need to set the target at all? With no target set would it not trigger a file download popup in the browser, but leave the current browser window/tab on the same content?

Resources