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

fix: Deprecated iOS Launcher methods #18632

Merged
merged 2 commits into from
Nov 8, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private void OpenUrl(string url)
var nsUrl = new NSUrl(url);
//Opens the specified URL, launching the app that's registered to handle the scheme.
#if __IOS__
UIApplication.SharedApplication.OpenUrl(nsUrl);
Task.Run(() => UIApplication.SharedApplication.OpenUrlAsync(nsUrl, new UIApplicationOpenUrlOptions()));
jeromelaban marked this conversation as resolved.
Show resolved Hide resolved
#else
NSWorkspace.SharedWorkspace.OpenUrl(nsUrl);
#endif
Expand Down
6 changes: 2 additions & 4 deletions src/Uno.UWP/ApplicationModel/Calls/PhoneCallManager.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CallKit;
using Foundation;
using UIKit;
Expand Down Expand Up @@ -37,10 +38,7 @@ static PhoneCallManager()
internal static void RaiseCallStateChanged() => CallStateChanged?.Invoke(null, null);

private static void ShowPhoneCallUIImpl(string phoneNumber, string displayName)
{
var url = new NSUrl($"tel:{phoneNumber}");
UIApplication.SharedApplication.OpenUrl(url);
}
=> Task.Run(() => UIApplication.SharedApplication.OpenUrlAsync(new NSUrl($"tel:{phoneNumber}"), new UIApplicationOpenUrlOptions()));

}
}
11 changes: 6 additions & 5 deletions src/Uno.UWP/System/Launcher.iOS.SpecialUris.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ private static bool CanHandleSpecialUri(Uri uri)
}
}

private static bool HandleSpecialUri(Uri uri)
private static async Task<bool> HandleSpecialUri(Uri uri)
{
switch (uri.Scheme.ToLowerInvariant())
{
case MicrosoftSettingsUri: return HandleSettingsUri(uri);
case MicrosoftSettingsUri: return await HandleSettingsUri(uri);
default: throw new InvalidOperationException("This special URI is not supported on iOS");
}
}

private static bool HandleSettingsUri(Uri uri) =>
UIApplication.SharedApplication.OpenUrl(
new NSUrl(UIApplication.OpenSettingsUrlString));
private static async Task<bool> HandleSettingsUri(Uri uri) =>
await UIApplication.SharedApplication.OpenUrlAsync(
new NSUrl(UIApplication.OpenSettingsUrlString),
new UIApplicationOpenUrlOptions());
}
}
#endif
13 changes: 10 additions & 3 deletions src/Uno.UWP/System/Launcher.iOSmacOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,24 @@ namespace Windows.System
{
public static partial class Launcher
{
public static Task<bool> LaunchUriPlatformAsync(Uri uri)
public static
#if __IOS__
async
#endif
Task<bool> LaunchUriPlatformAsync(Uri uri)
{
if (IsSpecialUri(uri) && CanHandleSpecialUri(uri))
{
#if __IOS__
return await HandleSpecialUri(uri);
#else
return Task.FromResult(HandleSpecialUri(uri));
#endif
}

var appleUrl = new AppleUrl(uri.OriginalString);
#if __IOS__
return Task.FromResult(UIApplication.SharedApplication.OpenUrl(
appleUrl));
return await UIApplication.SharedApplication.OpenUrlAsync(appleUrl, new UIApplicationOpenUrlOptions());
#else
return Task.FromResult(NSWorkspace.SharedWorkspace.OpenUrl(
appleUrl));
Expand Down
Loading