apple-app-site-association files are set up correctly
The idea is you can use these functions in your test suite for doing automated tests on the validity of your apple-app-site-association file
To fetch the
apple-app-site-association files, create a URL which is your domain, such as
let domainUrl:URL = URL(string:"https://www.example.com")!
and retrieve the two urls for the allowed locations like so:
let appleAppSiteAssociationURLs:[URL] = try! domainUrl.urlsForAppleAppSiteAssociation()
Then use the urls to fetch the files. it shoudle exist at one of the two locations.
Once you’ve fetched the Data of the
apple-app-site-association file, deserialize it with a
JSONDecoder, like so:
let appleAppSiteAssociation:AppleAppSiteAssociation = try! JSONDecoder().decode(AppleAppSiteAssociation.self, from: data)
Testing matching URLs
Test which app ids can be linked for a given URL, using the
let testUrl:URL = URL(string: "https://www.example.com/buy/")! let testAppId:String = "ABCED1234.com.example.app" XCTAssertEqual(appleAppSiteAssociation.applinks?.matchedAppIds(testUrl).contains(testAppId), true)
Each class within contains its own testing methods and its properties can be introspected.
percentEncoded is not handled correctly