From 9a81cd76b0931810b2007e02b0bfa3540b31906c Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Wed, 11 May 2022 16:06:39 -0300 Subject: [PATCH 1/2] feat: delay the launch event until the app becomes active --- packages/core/application/application.ios.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/application/application.ios.ts b/packages/core/application/application.ios.ts index 1a61b7a979..9d4239787d 100644 --- a/packages/core/application/application.ios.ts +++ b/packages/core/application/application.ios.ts @@ -77,6 +77,7 @@ export class iOSApplication extends ApplicationCommon implements IiOSApplication private _window: UIWindow; private _notificationObservers: NotificationObserver[] = []; private _rootView: View; + private launchEventCalled = false; displayedOnce = false; displayedLinkTarget: CADisplayLinkTarget; @@ -314,6 +315,7 @@ export class iOSApplication extends ApplicationCommon implements IiOSApplication } private notifyAppStarted(notification?: NSNotification) { + this.launchEventCalled = true; const root = this.notifyLaunch({ ios: notification?.userInfo?.objectForKey('UIApplicationLaunchOptionsLocalNotificationKey') ?? null, }); @@ -369,11 +371,14 @@ export class iOSApplication extends ApplicationCommon implements IiOSApplication // TODO: Expose Window module so that it can we styled from XML & CSS this._window.backgroundColor = Utils.ios.MajorVersion <= 12 || !UIColor.systemBackgroundColor ? UIColor.whiteColor : UIColor.systemBackgroundColor; - this.notifyAppStarted(notification); + this.launchEventCalled = false; } @profile private didBecomeActive(notification: NSNotification) { + if (!this.launchEventCalled) { + this.notifyAppStarted(notification); + } const additionalData = { ios: UIApplication.sharedApplication, }; From cab0b20e2889124e6d3cc2436e709ffc6d58b0d1 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Thu, 12 Mar 2026 01:01:32 -0300 Subject: [PATCH 2/2] feat(iOSApplication): add shouldDelayLaunchEvent flag to control launch timing --- packages/core/application/application.d.ts | 6 ++++++ packages/core/application/application.ios.ts | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/core/application/application.d.ts b/packages/core/application/application.d.ts index e5c2eec0c7..a305a88838 100644 --- a/packages/core/application/application.d.ts +++ b/packages/core/application/application.d.ts @@ -265,6 +265,12 @@ export class iOSApplication extends ApplicationCommon { * Get the current one or set a custom one. */ sceneDelegate: UIWindowSceneDelegate; + + /** + * Flag to be set when the launch event should be delayed until the application has become active. + * This is useful when you want to process notifications or data in the background without creating the UI. + */ + shouldDelayLaunchEvent: boolean; } export const VALID_FONT_SCALES: number[]; diff --git a/packages/core/application/application.ios.ts b/packages/core/application/application.ios.ts index 99a9e79bce..08f7ba1216 100644 --- a/packages/core/application/application.ios.ts +++ b/packages/core/application/application.ios.ts @@ -9,6 +9,7 @@ import { ios as iosUtils, dataSerialize } from '../utils/native-helper'; import { ApplicationCommon, initializeSdkVersionClass, SceneEvents } from './application-common'; import { ApplicationEventData, SceneEventData } from './application-interfaces'; import { Observable } from '../data/observable'; +import type { iOSApplication as IiOSApplication } from './application'; import { Trace } from '../trace'; import { AccessibilityServiceEnabledPropName, @@ -254,7 +255,7 @@ class SceneDelegate extends UIResponder implements UIWindowSceneDelegate { // ensure available globally global.SceneDelegate = SceneDelegate; -export class iOSApplication extends ApplicationCommon { +export class iOSApplication extends ApplicationCommon implements IiOSApplication { private _delegate: UIApplicationDelegate; private _delegateHandlers = new Map>(); private _rootView: View; @@ -270,6 +271,8 @@ export class iOSApplication extends ApplicationCommon { displayedLinkTarget: CADisplayLinkTarget; displayedLink: CADisplayLink; + shouldDelayLaunchEvent = false; + /** * @internal - should not be constructed by the user. */ @@ -694,6 +697,9 @@ export class iOSApplication extends ApplicationCommon { } this.launchEventCalled = false; + if (!this.shouldDelayLaunchEvent) { + this.notifyAppStarted(); + } } else { // Scene-based app - window creation will happen in scene delegate }