Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add Universal/App Links page #19213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions doc/articles/features/app-links.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
uid: Uno.Features.AppLinks
---

# App Links

> [!TIP]
> This article covers a quick overview for enabling Universal/App Links. For a full description of the feature and instructions on using it in general, see the [Microsoft docs on Universal Links](https://learn.microsoft.com/dotnet/maui/macios/universal-links) and [App Links](https://learn.microsoft.com/dotnet/maui/android/app-links).

* Universal Links (iOS) and App Links (Android) are mechanisms that allow deep linking to specific content within your application directly from external sources, such as websites or other apps.

## Using Universal/App Links with Uno

### iOS Universal Links

1. **Update the `Main.iOS.cs` file:**
* Add `OpenUrl` method override in your `Main` to handle Universal Links:

```csharp
// ...

public class App : UIApplication
{
public override void OpenUrl(NSUrl url, NSDictionary options, Action<bool>? completion)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're supposed to support this with OnActivated arguments, did it now work when you tried?

{
base.OpenUrl(url, options, completion);

Console.WriteLine($"Opened URL: {url}");
completion?.Invoke(true);
}
}
```

1. **Enable Associated Domains:**
* Add the `Associated Domains` entitlement to your app.
* Update your Apple Developer Portal to include the domain in the App Identifier.

1. **Configure the apple-app-site-association file:**
* Host this file on your server at `https://<yourdomain>/.well-known/apple-app-site-association`.
* Example file content:

```json
{
"applinks": {
"apps": [],
"details": [
{
"appID": "<TEAMID>.<BUNDLEID>",
"paths": [ "*" ]
}
]
}
}
```

### Android App Links

1. **Update the `AndroidManifest.xml`:**
* Add an intent filter in the manifest:

```xml
<activity android:name="MainActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="<yourdomain>" />
</intent-filter>
</activity>
```

1. **Verify the assetlinks.json file:**
* Host this file on your server at `https://<yourdomain>/.well-known/assetlinks.json`.
* Example file content:

```json
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "<PACKAGE_NAME>",
"sha256_cert_fingerprints": [
"<CERTIFICATE_FINGERPRINT>"
]
}
}
]
```

1. **Handle links in `MainActivity.Android.cs`:**
* Override the `OnNewIntent` method in your `MainActivity` class:

```csharp
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);

var data = intent.DataString;
Console.WriteLine($"Opened URL: {data}");
}
```
2 changes: 2 additions & 0 deletions doc/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@
href: features/windows-ui-startscreen.md
- name: App Close Handler
href: features/app-close-handler.md
- name: App Links
href: features/app-links.md
- name: App Suspension
href: features/windows-ui-xaml-application.md
- name: Application Data and Settings
Expand Down
Loading