feat(ios): multi-window support#10786
Conversation
|
View your CI Pipeline Execution ↗ for commit cbb075d
☁️ Nx Cloud last updated this comment at |
…t/multi-window-support
| * Additional user info from the notification. | ||
| */ | ||
| userInfo?: NSDictionary<any, any>; | ||
| } |
There was a problem hiding this comment.
We can likely embed ios|android keys within this interface for specific platform details and provide userInfo as a data property for both already deserialized.
There was a problem hiding this comment.
Pull Request Overview
This PR adds iOS multi-window and scene lifecycle support to NativeScript, enabling apps to manage multiple windows on iPadOS 13+ and handle scene-based lifecycle events. This is a significant enhancement for iPad apps that want to support modern iPadOS multitasking features.
- Implements UIWindowScene delegate and scene lifecycle management
- Adds API for opening and managing multiple windows with scene activation
- Provides demo application showing multi-scene functionality
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/assets/App_Resources/iOS/Info.plist | Added UIApplicationSceneManifest configuration to enable scene support and fixed indentation |
| packages/webpack5/src/configuration/base.ts | Fixed code formatting (quote style and spacing) |
| packages/core/vitest.setup.ts | Added NSBundle and UIWindowSceneDelegate mocks for testing scene functionality |
| packages/core/ui/styling/css-stroke.ts | Added Length import (appears unused) |
| packages/core/package.json | Bumped version to 9.0.0-alpha.13 |
| packages/core/application/application.ios.ts | Implemented scene delegate, scene lifecycle management, and multi-window APIs |
| packages/core/application/application.d.ts | Added TypeScript definitions for scene management APIs |
| packages/core/application/application-interfaces.ts | Added SceneEventData interface for scene lifecycle events |
| packages/core/application/application-common.ts | Added SceneEvents constants for scene lifecycle event names |
| apps/toolbox/src/pages/multiple-scenes.xml | Added demo UI for testing multi-scene functionality |
| apps/toolbox/src/pages/multiple-scenes.ts | Implemented demo logic for creating and managing scenes |
| apps/toolbox/src/main.ts | Added SceneEvents import (appears unused) |
| apps/toolbox/src/main-page.xml | Added navigation button to multiple-scenes demo |
| apps/toolbox/src/main-page.ts | Added commented-out scene event setup code for testing |
| apps/toolbox/src/app.css | Added CSS styles for multiple scenes demo UI |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What is the current behavior?
For several years, since iOS 13, a developer could manually wire up a SceneDelegate, modify plist properties and achieve multi scene support.
What is the new behavior?
With iOS 26 making multi-window support even nicer, this finally brings a powerful yet simple API to develop multi-window apps on iPadOS and beyond.
✅ Fully backwards compatible so maintains current behavior by default.
Scene lifecycle will only engage once
UIApplicationSceneManifestis added to Info.plist, for example:When a configuration like this is detected, the app will auto switch to scene lifecycle.
Multi-Window Scene Support for NativeScript iOS
Overview
This implementation provides full support for iOS 13+ scene-based applications while maintaining backwards compatibility with traditional single-window apps.
🔧 Core Changes
1. New SceneDelegate Class
A new
@NativeClass SceneDelegatehas been created that implementsUIWindowSceneDelegate.It is only activated when
UIApplicationSceneManifestconfiguration is present in Info.plist.sceneWillConnectToSessionOptions- Creates UIWindow and sets up scenesceneDidBecomeActive- Handles scene activationsceneWillResignActive- Handles scene deactivationsceneWillEnterForeground- Scene foreground transitionsceneDidEnterBackground- Scene background transitionsceneDidDisconnect- Scene cleanup2. Enhanced iOSApplication
The
iOSApplicationclass has been significantly enhanced with scene management capabilities:New Methods
supportsScenes(): Checks if device supports scenessupportsMultipleScenes(): Checks if the application supports multiple scenes (only available on physical iPadOS)getAllWindows(): Returns all app windowsgetAllScenes(): Returns all scenesgetWindowScenes(): Returns window scenes specificallygetPrimaryWindow(): Returns the primary windowgetPrimaryScene(): Returns primary sceneisUsingSceneLifecycle(): Checks if using scene-based lifecyclesetWindowRootView(window: UIWindow, view: View): Sets the root view for a specific window.3. Scene Event Support
New Interface: SceneEventData
Scene Event Constants
4. Scene Lifecycle Notification Observers
The application automatically registers for scene lifecycle notifications on iOS 13+ if the app has detected a scene manifest:
UISceneWillConnectNotificationUISceneDidActivateNotificationUISceneWillEnterForegroundNotificationUISceneDidEnterBackgroundNotificationUISceneDidDisconnectNotification🚀 Usage Examples
Basic Scene Event Listening
Multi-Window Management
Scene-Specific UI Management
📋 Key Features
1. Multi-Window Management
2. Scene Lifecycle Events
3. Backwards Compatibility
4. Type Safety
5. Custom Scene Delegates
🔍 Technical Implementation Details
Scene Detection and Setup
SDK_VERSION >= 13UIApplication.sharedApplication.supportsMultipleScenesWindow Management
Map<UIScene, UIWindow>for efficient scene-to-window mappingUIWindowinstances for eachUIWindowSceneEvent Forwarding
Memory Management
Error Handling
🔄 Migration Path?
For Existing Apps
No changes required - existing single-window apps will continue to work exactly as before.
For New Multi-Window Apps
Info.plistSceneEventsconstants