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

[WIP] feat: Support for iOS SceneDelegate #19083

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
17 changes: 17 additions & 0 deletions src/SamplesApp/SamplesApp.netcoremobile/iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,22 @@
<string>Assets.xcassets/iconapp.appiconset</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>__UNOPLATFORM_DEFAULT_CONFIGURATION</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
22 changes: 10 additions & 12 deletions src/SamplesApp/SamplesApp.netcoremobile/iOS/Main.iOS.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
using UIKit;

namespace SamplesApp.iOS
namespace SamplesApp.iOS;

public class Application
{
public class Application
// This is the main entry point of the application.
static void Main(string[] args)
{
// This is the main entry point of the application.
static void Main(string[] args)
{
#if __IOS__ && !__MACCATALYST__ && !TESTFLIGHT && !DEBUG
// requires Xamarin Test Cloud Agent
Xamarin.Calabash.Start();
// requires Xamarin Test Cloud Agent
Xamarin.Calabash.Start();
#endif


// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(App));
}
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(App));
}
}
15 changes: 15 additions & 0 deletions src/SamplesApp/SamplesApp.netcoremobile/iOS/SceneDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.UI.Xaml;
using Foundation;
using UIKit;

namespace SamplesApp.iOS;

[Register("SceneDelegate")]
public class SceneDelegate : UnoSceneDelegate
{
}
6 changes: 6 additions & 0 deletions src/Uno.UI/UI/Xaml/Application.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
[Register("UnoAppDelegate")]
public partial class Application : UIApplicationDelegate
{
private const string UIApplicationSceneManifestKey = "UIApplicationSceneManifest";

private bool _preventSecondaryActivationHandling;

partial void InitializePartial()
Expand Down Expand Up @@ -142,6 +144,10 @@
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
public NSString GetWorkingFolder() => new NSString(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));

internal static bool HasSceneManifest() =>
(OperatingSystem.IsIOSVersionAtLeast(13, 0) || OperatingSystem.IsTvOSVersionAtLeast(13, 0)) &&

Check notice on line 148 in src/Uno.UI/UI/Xaml/Application.iOS.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Uno.UI/UI/Xaml/Application.iOS.cs#L148

Remove this default value assigned to parameter 'minor'.
NSBundle.MainBundle.InfoDictionary.ContainsKey(new NSString(UIApplicationSceneManifestKey));

private bool TryHandleUniversalLinkFromUserActivity(NSUserActivity userActivity)
{
// If the application was not running, universal link was already handled by FinishedLaunching
Expand Down
14 changes: 14 additions & 0 deletions src/Uno.UI/UI/Xaml/UnoSceneDelegate.iOS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Foundation;
using UIKit;

namespace Microsoft.UI.Xaml;

[Register(nameof(UnoSceneDelegate))]
public class UnoSceneDelegate : UISceneDelegate
{
}
Loading