Skip to content

Commit

Permalink
Fix extension crash on iOS 13 (#69)
Browse files Browse the repository at this point in the history
* Fix extension crash on iOS 13

* Fix UISceneOpenExternalURLOptions init

* iOS 13 version check
  • Loading branch information
NiklasMerz authored Dec 31, 2019
1 parent c301c51 commit a914317
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/ios/ShareExtension/ShareViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,31 @@ - (void) openURL:(nonnull NSURL *)url {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:methodSignature];

// Arguments
NSDictionary<NSString *, id> *options = [NSDictionary dictionary];
void (^completion)(BOOL success) = ^void(BOOL success) {
NSLog(@"Completions block: %i", 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;
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 a914317

Please sign in to comment.