App linksNew
Open your Nucleus app from verified https:// links on a domain you own, through AppX app URI handlers on Windows and Universal Links on macOS.
App links let an https:// link on a domain you own open your app instead of the browser. They
are the desktop counterpart of Android App Links. The link reaches the same onDeepLink { } as a
custom URL scheme, so you add no runtime code.
| Platform | Support | Mechanism |
|---|---|---|
| Windows, AppX / MSIX | Yes | windows.appUriHandler |
| Windows, NSIS / MSI / Portable | No, no package identity. The build warns | |
| macOS, signed build with a profile granting Associated Domains | Yes | Universal Links |
| macOS, unsigned or ad hoc build, or no such profile | No, skipped. The build warns or logs | |
| Linux | No | freedesktop has no verified-link mechanism |
Declare the hosts
nucleus.application {
nativeDistributions {
protocol("MyApp", "myapp") // custom scheme, every format
appLinks("example.com", "*.example.com") // https:// links: AppX, signed macOS builds
macOS {
provisioningProfile.set(file("packaging/MyApp.provisionprofile")) // required on macOS
}
}
}appLinks(vararg hosts) takes bare host names, without scheme, port, or path. One leading *.
covers every subdomain. *.example.com matches a.example.com but not example.com, so declare
both if you need both. The plugin lowercases and deduplicates the hosts, and fails the build on
anything that is not a host name.
Each host proves that it trusts your app with a file it serves under /.well-known/. Until the OS
has checked it, links keep opening in the browser.
Never declare protocol("MyApp", "https") to catch web links. That registers your app as a web
browser for every https:// URL, not as the handler of your domain.
Receive the link
Handle it like any deep link:
fun main(args: Array<String>) = nucleusApplication(args) {
onDeepLink { uri: URI -> navigateTo(uri) } // https://example.com/path?q=1
DecoratedWindow(onCloseRequest = ::exitApplication) { /* ... */ }
}On Windows, the OS starts the app with the full URL as its first argument, and the single-instance lock forwards it to a running instance. On macOS, the link arrives as a user activity, on a cold start as well as in a running app.
Set up Windows
App links need package identity, so only the AppX format registers them. NSIS, MSI, Portable,
and the other Windows formats ignore appLinks(...) and print a warning. Configure the package as described in
Build an AppX or MSIX package.
Serve this file at https://<host>/.well-known/windows-app-web-link, with no extension, over HTTPS,
and without a redirect:
[
{
"packageFamilyName": "MyCompany.MyApp_xxxxxxxxxxxxx",
"paths": ["*"],
"excludePaths": [],
"allowSubdomains": true
}
]packageFamilyName is your package family name, which Get-AppxPackage lists for an installed
package. allowSubdomains is needed for a *. host. Check the file before you publish it:
%windir%\System32\AppHostRegistrationVerifier.exe example.com MyCompany.MyApp_xxxxxxxxxxxxx windows-app-web-linkNo output means the file is valid. Windows re-validates the host on its own schedule, from the same day to 8 days later according to Microsoft.
Test on Windows
- Install the package. A sideloaded or developer-registered package opens its hosts' links even when validation failed, so you can test before the file is online. A Store install depends on the hosted file.
- Run
Start-Process 'https://example.com/test'in PowerShell, or open the link from Win+R or another app. - The first time per host, Windows asks which app should open the site: your app or the default browser. Settings, Apps, Apps for websites lists each host with an on/off toggle.
Links clicked inside Chrome or Edge stay in the browser. http:// links on a declared host also
open the app.
Set up macOS
Universal Links rest on the com.apple.developer.associated-domains entitlement. macOS refuses to
launch an app that claims it without an embedded provisioning profile that grants it, for
Developer ID builds as well as App Store ones. So the plugin adds it only when all of these hold:
- The build is signed with a real identity (
macOS { signing { sign.set(true) } }). Unsigned and ad hoc builds, such asrunDistributablein development, skip it. macOS { provisioningProfile }points at a profile that grants Associated Domains. Enable the capability on your App ID in the Apple Developer portal, then regenerate the profile. Without a profile, or with one that lacks the capability, the build warns and leaves the entitlements alone.
The plugin then copies the profile to Contents/embedded.provisionprofile and signs the bundle
with applinks:<host> for each host. It also adds com.apple.application-identifier and
com.apple.developer.team-identifier from the profile when your entitlements lack them. This
applies to createDistributable and to every signed DMG, ZIP, and PKG, JVM and GraalVM alike.
If your entitlementsFile already declares com.apple.developer.associated-domains, for example
applinks:example.com?mode=developer, the plugin uses it as is.
Serve this file at https://<host>/.well-known/apple-app-site-association, with no extension and
without a redirect:
{
"applinks": {
"details": [
{ "appIDs": ["TEAMID.com.example.myapp"], "components": [{ "/": "/app/*" }] }
]
}
}appIDs holds your team ID and bundleID. Limit components to the paths your app handles:
every other path keeps opening in the browser. macOS fetches the file through Apple's CDN, and
https://app-site-association.cdn-apple.com/a/v1/<host> shows what the CDN holds. GitHub Pages
serves it as application/octet-stream, which works.
Test on macOS
- Build a signed app, then check its entitlements:
codesign -d --entitlements - --xml MyApp.app | plutil -p -must listapplinks:<host>. - Install the app, for example in
~/Applications, and launch it once. - In Safari, open a link on your host. Safari loads the page and shows a banner offering to open
it in your app. Its Open button delivers the link to
onDeepLink.
A URL you type in the address bar, or pass to open https://…, always loads in the browser.
Chrome ignores Universal Links.
API reference
| Symbol | Notes |
|---|---|
appLinks(vararg hosts) | Gradle DSL in nativeDistributions. Bare host names, one optional leading *.. |
appLinkHosts | MutableList<String>, the hosts appLinks collects. |
macOS { provisioningProfile } | Required on macOS: a profile granting Associated Domains. |
NucleusApplicationScope.onDeepLink(block: (URI) -> Unit) | Receives the https:// URI. |
What's next
- Deep links: custom URL schemes and
DeepLinkHandler. - Building for Windows: the AppX package.
- Code signing: the macOS signing identity app links need.
Last updated on