Skip to content

Commit

Permalink
allow other actions reach guest app
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeBlack committed Aug 24, 2024
1 parent ef77c1a commit 65557d2
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions TweakLoader/UIKit+GuestHooks.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

Expand Down

0 comments on commit 65557d2

Please sign in to comment.