Skip to content

Commit

Permalink
Fix iOS 13 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaime Fernandez committed Oct 11, 2019
1 parent c307f25 commit b3a2507
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/ios/ShareExtension/ShareViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,37 @@ - (void) openURL:(nonnull NSURL *)url {

UIResponder* responder = self;
while ((responder = [responder nextResponder]) != nil) {

NSLog(@"responder = %@", responder);
if([responder respondsToSelector:selector] == true) {
NSMethodSignature *methodSignature = [responder methodSignatureForSelector:selector];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature];

// Arguments
NSDictionary<NSString *, id> *options = [NSDictionary dictionary];
void (^completion)(BOOL success) = ^void(BOOL success) {};

[invocation setTarget: responder];
[invocation setSelector: selector];
[invocation setArgument: &url atIndex: 2];
[invocation setArgument: &options atIndex:3];
[invocation setArgument: &completion atIndex: 4];
[invocation invoke];
break;
void (^completion)(BOOL success) = ^void(BOOL success) {
NSLog(@"Completions block: %i", success);
};
if (@available(iOS 13.0, *)) {
UISceneOpenExternalURLOptions * options = [[UISceneOpenExternalURLOptions alloc] init];
options.universalLinksOnly = false;

[invocation setTarget: responder];
[invocation setSelector: selector];
[invocation setArgument: &url atIndex: 2];
[invocation setArgument: &options atIndex:3];
[invocation setArgument: &completion atIndex: 4];
[invocation invoke];
break;
} else {
NSDictionary<NSString *, id> *options = [NSDictionary dictionary];

[invocation setTarget: responder];
[invocation setSelector: selector];
[invocation setArgument: &url atIndex: 2];
[invocation setArgument: &options atIndex:3];
[invocation setArgument: &completion atIndex: 4];
[invocation invoke];
break;
}
}
}
}
Expand Down

0 comments on commit b3a2507

Please sign in to comment.