|
62 | 62 | NSString static *const kYTPlayerStaticProxyRegexPattern = @"^https://content.googleapis.com/static/proxy.html(.*)$"; |
63 | 63 | NSString static *const kYTPlayerSyndicationRegexPattern = @"^https://tpc.googlesyndication.com/sodar/(.*).html$"; |
64 | 64 |
|
65 | | -@interface YTPlayerView() <WKNavigationDelegate> |
| 65 | +@interface YTPlayerView() <WKNavigationDelegate, WKUIDelegate> |
66 | 66 |
|
67 | 67 | @property (nonatomic) NSURL *originURL; |
68 | 68 | @property (nonatomic, weak) UIView *initialLoadingView; |
@@ -540,6 +540,20 @@ - (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigatio |
540 | 540 | } |
541 | 541 | } |
542 | 542 |
|
| 543 | +#pragma mark - WKUIDelegate |
| 544 | + |
| 545 | +- (WKWebView *)webView:(WKWebView *)webView |
| 546 | +createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration |
| 547 | + forNavigationAction:(WKNavigationAction *)navigationAction |
| 548 | + windowFeatures:(WKWindowFeatures *)windowFeatures { |
| 549 | + // Handle navigation actions initiated by Javascript. |
| 550 | + [[UIApplication sharedApplication] openURL:navigationAction.request.URL |
| 551 | + options:@{} |
| 552 | + completionHandler:nil]; |
| 553 | + // Returning nil results in canceling the navigation, which has already been handled above. |
| 554 | + return nil; |
| 555 | +} |
| 556 | + |
543 | 557 | #pragma mark - Private methods |
544 | 558 |
|
545 | 559 | - (NSURL *)originURL { |
@@ -770,6 +784,7 @@ - (BOOL)loadWithPlayerParams:(NSDictionary *)additionalPlayerParams { |
770 | 784 |
|
771 | 785 | [self.webView loadHTMLString:embedHTML baseURL: self.originURL]; |
772 | 786 | self.webView.navigationDelegate = self; |
| 787 | + self.webView.UIDelegate = self; |
773 | 788 |
|
774 | 789 | if ([self.delegate respondsToSelector:@selector(playerViewPreferredInitialLoadingView:)]) { |
775 | 790 | UIView *initialLoadingView = [self.delegate playerViewPreferredInitialLoadingView:self]; |
|
0 commit comments