Skip to content
Open
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
6 changes: 6 additions & 0 deletions packages/core/application/application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
15 changes: 13 additions & 2 deletions packages/core/application/application.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -254,10 +255,11 @@ 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<string, Array<Function>>();
private _rootView: View;
private launchEventCalled = false;
private _sceneDelegate: UIWindowSceneDelegate;
private _windowSceneMap = new Map<UIScene, UIWindow>();
private _primaryScene: UIWindowScene | null = null;
Expand All @@ -269,6 +271,8 @@ export class iOSApplication extends ApplicationCommon {
displayedLinkTarget: CADisplayLinkTarget;
displayedLink: CADisplayLink;

shouldDelayLaunchEvent = false;

/**
* @internal - should not be constructed by the user.
*/
Expand Down Expand Up @@ -583,6 +587,7 @@ export class iOSApplication extends ApplicationCommon {
}

private notifyAppStarted(notification?: NSNotification) {
this.launchEventCalled = true;
const root = this.notifyLaunch({
ios: notification?.userInfo?.objectForKey('UIApplicationLaunchOptionsLocalNotificationKey') ?? null,
});
Expand Down Expand Up @@ -691,14 +696,20 @@ export class iOSApplication extends ApplicationCommon {
this.window.backgroundColor = SDK_VERSION <= 12 || !UIColor.systemBackgroundColor ? UIColor.whiteColor : UIColor.systemBackgroundColor;
}

this.notifyAppStarted(notification);
this.launchEventCalled = false;
if (!this.shouldDelayLaunchEvent) {
this.notifyAppStarted();
}
} else {
// Scene-based app - window creation will happen in scene delegate
}
}

@profile
private didBecomeActive(notification: NSNotification) {
if (!this.launchEventCalled) {
this.notifyAppStarted(notification);
}
const additionalData = {
ios: UIApplication.sharedApplication,
};
Expand Down
Loading