From 7a91221926afbc57ff35c5c9fb64f2f2e4b97534 Mon Sep 17 00:00:00 2001 From: TMomemt <42024947+TMomemt@users.noreply.github.com> Date: Tue, 23 Apr 2019 17:16:04 +0800 Subject: [PATCH 01/10] fix(WKWebView): iOS crash when WebView's title is nil (#521) --- ios/RNCWKWebView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RNCWKWebView.m b/ios/RNCWKWebView.m index 2e5ad05..a1fa7d8 100644 --- a/ios/RNCWKWebView.m +++ b/ios/RNCWKWebView.m @@ -460,7 +460,7 @@ static NSURLCredential* clientAuthenticationCredential; { NSDictionary *event = @{ @"url": _webView.URL.absoluteString ?: @"", - @"title": _webView.title, + @"title": _webView.title ?: @"", @"loading" : @(_webView.loading), @"canGoBack": @(_webView.canGoBack), @"canGoForward" : @(_webView.canGoForward) From 4894e4836d413b66c26e0a1f97edaab415177833 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 23 Apr 2019 09:17:41 +0000 Subject: [PATCH 02/10] chore(release): 5.7.1 [skip ci] ## [5.7.1](https://github.com/react-native-community/react-native-webview/compare/v5.7.0...v5.7.1) (2019-04-23) ### Bug Fixes * **WKWebView:** iOS crash when WebView's title is nil ([#521](https://github.com/react-native-community/react-native-webview/issues/521)) ([7a91221](https://github.com/react-native-community/react-native-webview/commit/7a91221)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d0be3dd..e6a59b6 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "Thibault Malbranche " ], "license": "MIT", - "version": "5.7.0", + "version": "5.7.1", "homepage": "https://github.com/react-native-community/react-native-webview#readme", "scripts": { "ci": "CI=true && yarn lint && yarn test", From 737f8b4741d831c97d58ccfdab6d4d7d6e8ca5f8 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" Date: Tue, 23 Apr 2019 11:20:21 +0200 Subject: [PATCH 03/10] chore(docs): add TMomemt as a contributor (#522) * docs: update README.md * docs: update .all-contributorsrc --- .all-contributorsrc | 9 +++++++++ README.md | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index f9be3b8..3e74250 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -150,6 +150,15 @@ "contributions": [ "doc" ] + }, + { + "login": "TMomemt", + "name": "TMomemt", + "avatar_url": "https://avatars3.githubusercontent.com/u/42024947?v=4", + "profile": "https://github.com/TMomemt", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7 diff --git a/README.md b/README.md index b891adb..a50dba0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # React Native WebView - a Modern, Cross-Platform WebView for React Native -[![star this repo](http://githubbadges.com/star.svg?user=react-native-community&repo=react-native-webview&style=flat)](https://github.com/react-native-community/react-native-webview) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors) [![Known Vulnerabilities](https://snyk.io/test/github/react-native-community/react-native-webview/badge.svg?style=flat-square)](https://snyk.io/test/github/react-native-community/react-native-webview)![version](https://img.shields.io/npm/v/react-native-webview.svg) +[![star this repo](http://githubbadges.com/star.svg?user=react-native-community&repo=react-native-webview&style=flat)](https://github.com/react-native-community/react-native-webview) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors) [![Known Vulnerabilities](https://snyk.io/test/github/react-native-community/react-native-webview/badge.svg?style=flat-square)](https://snyk.io/test/github/react-native-community/react-native-webview)![version](https://img.shields.io/npm/v/react-native-webview.svg) **React Native WebView** is a modern, well-supported, and cross-platform WebView for React Native. It is intended to be a replacement for the built-in WebView (which will be [removed from core](https://github.com/react-native-community/discussions-and-proposals/pull/3)). @@ -77,7 +77,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/all-contri -
Thibault Malbranche
Thibault Malbranche

💻 🤔 👀 📖 🚧 ⚠️ 🚇 💬
Jamon Holmgren
Jamon Holmgren

💻 🤔 👀 📖 🚧 ⚠️ 💡 💬
Andrei Pfeiffer
Andrei Pfeiffer

💻 👀 🤔
Michael Diarmid
Michael Diarmid

💻 👀 🤔 🔧
Scott Mathson
Scott Mathson

💻 📖
Margaret
Margaret

💻 📖
Jordan Sexton
Jordan Sexton

💻 📖
Malcolm Scruggs
Malcolm Scruggs

💻 🔧 ⚠️
Momazo7u7
Momazo7u7

📖
Marco
Marco

📖
Julien Eluard
Julien Eluard

📖
Jian Wei
Jian Wei

💻 📖
Sergei Butko
Sergei Butko

📖
+
Thibault Malbranche
Thibault Malbranche

💻 🤔 👀 📖 🚧 ⚠️ 🚇 💬
Jamon Holmgren
Jamon Holmgren

💻 🤔 👀 📖 🚧 ⚠️ 💡 💬
Andrei Pfeiffer
Andrei Pfeiffer

💻 👀 🤔
Michael Diarmid
Michael Diarmid

💻 👀 🤔 🔧
Scott Mathson
Scott Mathson

💻 📖
Margaret
Margaret

💻 📖
Jordan Sexton
Jordan Sexton

💻 📖
Malcolm Scruggs
Malcolm Scruggs

💻 🔧 ⚠️
Momazo7u7
Momazo7u7

📖
Marco
Marco

📖
Julien Eluard
Julien Eluard

📖
Jian Wei
Jian Wei

💻 📖
Sergei Butko
Sergei Butko

📖
TMomemt
TMomemt

💻
From 5892601c290a83b3c23533c2c7f7b0872986dce9 Mon Sep 17 00:00:00 2001 From: manuelblum Date: Mon, 29 Apr 2019 09:45:15 +0200 Subject: [PATCH 04/10] fix(types): wrong parameter type in onLoadProgress (#538) WebViewProgressEvent musst be wrapped within NativeSyntheticEvent --- src/WebViewTypes.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/WebViewTypes.ts b/src/WebViewTypes.ts index 5b16b0c..3ae5f9d 100644 --- a/src/WebViewTypes.ts +++ b/src/WebViewTypes.ts @@ -91,7 +91,7 @@ export interface WebViewNativeEvent { lockIdentifier: number; } -export interface WebViewProgressEvent extends WebViewNativeEvent { +export interface WebViewNativeProgressEvent extends WebViewNativeEvent { progress: number; } @@ -122,6 +122,8 @@ export interface WebViewError extends WebViewNativeEvent { export type WebViewEvent = NativeSyntheticEvent; +export type WebViewProgressEvent = NativeSyntheticEvent; + export type WebViewNavigationEvent = NativeSyntheticEvent; export type WebViewMessageEvent = NativeSyntheticEvent; From c297e320d2797a135d1e050f75abb99b4dd65c30 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 29 Apr 2019 07:47:53 +0000 Subject: [PATCH 05/10] chore(release): 5.7.2 [skip ci] ## [5.7.2](https://github.com/react-native-community/react-native-webview/compare/v5.7.1...v5.7.2) (2019-04-29) ### Bug Fixes * **types:** wrong parameter type in onLoadProgress ([#538](https://github.com/react-native-community/react-native-webview/issues/538)) ([5892601](https://github.com/react-native-community/react-native-webview/commit/5892601)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e6a59b6..df18962 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "Thibault Malbranche " ], "license": "MIT", - "version": "5.7.1", + "version": "5.7.2", "homepage": "https://github.com/react-native-community/react-native-webview#readme", "scripts": { "ci": "CI=true && yarn lint && yarn test", From 455c30e00078cb19bdae4c7a649f86d4cbb0b9e0 Mon Sep 17 00:00:00 2001 From: Eric Lewis Date: Mon, 29 Apr 2019 11:46:07 -0400 Subject: [PATCH 06/10] feat(WKWebView): Allow focus without user interaction (#540) * [iOS] Allow focus without user interaction * Add documentation for keyboardDisplayRequiresUserAction * set keyboardDisplayRequiresUserAction default to true --- docs/Reference.md | 11 +++++++ ios/RNCWKWebView.h | 1 + ios/RNCWKWebView.m | 61 +++++++++++++++++++++++++++++++++++++++ ios/RNCWKWebViewManager.m | 4 +++ src/WebViewTypes.ts | 12 ++++++++ 5 files changed, 89 insertions(+) diff --git a/docs/Reference.md b/docs/Reference.md index e3ece1b..b5f0ef3 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -42,6 +42,7 @@ This document lays out the current public properties and methods for the React N - [`useWebKit`](Reference.md#usewebkit) - [`url`](Reference.md#url) - [`html`](Reference.md#html) +- [`keyboardDisplayRequiresUserAction`](Reference.md#keyboardDisplayRequiresUserAction) - [`hideKeyboardAccessoryView`](Reference.md#hidekeyboardaccessoryview) - [`allowsBackForwardNavigationGestures`](Reference.md#allowsbackforwardnavigationgestures) - [`incognito`](Reference.md#incognito) @@ -756,6 +757,16 @@ If true, use WKWebView instead of UIWebView. --- +### `keyboardDisplayRequiresUserAction` + +If false, web content can programmatically display the keyboard when using the WKWebView. The default value is `true`. + +| Type | Required | Platform | +| ------- | -------- | -------- | +| boolean | No | iOS | + +--- + ### `hideKeyboardAccessoryView` If true, this will hide the keyboard accessory view (< > and Done) when using the WKWebView. diff --git a/ios/RNCWKWebView.h b/ios/RNCWKWebView.h index 7cea86b..1b61c28 100644 --- a/ios/RNCWKWebView.h +++ b/ios/RNCWKWebView.h @@ -37,6 +37,7 @@ #endif @property (nonatomic, assign) UIEdgeInsets contentInset; @property (nonatomic, assign) BOOL automaticallyAdjustContentInsets; +@property (nonatomic, assign) BOOL keyboardDisplayRequiresUserAction; @property (nonatomic, assign) BOOL hideKeyboardAccessoryView; @property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures; @property (nonatomic, assign) BOOL incognito; diff --git a/ios/RNCWKWebView.m b/ios/RNCWKWebView.m index a1fa7d8..c152d5b 100644 --- a/ios/RNCWKWebView.m +++ b/ios/RNCWKWebView.m @@ -41,6 +41,7 @@ static NSURLCredential* clientAuthenticationCredential; { UIColor * _savedBackgroundColor; BOOL _savedHideKeyboardAccessoryView; + BOOL _savedKeyboardDisplayRequiresUserAction; } - (instancetype)initWithFrame:(CGRect)frame @@ -54,6 +55,7 @@ static NSURLCredential* clientAuthenticationCredential; _directionalLockEnabled = YES; _automaticallyAdjustContentInsets = YES; _contentInset = UIEdgeInsetsZero; + _savedKeyboardDisplayRequiresUserAction = YES; } // Workaround for a keyboard dismissal bug present in iOS 12 @@ -214,6 +216,7 @@ static NSURLCredential* clientAuthenticationCredential; [self addSubview:_webView]; [self setHideKeyboardAccessoryView: _savedHideKeyboardAccessoryView]; + [self setKeyboardDisplayRequiresUserAction: _savedKeyboardDisplayRequiresUserAction]; [self visitSource]; } } @@ -364,6 +367,64 @@ static NSURLCredential* clientAuthenticationCredential; } } +-(void)setKeyboardDisplayRequiresUserAction:(BOOL)keyboardDisplayRequiresUserAction +{ + if (_webView == nil) { + _savedKeyboardDisplayRequiresUserAction = keyboardDisplayRequiresUserAction; + return; + } + + if (_savedKeyboardDisplayRequiresUserAction == true) { + return; + } + + UIView* subview; + + for (UIView* view in _webView.scrollView.subviews) { + if([[view.class description] hasPrefix:@"WK"]) + subview = view; + } + + if(subview == nil) return; + + Class class = subview.class; + + NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0}; + NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0}; + + Method method; + IMP override; + + if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_12_2_0]) { + // iOS 12.2.0 - Future + SEL selector = sel_getUid("_elementDidFocus:userIsInteracting:blurPreviousNode:changingActivityState:userObject:"); + method = class_getInstanceMethod(class, selector); + IMP original = method_getImplementation(method); + override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) { + ((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4); + }); + } + else if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion: iOS_11_3_0]) { + // iOS 11.3.0 - 12.2.0 + SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:"); + method = class_getInstanceMethod(class, selector); + IMP original = method_getImplementation(method); + override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) { + ((void (*)(id, SEL, void*, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4); + }); + } else { + // iOS 9.0 - 11.3.0 + SEL selector = sel_getUid("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:"); + method = class_getInstanceMethod(class, selector); + IMP original = method_getImplementation(method); + override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) { + ((void (*)(id, SEL, void*, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3); + }); + } + + method_setImplementation(method, override); +} + -(void)setHideKeyboardAccessoryView:(BOOL)hideKeyboardAccessoryView { if (_webView == nil) { diff --git a/ios/RNCWKWebViewManager.m b/ios/RNCWKWebViewManager.m index 79c4f00..8de7f93 100644 --- a/ios/RNCWKWebViewManager.m +++ b/ios/RNCWKWebViewManager.m @@ -101,6 +101,10 @@ RCT_CUSTOM_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL, RNCWKWebView) { view.showsVerticalScrollIndicator = json == nil ? true : [RCTConvert BOOL: json]; } +RCT_CUSTOM_VIEW_PROPERTY(keyboardDisplayRequiresUserAction, BOOL, RNCWKWebView) { + view.keyboardDisplayRequiresUserAction = json == nil ? true : [RCTConvert BOOL: json]; +} + RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script) { [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary *viewRegistry) { diff --git a/src/WebViewTypes.ts b/src/WebViewTypes.ts index 3ae5f9d..5a572a3 100644 --- a/src/WebViewTypes.ts +++ b/src/WebViewTypes.ts @@ -403,6 +403,18 @@ export interface IOSWebViewProps extends WebViewSharedProps { */ directionalLockEnabled?: boolean; + /** + * A Boolean value indicating whether web content can programmatically display the keyboard. + * + * When this property is set to true, the user must explicitly tap the elements in the + * web view to display the keyboard (or other relevant input view) for that element. + * When set to false, a focus event on an element causes the input view to be displayed + * and associated with that element automatically. + * + * The default value is `true`. + * @platform ios + */ + keyboardDisplayRequiresUserAction?: boolean; } export interface AndroidWebViewProps extends WebViewSharedProps { From 0d63760c6604233dfdeeafb94e1b24d09a5aee9e Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" Date: Mon, 29 Apr 2019 17:47:39 +0200 Subject: [PATCH 07/10] chore(docs): add ericlewis as a contributor (#543) * docs: update README.md * docs: update .all-contributorsrc --- .all-contributorsrc | 10 ++++++++++ README.md | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 3e74250..bc6890a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -159,6 +159,16 @@ "contributions": [ "code" ] + }, + { + "login": "ericlewis", + "name": "Eric Lewis", + "avatar_url": "https://avatars0.githubusercontent.com/u/674503?v=4", + "profile": "http://www.try.com", + "contributions": [ + "code", + "doc" + ] } ], "contributorsPerLine": 7 diff --git a/README.md b/README.md index a50dba0..050d2ee 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # React Native WebView - a Modern, Cross-Platform WebView for React Native -[![star this repo](http://githubbadges.com/star.svg?user=react-native-community&repo=react-native-webview&style=flat)](https://github.com/react-native-community/react-native-webview) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors) [![Known Vulnerabilities](https://snyk.io/test/github/react-native-community/react-native-webview/badge.svg?style=flat-square)](https://snyk.io/test/github/react-native-community/react-native-webview)![version](https://img.shields.io/npm/v/react-native-webview.svg) +[![star this repo](http://githubbadges.com/star.svg?user=react-native-community&repo=react-native-webview&style=flat)](https://github.com/react-native-community/react-native-webview) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors) [![Known Vulnerabilities](https://snyk.io/test/github/react-native-community/react-native-webview/badge.svg?style=flat-square)](https://snyk.io/test/github/react-native-community/react-native-webview)![version](https://img.shields.io/npm/v/react-native-webview.svg) **React Native WebView** is a modern, well-supported, and cross-platform WebView for React Native. It is intended to be a replacement for the built-in WebView (which will be [removed from core](https://github.com/react-native-community/discussions-and-proposals/pull/3)). @@ -77,7 +77,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/all-contri -
Thibault Malbranche
Thibault Malbranche

💻 🤔 👀 📖 🚧 ⚠️ 🚇 💬
Jamon Holmgren
Jamon Holmgren

💻 🤔 👀 📖 🚧 ⚠️ 💡 💬
Andrei Pfeiffer
Andrei Pfeiffer

💻 👀 🤔
Michael Diarmid
Michael Diarmid

💻 👀 🤔 🔧
Scott Mathson
Scott Mathson

💻 📖
Margaret
Margaret

💻 📖
Jordan Sexton
Jordan Sexton

💻 📖
Malcolm Scruggs
Malcolm Scruggs

💻 🔧 ⚠️
Momazo7u7
Momazo7u7

📖
Marco
Marco

📖
Julien Eluard
Julien Eluard

📖
Jian Wei
Jian Wei

💻 📖
Sergei Butko
Sergei Butko

📖
TMomemt
TMomemt

💻
+
Thibault Malbranche
Thibault Malbranche

💻 🤔 👀 📖 🚧 ⚠️ 🚇 💬
Jamon Holmgren
Jamon Holmgren

💻 🤔 👀 📖 🚧 ⚠️ 💡 💬
Andrei Pfeiffer
Andrei Pfeiffer

💻 👀 🤔
Michael Diarmid
Michael Diarmid

💻 👀 🤔 🔧
Scott Mathson
Scott Mathson

💻 📖
Margaret
Margaret

💻 📖
Jordan Sexton
Jordan Sexton

💻 📖
Malcolm Scruggs
Malcolm Scruggs

💻 🔧 ⚠️
Momazo7u7
Momazo7u7

📖
Marco
Marco

📖
Julien Eluard
Julien Eluard

📖
Jian Wei
Jian Wei

💻 📖
Sergei Butko
Sergei Butko

📖
TMomemt
TMomemt

💻
Eric Lewis
Eric Lewis

💻 📖
From d864c31b62b6b3a0d2d503bbec1b83cf897f3c65 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 29 Apr 2019 15:49:33 +0000 Subject: [PATCH 08/10] chore(release): 5.8.0 [skip ci] # [5.8.0](https://github.com/react-native-community/react-native-webview/compare/v5.7.2...v5.8.0) (2019-04-29) ### Features * **WKWebView:** Allow focus without user interaction ([#540](https://github.com/react-native-community/react-native-webview/issues/540)) ([455c30e](https://github.com/react-native-community/react-native-webview/commit/455c30e)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df18962..ad6ad75 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "Thibault Malbranche " ], "license": "MIT", - "version": "5.7.2", + "version": "5.8.0", "homepage": "https://github.com/react-native-community/react-native-webview#readme", "scripts": { "ci": "CI=true && yarn lint && yarn test", From c2914a8d7345204997678956ecf076dfbf776cc5 Mon Sep 17 00:00:00 2001 From: Eric Lewis Date: Tue, 30 Apr 2019 04:08:41 -0400 Subject: [PATCH 09/10] fix(WKWebView): StatusBar is gone after fullscreen (iOS 12) (#544) fixes #62 --- ios/RNCWKWebView.m | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/ios/RNCWKWebView.m b/ios/RNCWKWebView.m index c152d5b..dc351a5 100644 --- a/ios/RNCWKWebView.m +++ b/ios/RNCWKWebView.m @@ -42,6 +42,12 @@ static NSURLCredential* clientAuthenticationCredential; UIColor * _savedBackgroundColor; BOOL _savedHideKeyboardAccessoryView; BOOL _savedKeyboardDisplayRequiresUserAction; + + // Workaround for StatusBar appearance bug for iOS 12 + // https://github.com/react-native-community/react-native-webview/issues/62 + BOOL _isFullScreenVideoOpen; + UIStatusBarStyle _savedStatusBarStyle; + BOOL _savedStatusBarHidden; } - (instancetype)initWithFrame:(CGRect)frame @@ -56,11 +62,13 @@ static NSURLCredential* clientAuthenticationCredential; _automaticallyAdjustContentInsets = YES; _contentInset = UIEdgeInsetsZero; _savedKeyboardDisplayRequiresUserAction = YES; + _savedStatusBarStyle = RCTSharedApplication().statusBarStyle; + _savedStatusBarHidden = RCTSharedApplication().statusBarHidden; } - // Workaround for a keyboard dismissal bug present in iOS 12 - // https://openradar.appspot.com/radar?id=5018321736957952 if (@available(iOS 12.0, *)) { + // Workaround for a keyboard dismissal bug present in iOS 12 + // https://openradar.appspot.com/radar?id=5018321736957952 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide) @@ -69,8 +77,12 @@ static NSURLCredential* clientAuthenticationCredential; addObserver:self selector:@selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil]; + + // Workaround for StatusBar appearance bug for iOS 12 + // https://github.com/react-native-community/react-native-webview/issues/62 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toggleFullScreenVideoStatusBars) name:@"_MRMediaRemotePlayerSupportedCommandsDidChangeNotification" object:nil]; } - + return self; } @@ -241,6 +253,24 @@ static NSURLCredential* clientAuthenticationCredential; [super removeFromSuperview]; } +-(void)toggleFullScreenVideoStatusBars +{ +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + if (!_isFullScreenVideoOpen) { + _isFullScreenVideoOpen = YES; + RCTUnsafeExecuteOnMainQueueSync(^{ + [RCTSharedApplication() setStatusBarStyle:UIStatusBarStyleLightContent animated:YES]; + }); + } else { + _isFullScreenVideoOpen = NO; + RCTUnsafeExecuteOnMainQueueSync(^{ + [RCTSharedApplication() setStatusBarHidden:_savedStatusBarHidden animated:YES]; + [RCTSharedApplication() setStatusBarStyle:_savedStatusBarStyle animated:YES]; + }); + } +#pragma clang diagnostic pop +} + -(void)keyboardWillHide { keyboardTimer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(keyboardDisplacementFix) userInfo:nil repeats:false]; From 406241462f7edf8360eb6efb29f7b30f90ca0b02 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 30 Apr 2019 08:10:42 +0000 Subject: [PATCH 10/10] chore(release): 5.8.1 [skip ci] ## [5.8.1](https://github.com/react-native-community/react-native-webview/compare/v5.8.0...v5.8.1) (2019-04-30) ### Bug Fixes * **WKWebView:** StatusBar is gone after fullscreen (iOS 12) ([#544](https://github.com/react-native-community/react-native-webview/issues/544)) ([c2914a8](https://github.com/react-native-community/react-native-webview/commit/c2914a8)), closes [#62](https://github.com/react-native-community/react-native-webview/issues/62) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ad6ad75..7aed31d 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "Thibault Malbranche " ], "license": "MIT", - "version": "5.8.0", + "version": "5.8.1", "homepage": "https://github.com/react-native-community/react-native-webview#readme", "scripts": { "ci": "CI=true && yarn lint && yarn test",