r-plus / libcanopenurl

Stay away iOS 9+ canOpenURL: restriction.
MIT License
33 stars 3 forks source link

IPC to SpringBoard isn't needed #3

Open kirb opened 8 years ago

kirb commented 8 years ago

The restrictions are implemented within -[LSApplicationWorkspace isApplicationAvailableToOpenURL:error:], which otherwise just calls [LSApplicationWorkspace applicationsAvailableForHandlingURLScheme:] and returns YES if there's at least one result.

cy# [UIApp canOpenURL:[NSURL URLWithString:@"twitter:"]]
false
cy# [[LSApplicationWorkspace defaultWorkspace] applicationsAvailableForHandlingURLScheme:@"twitter"]
@[#"<LSApplicationProxy: 0x180cb1e0> com.atebits.Tweetie2"]
r-plus commented 8 years ago

oh nice. I'll change to that way directly in ActivityAction(I'm using this for it).

r-plus commented 8 years ago

BTW, runtime automatically link to MobileCoreServices.framework launch timing even if app developer not link to it?

kirb commented 8 years ago

UIKit links against MobileCoreServices:

$ otool -L ~/sdks/sim/iPhoneSimulator9.0.sdk/System/Library/Frameworks/UIKit.framework/UIKit | grep mobilecoreservices -
grep: warning: recursive search of stdin
(standard input):29:    /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices (compatibility version 1.0.0, current version 727.5.3)
r-plus commented 8 years ago

Wow gotcha! Thanks for quick reply.

malhal commented 8 years ago

Yep this package isn't needed, this worked for me inside my tweak:

@interface LSApplicationWorkspace
- (BOOL)isApplicationAvailableToOpenURL:(id)arg1 error:(id*)arg2;
@end

static IMP original_LSApplicationWorkspace_isApplicationAvailableToOpenURL_error;
static BOOL replaced_LSApplicationWorkspace_isApplicationAvailableToOpenURL_error(LSApplicationWorkspace* self, SEL sel, NSError** error){
    return YES; // allows all URLs.
}

...

    Class $LSApplicationWorkspace(objc_getClass("LSApplicationWorkspace"));
    MSHookMessageEx($LSApplicationWorkspace, @selector(isApplicationAvailableToOpenURL:error:), (IMP)replaced_LSApplicationWorkspace_isApplicationAvailableToOpenURL_error,& original_LSApplicationWorkspace_isApplicationAvailableToOpenURL_error);
kirb commented 6 years ago

This seems necessary on iOS 11 now. Pretty much all of LSApplicationWorkspace, LSApplicationProxy, etc. is restricted.

malhal commented 6 years ago

When they restrict something sometimes there is an entitlement that can enable it again.