Skip to content

Commit

Permalink
fix(ios): fix some open issues related to scenes (#14020)
Browse files Browse the repository at this point in the history
* fix(ios): fix “handleurl” event when using scenes

* fix(ios): fix log server from not being started on physical device
  • Loading branch information
hansemannn committed May 3, 2024
1 parent 9038a65 commit a0a3aea
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m
Expand Up @@ -324,7 +324,20 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}

// Handle URL-schemes / iOS >= 9
- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts
{
UIOpenURLContext *primaryContext = URLContexts.allObjects.firstObject;

NSDictionary<UIApplicationOpenURLOptionsKey, id> *options = @{
UIApplicationOpenURLOptionsSourceApplicationKey : NULL_IF_NIL(primaryContext.options.sourceApplication)
};

[self application:[UIApplication sharedApplication] openURL:primaryContext.URL options:options];
}

// Handle URL-schemes. Note that this selector is not called automatically anymore in iOS 13+
// because of the scene management. Instead, the above "scene:openURLContexts:" selector is called
// that forwards the call for maximum backwards compatibility
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *)options
{
[self tryToInvokeSelector:@selector(application:openURL:options:)
Expand Down Expand Up @@ -1185,12 +1198,20 @@ - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session op
[self tryToInvokeSelector:@selector(scene:willConnectToSession:options:)
withArguments:[NSOrderedSet orderedSetWithObjects:scene, connectionOptions, nil]];

// If a "application-launch-url" is set, launch it directly
[self launchToUrl];
// Catch exceptions
[TiExceptionHandler defaultExceptionHandler];

// Enable device logs (e.g. for physical devices)
if ([[TiSharedConfig defaultConfig] logServerEnabled]) {
[[TiLogServer defaultLogServer] start];
}

// Initialize the root-controller
[self initController];

// If a "application-launch-url" is set, launch it directly
[self launchToUrl];

// Boot our kroll-core
[self boot];

Expand Down

0 comments on commit a0a3aea

Please sign in to comment.