From 65557d2276ba69fcd3178dcf53a634a23fc7e9b7 Mon Sep 17 00:00:00 2001 From: Huge_Black Date: Sat, 24 Aug 2024 21:48:24 +0800 Subject: [PATCH] allow other actions reach guest app --- TweakLoader/UIKit+GuestHooks.m | 39 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/TweakLoader/UIKit+GuestHooks.m b/TweakLoader/UIKit+GuestHooks.m index 7fd1875..56954e5 100644 --- a/TweakLoader/UIKit+GuestHooks.m +++ b/TweakLoader/UIKit+GuestHooks.m @@ -120,37 +120,38 @@ - (void)hook_scene:(id)scene didReceiveActions:(NSSet *)actions fromTransitionCo NSString *url = urlAction.url.absoluteString; if ([url hasPrefix:@"livecontainer://livecontainer-relaunch"]) { // Ignore - return; + } else if ([url hasPrefix:@"livecontainer://open-web-page?"]) { NSURLComponents* lcUrl = [NSURLComponents componentsWithString:url]; NSString* realUrlEncoded = lcUrl.queryItems[0].value; - if(!realUrlEncoded) return; - // launch to UI and open web page - NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:realUrlEncoded options:0]; - NSString *decodedUrl = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding]; - LCOpenWebPage(decodedUrl); - return; + if(realUrlEncoded) { + // launch to UI and open web page + NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:realUrlEncoded options:0]; + NSString *decodedUrl = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding]; + LCOpenWebPage(decodedUrl); + } + } else if ([url hasPrefix:@"livecontainer://open-url?"]) { // Open guest app's URL scheme NSURLComponents* lcUrl = [NSURLComponents componentsWithString:url]; NSString* realUrlEncoded = lcUrl.queryItems[0].value; - if(!realUrlEncoded) return; - // Convert the base64 encoded url into String - NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:realUrlEncoded options:0]; - NSString *decodedUrl = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding]; - - NSMutableSet *newActions = actions.mutableCopy; - [newActions removeObject:urlAction]; - UIOpenURLAction *newUrlAction = [[UIOpenURLAction alloc] initWithURL:[NSURL URLWithString:decodedUrl]]; - [newActions addObject:newUrlAction]; - [self hook_scene:scene didReceiveActions:newActions fromTransitionContext:context]; - return; + if(realUrlEncoded) { + // Convert the base64 encoded url into String + NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:realUrlEncoded options:0]; + NSString *decodedUrl = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding]; + + NSMutableSet *newActions = actions.mutableCopy; + [newActions removeObject:urlAction]; + UIOpenURLAction *newUrlAction = [[UIOpenURLAction alloc] initWithURL:[NSURL URLWithString:decodedUrl]]; + [newActions addObject:newUrlAction]; + [self hook_scene:scene didReceiveActions:newActions fromTransitionContext:context]; + return; + } } else if ([url hasPrefix:@"livecontainer://livecontainer-launch?"]){ // If it's not current app, then switch if (![url hasSuffix:NSBundle.mainBundle.bundlePath.lastPathComponent]) { LCShowSwitchAppConfirmation(urlAction.url); } - return; }