Skip to content

Support activation with universal links #18005

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

Merged
merged 1 commit into from
Jan 22, 2025
Merged
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
13 changes: 13 additions & 0 deletions src/iOS/Avalonia.iOS/AvaloniaAppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ public bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
return false;
}

[Export("application:continueUserActivity:restorationHandler:")]
public bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
{
if (userActivity.ActivityType == NSUserActivityType.BrowsingWeb && Uri.TryCreate(userActivity.WebPageUrl?.ToString(), UriKind.RelativeOrAbsolute, out var uri))
{
// Activation using a univeral link or web browser-to-native app Handoff
_onActivated?.Invoke(this, new ProtocolActivatedEventArgs(uri));
return true;
}

return false;
}

private void OnEnteredBackground(NSNotification notification)
{
_onDeactivated?.Invoke(this, new ActivatedEventArgs(ActivationKind.Background));
Expand Down
Loading