diff --git a/README.md b/README.md index 2a1fc4d..d5e6e75 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,10 @@ On jailbroken iOS 14 when TrollHelper is used for installation, it is located in ## URL Scheme -As of version 1.3, TrollStore replaces the system URL scheme "apple-magnifier" (this is done so "jailbreak" detections can't detect TrollStore like they could if TrollStore had a unique URL scheme). This URL scheme can be used to install applications right from the browser, the format goes as follows: +As of version 1.3, TrollStore replaces the system URL scheme "apple-magnifier" (this is done so "jailbreak" detections can't detect TrollStore like they could if TrollStore had a unique URL scheme). This URL scheme can be used to install applications right from the browser, or to enable JIT from the app itself, the format goes as follows: -`apple-magnifier://install?url=` +- `apple-magnifier://install?url=` +- `apple-magnifier://enable-jit?bundle-id=` On devices that don't have TrollStore (1.3+) installed, this will just open the magnifier app. diff --git a/TrollStore/TSSceneDelegate.m b/TrollStore/TSSceneDelegate.m index f4b242b..b5090fa 100644 --- a/TrollStore/TSSceneDelegate.m +++ b/TrollStore/TSSceneDelegate.m @@ -1,6 +1,7 @@ #import "TSSceneDelegate.h" #import "TSRootViewController.h" #import "TSUtil.h" +#import "TSApplicationsManager.h" #import "TSInstallationController.h" #import @@ -67,11 +68,64 @@ [TSInstallationController handleAppInstallFromRemoteURL:URLToInstall completion:nil]; } } + else if([components.host isEqualToString:@"enable-jit"]) + { + NSString* BundleIDToEnableJIT; + + for(NSURLQueryItem* queryItem in components.queryItems) + { + if([queryItem.name isEqualToString:@"bundle-id"]) + { + BundleIDToEnableJIT = queryItem.value; + break; + } + } + + if(BundleIDToEnableJIT && [BundleIDToEnableJIT isKindOfClass:NSString.class]) + { + dispatch_async(dispatch_get_main_queue(), ^ + { + [self handleEnableJITForBundleID:BundleIDToEnableJIT]; + }); + } + } } } } } +- (void)handleEnableJITForBundleID:(NSString *)appId +{ + TSApplicationsManager* appsManager = [TSApplicationsManager sharedInstance]; + + BOOL didOpen = [appsManager openApplicationWithBundleID:appId]; + + // if we failed to open the app, show an alert + if(!didOpen) + { + NSString* failMessage = @""; + // we don't have TSAppInfo here so we cannot check the registration state + + NSString* failTitle = [NSString stringWithFormat:@"Failed to open %@", appId]; + UIAlertController* didFailController = [UIAlertController alertControllerWithTitle:failTitle message:failMessage preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; + + [didFailController addAction:cancelAction]; + [TSPresentationDelegate presentViewController:didFailController animated:YES completion:nil]; + } + else + { + int ret = [appsManager enableJITForBundleID:appId]; + if (ret != 0) + { + UIAlertController* errorAlert = [UIAlertController alertControllerWithTitle:@"Error" message:[NSString stringWithFormat:@"Error enabling JIT: trollstorehelper returned %d", ret] preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction* closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:nil]; + [errorAlert addAction:closeAction]; + [TSPresentationDelegate presentViewController:errorAlert animated:YES completion:nil]; + } + } +} + // We want to auto install ldid if either it doesn't exist // or if it's the one from an old TrollStore version that's no longer supported - (void)handleLdidCheck diff --git a/TrollStore/TSSettingsListController.m b/TrollStore/TSSettingsListController.m index f9b9119..61976cc 100644 --- a/TrollStore/TSSettingsListController.m +++ b/TrollStore/TSSettingsListController.m @@ -291,7 +291,7 @@ extern NSUserDefaults* trollStoreUserDefaults(void); PSSpecifier* installationSettingsGroupSpecifier = [PSSpecifier emptyGroupSpecifier]; installationSettingsGroupSpecifier.name = @"Security"; - [installationSettingsGroupSpecifier setProperty:@"The URL Scheme, when enabled, will allow apps and websites to trigger TrollStore installations through the apple-magnifier://install?url= URL scheme." forKey:@"footerText"]; + [installationSettingsGroupSpecifier setProperty:@"The URL Scheme, when enabled, will allow apps and websites to trigger TrollStore installations through the apple-magnifier://install?url= URL scheme and enable JIT through the apple-magnifier://enable-jit?bundle-id= URL scheme." forKey:@"footerText"]; [_specifiers addObject:installationSettingsGroupSpecifier];