Skip to content

Commit

Permalink
maybe fixes this share flow (#27992)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnojima authored Sep 24, 2024
1 parent 661bf24 commit 3856667
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions shared/ios/KeybaseShare/ShareViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,32 @@ - (void)didReceiveMemoryWarning {
}

- (void) openApp {
NSURL * url = [NSURL URLWithString:@"keybase://incoming-share"];
NSURL *url = [NSURL URLWithString:@"keybase://incoming-share"];
UIResponder *responder = self;
while (responder){
if ([responder respondsToSelector: @selector(openURL:)]){
[responder performSelector: @selector(openURL:) withObject: url];
return;
}
responder = [responder nextResponder];
while (responder) {
if ([responder respondsToSelector: @selector(openURL:)]){
@try {
// This is needed by ios18+ to function now on the new xcode. This FAILs in the simulator but seems
// to work on device
NSMethodSignature *signature = [responder methodSignatureForSelector:@selector(openURL:options:completionHandler:)];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setTarget:responder];
[invocation setSelector:@selector(openURL:options:completionHandler:)];

NSDictionary *options = @{};
void (^completionHandler)(BOOL success) = nil;

[invocation setArgument:&url atIndex:2];
[invocation setArgument:&options atIndex:3];
[invocation setArgument:&completionHandler atIndex:4];
[invocation invoke];
return;
}
@catch (NSException *exception) {
NSLog(@"Exception occurred while opening URL to share");
}
}
responder = [responder nextResponder];
}
}

Expand Down

0 comments on commit 3856667

Please sign in to comment.