10

I've gone through pretty much every Universal Links question on SO that I can find and have yet to have any luck. For the record, this all appears to pass Branch's validator.

I'm running iOS 10.3 and serving up my aasa file behind https, so in theory I shouldn't need to sign it.

Here's where I stand:

When the app is installed, tailing Heroku's logs for my staging server gives me this:

7-07-27T17:24:59.818724+00:00 heroku[router]: at=info method=GET path="/.well-known/apple-app-site-association" host=trueey-staging.herokuapp.com request_id=54b817e2-1d89-4c7a-9ed8-f52bdb3ad46e fwd="24.23.197.78" dyno=web.1 connect=1ms service=6ms status=200 bytes=618 protocol=https
2017-07-27T17:24:59.812926+00:00 app[web.1]: Started GET "/.well-known/apple-app-site-association" for 24.23.197.78 at 2017-07-27 17:24:59 +0000
2017-07-27T17:24:59.814845+00:00 app[web.1]: Processing by Web::AppSiteController#show as */*
2017-07-27T17:24:59.815538+00:00 app[web.1]: Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms)

1) My entitlements:

applinks:trueey-staging.herokuapp.com
applinks:https://trueey-staging.herokuapp.com

Are these the same thing? Probably, but let's double-down

2) My apple-app-site-association file, route, and Rails controller that serves it up:

apple-app-site-association (lives in /public as apple-app-site):

{
    "applinks": {
        "apps": [ ],
        "details": [
            {
                "appID": "[Prefix].[AppId]",    
                "paths": [ "*", "/" ]
            }
        ]
    }   
}

route(s):

  get "/apple-app-site-association", to: "web/app_site#show"
  get "/.well-known/apple-app-site-association", to: "web/app_site#show"

Controller:

module Web

class AppSiteController < ApplicationController
    def show
        data = File.read("#{Rails.root}/public/apple-app-site")
        render json: data
    end
end

end

3) In My AppDelegate I've implemented the application:continueUserActivity:restorationHandler: function and it is set up to do the exact same thing as when didFinishLaunchingWithOptions is called (plus print out a ton of ==== for kicks)

AND YET...

Nothing. After deploying to staging I load up the app on my phone, go through our share functionality to generate a link, save it to notes, and click it only to have it open up in Safari. Long press doesn't do anything, and there's no other indication that Safari is opening instead of the app. Device logs do not seem to indicate any problems, but maybe I'm not searching for the right thing?

Halp.

inspector_60
  • 448
  • 1
  • 3
  • 12
Nick Coelius
  • 4,668
  • 3
  • 24
  • 30
  • Have you tried removing and reinstalling your app? Universal links are only registered when the app is just installed – donnywals Jul 27 '17 at 13:30
  • @donnywals Yeah, pretty much every time I rebuild from XCode I uninstall the app on my phone...Is there something more I need to do? – Nick Coelius Jul 27 '17 at 16:45

3 Answers3

1

It seems that your problem is in your app implementation not your server.

You need to implement application:continueUserActivity:restorationHandler: function on your app delegate.

You can read more about it here which I guess you already visited but pay close attention to the "Preparing Your App to Handle Universal Links" section, specifically:

After you specify your associated domains, adopt the UIApplicationDelegate methods for Handoff (specifically application:continueUserActivity:restorationHandler:) so that your app can receive a link and handle it appropriately.

When iOS launches your app after a user taps a universal link, you receive an NSUserActivity object with an activityType value of NSUserActivityTypeBrowsingWeb. The activity object’s webpageURL property contains the URL that the user is accessing. The webpage URL property always contains an HTTP or HTTPS URL, and you can use NSURLComponents APIs to manipulate the components of the URL.

inspector_60
  • 448
  • 1
  • 3
  • 12
  • Please note point #3 in my question - the app delegate is set up to handle incoming requests and do exactly what the normal didFinishLaunching flow would handle, which is to say just open the app to the first page. I plan on doing more specialized stuff eventually, but for now I just want it launching...and it's not! I have print statements and breakpoints around continueUserActivity, and they're not being activated. – Nick Coelius Aug 02 '17 at 01:09
  • I noticed point #3 and that's what point me to this solution. It indicated that you haven't implemented the needed function. The app will not launch, unless you will implement it, please try to add it just with one print line to test it, and come back with the results, good luck! – inspector_60 Aug 02 '17 at 06:00
  • That's what I'm saying though - `continue userActivity` IS implemented, and is doing exactly what `didFinishLaunching` is doing, so it SHOULD just be opening the app to the first page - but nothing. – Nick Coelius Aug 02 '17 at 18:08
0

I think the following can help you.

1) applinks:trueey-staging.herokuapp.com in Associated domains

2) Try to change your json in https://trueey-staging.herokuapp.com/apple-app-site-association to

{"applinks":{"apps":[],"details":[{"appID":"SSHENFP95X.com.markmywordsllc.trueey-staging","paths":["*"]}]}}

3) Apple take a time to register new universal links.

After these steps try to open https://trueey-staging.herokuapp.com from another app and it should open your app

wskcoder
  • 266
  • 2
  • 6
  • Hah, my aasa actually is "SSHENFP95X.com.markmywordsllc.trueey-staging", I just edited it out here for privacy purposes? But of course anyone can just go to the url and see the IDs, heh. – Nick Coelius Jul 26 '17 at 21:33
0

Ultimately what made it work was adding an application-identifier entitlement with a value similar to the appID from the AASA file; I used a wildcard $() for the suffix, so in theory it'll work across deployment environments. No idea where that is supposed to come from, or what presumptions were being made on the part of Apple's documentation, but...the app opens from links, now!

Nick Coelius
  • 4,668
  • 3
  • 24
  • 30