libcanopenurl icon indicating copy to clipboard operation
libcanopenurl copied to clipboard

IPC to SpringBoard isn't needed

Open kirb opened this issue 10 years ago • 7 comments

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"]

kirb avatar Nov 01 '15 05:11 kirb

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

r-plus avatar Nov 01 '15 15:11 r-plus

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

r-plus avatar Nov 15 '15 02:11 r-plus

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)

kirb avatar Nov 15 '15 02:11 kirb

Wow gotcha! Thanks for quick reply.

r-plus avatar Nov 15 '15 03:11 r-plus

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);

malhal avatar Apr 29 '16 23:04 malhal

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

kirb avatar Jan 19 '18 03:01 kirb

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

malhal avatar Jan 19 '18 10:01 malhal