Selaa lähdekoodia

fix(iOS): UIWebView Removal (#828)

Apple required us to remove this (see #819)

BREAKING CHANGE: UIWebView has been removed
BREAKING CHANGE: useWebkit prop removal
BREAKING CHANGE: scalesPageToFit prop removal on iOS (since it's not compatible with WKWebview)
BREAKING CHANGE: Renamed RNCWKWebView to RNCWebView on iOS
Thibault Malbranche 4 vuotta sitten
vanhempi
commit
8549be5fd0
No account linked to committer's email address

+ 7
- 8
README.md Näytä tiedosto

1
 # React Native WebView - a Modern, Cross-Platform WebView for React Native
1
 # React Native WebView - a Modern, Cross-Platform WebView for React Native
2
 
2
 
3
-[![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) 
4
-[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) 
5
-[![All Contributors](https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square)](#contributors) 
3
+[![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)
4
+[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
5
+[![All Contributors](https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square)](#contributors)
6
 [![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)
6
 [![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)
7
 <a href="https://www.npmjs.com/package/react-native-webview"><img src="https://img.shields.io/npm/v/react-native-webview.svg"></a>
7
 <a href="https://www.npmjs.com/package/react-native-webview"><img src="https://img.shields.io/npm/v/react-native-webview.svg"></a>
8
 
8
 
17
 
17
 
18
 ## Platforms Supported
18
 ## Platforms Supported
19
 
19
 
20
-- [x] iOS (both UIWebView and WKWebView)
20
+- [x] iOS
21
 - [x] Android
21
 - [x] Android
22
 
22
 
23
 _Note: Expo support for React Native WebView started with [Expo SDK v33.0.0](https://blog.expo.io/expo-sdk-v33-0-0-is-now-available-52d1c99dfe4c)._
23
 _Note: Expo support for React Native WebView started with [Expo SDK v33.0.0](https://blog.expo.io/expo-sdk-v33-0-0-is-now-available-52d1c99dfe4c)._
34
 
34
 
35
 Current Version: ![version](https://img.shields.io/npm/v/react-native-webview.svg)
35
 Current Version: ![version](https://img.shields.io/npm/v/react-native-webview.svg)
36
 
36
 
37
-yarn add react-native-webview@androidx
37
+- [7.0.0](https://github.com/react-native-community/react-native-webview/releases/tag/v7.0.0 - Removed UIWebView
38
+
38
 - [6.0.**2**](https://github.com/react-native-community/react-native-webview/releases/tag/v6.0.2) - Update to AndroidX. Make sure to enable it in your project's `android/gradle.properties`. See [Getting Started Guide](docs/Getting-Started.md).
39
 - [6.0.**2**](https://github.com/react-native-community/react-native-webview/releases/tag/v6.0.2) - Update to AndroidX. Make sure to enable it in your project's `android/gradle.properties`. See [Getting Started Guide](docs/Getting-Started.md).
39
 
40
 
40
-yarn add react-native-webview
41
 - [5.0.**1**](https://github.com/react-native-community/react-native-webview/releases/tag/v5.0.0) - Refactored the old postMessage implementation for communication from webview to native.
41
 - [5.0.**1**](https://github.com/react-native-community/react-native-webview/releases/tag/v5.0.0) - Refactored the old postMessage implementation for communication from webview to native.
42
 - [4.0.0](https://github.com/react-native-community/react-native-webview/releases/tag/v4.0.0) - Added cache (enabled by default).
42
 - [4.0.0](https://github.com/react-native-community/react-native-webview/releases/tag/v4.0.0) - Added cache (enabled by default).
43
 - [3.0.0](https://github.com/react-native-community/react-native-webview/releases/tag/v3.0.0) - WKWebview: Add shared process pool so cookies and localStorage are shared across webviews in iOS (enabled by default).
43
 - [3.0.0](https://github.com/react-native-community/react-native-webview/releases/tag/v3.0.0) - WKWebview: Add shared process pool so cookies and localStorage are shared across webviews in iOS (enabled by default).
45
 
45
 
46
 **Upcoming:**
46
 **Upcoming:**
47
 
47
 
48
-- UIWebView removal
49
 - this.webView.postMessage() removal (never documented and less flexible than injectJavascript)
48
 - this.webView.postMessage() removal (never documented and less flexible than injectJavascript)
50
 - Kotlin rewrite
49
 - Kotlin rewrite
51
 - Maybe Swift rewrite
50
 - Maybe Swift rewrite
73
 
72
 
74
 ## Common issues
73
 ## Common issues
75
 
74
 
76
-- If you're getting `Invariant Violation: Native component for "RNCWKWebView does not exist"` it likely means you forgot to run `react-native link` or there was some error with the linking process
75
+- If you're getting `Invariant Violation: Native component for "RNCWebView does not exist"` it likely means you forgot to run `react-native link` or there was some error with the linking process
77
 
76
 
78
 ## Contributing
77
 ## Contributing
79
 
78
 

+ 0
- 1
docs/Contributing.md Näytä tiedosto

45
 ## Notes
45
 ## Notes
46
 
46
 
47
 - We use TypeScript.
47
 - We use TypeScript.
48
-- We don't intend to support UIWebView and will remove it soon.
49
 - After pulling this repo and installing all dependencies, you can run tests using the command: `yarn ci`
48
 - After pulling this repo and installing all dependencies, you can run tests using the command: `yarn ci`

+ 1
- 1
docs/Custom-iOS.md Näytä tiedosto

137
 If you open webpages that needs a Client Certificate for Authentication, you can create a credential and pass it to the webview:
137
 If you open webpages that needs a Client Certificate for Authentication, you can create a credential and pass it to the webview:
138
 
138
 
139
 ```
139
 ```
140
-[RNCWKWebView setClientAuthenticationCredential:credential];
140
+[RNCWebView setClientAuthenticationCredential:credential];
141
 ```
141
 ```
142
 
142
 
143
 This can be paired with a call from Javascript to pass a string label for the certificate stored in keychain and use native calls to fetch the certificate to create a credential object. This call can be made anywhere that makes sense for your application (e.g. as part of the user authentication stack). The only requirement is to make this call before displaying any webviews.
143
 This can be paired with a call from Javascript to pass a string label for the certificate stored in keychain and use native calls to fetch the certificate to create a credential object. This call can be made anywhere that makes sense for your application (e.g. as part of the user authentication stack). The only requirement is to make this call before displaying any webviews.

+ 2
- 2
docs/Guide.md Näytä tiedosto

297
 
297
 
298
 _Under the hood_
298
 _Under the hood_
299
 
299
 
300
-> On iOS, `injectedJavaScript` runs a method on WKWebView called `evaluateJavaScript:completionHandler:`
300
+> On iOS, `injectedJavaScript` runs a method on WebView called `evaluateJavaScript:completionHandler:`
301
 > On Android, `injectedJavaScript` runs a method on the Android WebView called `evaluateJavascriptWithFallback`
301
 > On Android, `injectedJavaScript` runs a method on the Android WebView called `evaluateJavascriptWithFallback`
302
 
302
 
303
 #### The `injectJavaScript` method
303
 #### The `injectJavaScript` method
341
 
341
 
342
 _Under the hood_
342
 _Under the hood_
343
 
343
 
344
-> On iOS, `injectJavaScript` calls WKWebView's `evaluateJS:andThen:`
344
+> On iOS, `injectJavaScript` calls WebView's `evaluateJS:andThen:`
345
 > On Android, `injectJavaScript` calls Android WebView's `evaluateJavascriptWithFallback` method
345
 > On Android, `injectJavaScript` calls Android WebView's `evaluateJavascriptWithFallback` method
346
 
346
 
347
 #### The `window.ReactNativeWebView.postMessage` method and `onMessage` prop
347
 #### The `window.ReactNativeWebView.postMessage` method and `onMessage` prop

+ 25
- 42
docs/Reference.md Näytä tiedosto

43
 - [`geolocationEnabled`](Reference.md#geolocationenabled)
43
 - [`geolocationEnabled`](Reference.md#geolocationenabled)
44
 - [`allowUniversalAccessFromFileURLs`](Reference.md#allowUniversalAccessFromFileURLs)
44
 - [`allowUniversalAccessFromFileURLs`](Reference.md#allowUniversalAccessFromFileURLs)
45
 - [`allowingReadAccessToURL`](Reference.md#allowingReadAccessToURL)
45
 - [`allowingReadAccessToURL`](Reference.md#allowingReadAccessToURL)
46
-- [`useWebKit`](Reference.md#usewebkit)
47
 - [`url`](Reference.md#url)
46
 - [`url`](Reference.md#url)
48
 - [`html`](Reference.md#html)
47
 - [`html`](Reference.md#html)
49
 - [`keyboardDisplayRequiresUserAction`](Reference.md#keyboardDisplayRequiresUserAction)
48
 - [`keyboardDisplayRequiresUserAction`](Reference.md#keyboardDisplayRequiresUserAction)
132
   source={{ uri: 'https://facebook.github.io/react-native' }}
131
   source={{ uri: 'https://facebook.github.io/react-native' }}
133
   injectedJavaScript={INJECTED_JAVASCRIPT}
132
   injectedJavaScript={INJECTED_JAVASCRIPT}
134
   onMessage={this.onMessage}
133
   onMessage={this.onMessage}
135
-/>
134
+/>;
136
 ```
135
 ```
137
 
136
 
138
 ---
137
 ---
312
 
311
 
313
 > **_Note_**
312
 > **_Note_**
314
 >
313
 >
315
-> On iOS, when useWebKit=false, this prop will not work.
316
 > On android, You can't get the url property, meaning that `event.nativeEvent.url` will be null.
314
 > On android, You can't get the url property, meaning that `event.nativeEvent.url` will be null.
317
 
315
 
318
 | Type     | Required |
316
 | Type     | Required |
459
 
457
 
460
 Boolean that controls whether the web content is scaled to fit the view and enables the user to change the scale. The default value is `true`.
458
 Boolean that controls whether the web content is scaled to fit the view and enables the user to change the scale. The default value is `true`.
461
 
459
 
462
-On iOS, when [`useWebKit=true`](Reference.md#usewebkit), this prop will not work.
463
-
464
-| Type | Required |
465
-| ---- | -------- |
466
-| bool | No       |
460
+| Type | Required | Platform |
461
+| ---- | -------- | -------- |
462
+| bool | No       | Android  |
467
 
463
 
468
 ---
464
 ---
469
 
465
 
605
 
601
 
606
 ### `userAgent`
602
 ### `userAgent`
607
 
603
 
608
-Sets the user-agent for the `WebView`. This will only work for iOS if you are using WKWebView, not UIWebView (see https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent).
604
+Sets the user-agent for the `WebView`.
609
 
605
 
610
-| Type   | Required | Platform               |
611
-| ------ | -------- | ---------------------- |
612
-| string | No       | Android, iOS WKWebView |
606
+| Type   | Required |
607
+| ------ | -------- |
608
+| string | No       |
613
 
609
 
614
 ---
610
 ---
615
 
611
 
616
 ### `applicationNameForUserAgent`
612
 ### `applicationNameForUserAgent`
617
 
613
 
618
-Append to the existing user-agent. This will only work for iOS if you are using WKWebView, not UIWebView. Setting `userAgent` will override this.
614
+Append to the existing user-agent. Setting `userAgent` will override this.
619
 
615
 
620
-| Type   | Required | Platform      |
621
-| ------ | -------- | ------------- |
622
-| string | No       | Android, iOS WKWebView |
616
+| Type   | Required |
617
+| ------ | -------- |
618
+| string | No       |
623
 
619
 
624
 ```jsx
620
 ```jsx
625
 <WebView
621
 <WebView
626
   source={{ uri: 'https://facebook.github.io/react-native' }}
622
   source={{ uri: 'https://facebook.github.io/react-native' }}
627
-  applicationNameForUserAgent={"DemoApp/1.1.0"}
623
+  applicationNameForUserAgent={'DemoApp/1.1.0'}
628
 />
624
 />
629
 // Resulting User-Agent will look like:
625
 // Resulting User-Agent will look like:
630
 // Mozilla/5.0 (Linux; Android 8.1.0; Android SDK built for x86 Build/OSM1.180201.021; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Mobile Safari/537.36 DemoApp/1.1.0
626
 // Mozilla/5.0 (Linux; Android 8.1.0; Android SDK built for x86 Build/OSM1.180201.021; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Mobile Safari/537.36 DemoApp/1.1.0
722
 - `calendarEvent`
718
 - `calendarEvent`
723
 - `none`
719
 - `none`
724
 - `all`
720
 - `all`
725
-
726
-With the [new WebKit](Reference.md#usewebkit) implementation, we have three new values:
727
-
728
 - `trackingNumber`
721
 - `trackingNumber`
729
 - `flightNumber`
722
 - `flightNumber`
730
 - `lookupSuggestion`
723
 - `lookupSuggestion`
798
 
791
 
799
 ### `allowingReadAccessToURL`
792
 ### `allowingReadAccessToURL`
800
 
793
 
801
-A String value that indicates which URLs the WebView's file can then reference in scripts, AJAX requests, and CSS imports. This is only used in `RNCWKWebView` for WebViews that are loaded with a source.uri set to a `'file://'` URL. If not provided, the default is to only allow read access to the URL provided in source.uri itself.
802
-
803
-| Type   | Required | Platform      |
804
-| ------ | -------- | ------------- |
805
-| string | No       | iOS WKWebView |
806
-
807
----
808
-
809
-### `useWebKit`
810
-
811
-If true, use WKWebView instead of UIWebView.
794
+A String value that indicates which URLs the WebView's file can then reference in scripts, AJAX requests, and CSS imports. This is only used in for WebViews that are loaded with a source.uri set to a `'file://'` URL. If not provided, the default is to only allow read access to the URL provided in source.uri itself.
812
 
795
 
813
-| Type    | Required | Platform |
814
-| ------- | -------- | -------- |
815
-| boolean | No       | iOS      |
796
+| Type   | Required | Platform |
797
+| ------ | -------- | -------- |
798
+| string | No       | iOS      |
816
 
799
 
817
 ---
800
 ---
818
 
801
 
838
 
821
 
839
 ### `keyboardDisplayRequiresUserAction`
822
 ### `keyboardDisplayRequiresUserAction`
840
 
823
 
841
-If false, web content can programmatically display the keyboard when using the WKWebView. The default value is `true`.
824
+If false, web content can programmatically display the keyboard. The default value is `true`.
842
 
825
 
843
 | Type    | Required | Platform |
826
 | Type    | Required | Platform |
844
 | ------- | -------- | -------- |
827
 | ------- | -------- | -------- |
848
 
831
 
849
 ### `hideKeyboardAccessoryView`
832
 ### `hideKeyboardAccessoryView`
850
 
833
 
851
-If true, this will hide the keyboard accessory view (< > and Done) when using the WKWebView.
834
+If true, this will hide the keyboard accessory view (< > and Done).
852
 
835
 
853
 | Type    | Required | Platform |
836
 | Type    | Required | Platform |
854
 | ------- | -------- | -------- |
837
 | ------- | -------- | -------- |
858
 
841
 
859
 ### `allowsBackForwardNavigationGestures`
842
 ### `allowsBackForwardNavigationGestures`
860
 
843
 
861
-If true, this will be able horizontal swipe gestures when using the WKWebView. The default value is `false`.
844
+If true, this will be able horizontal swipe gestures. The default value is `false`.
862
 
845
 
863
 | Type    | Required | Platform |
846
 | Type    | Required | Platform |
864
 | ------- | -------- | -------- |
847
 | ------- | -------- | -------- |
870
 
853
 
871
 Does not store any data within the lifetime of the WebView.
854
 Does not store any data within the lifetime of the WebView.
872
 
855
 
873
-| Type    | Required | Platform               |
874
-| ------- | -------- | ---------------------- |
875
-| boolean | No       | Android, iOS WKWebView |
856
+| Type    | Required |
857
+| ------- | -------- |
858
+| boolean | No       |
876
 
859
 
877
 ---
860
 ---
878
 
861
 
898
 
881
 
899
 ### `cacheEnabled`
882
 ### `cacheEnabled`
900
 
883
 
901
-Sets whether WebView & WKWebView should use browser caching.
884
+Sets whether WebView should use browser caching.
902
 
885
 
903
 | Type    | Required | Default |
886
 | Type    | Required | Default |
904
 | ------- | -------- | ------- |
887
 | ------- | -------- | ------- |
928
 
911
 
929
 ### `sharedCookiesEnabled`
912
 ### `sharedCookiesEnabled`
930
 
913
 
931
-Set `true` if shared cookies from `[NSHTTPCookieStorage sharedHTTPCookieStorage]` should used for every load request in the `RNCWKWebView`. The default value is `false`.
914
+Set `true` if shared cookies from `[NSHTTPCookieStorage sharedHTTPCookieStorage]` should used for every load request in the WebView. The default value is `false`.
932
 
915
 
933
 | Type    | Required | Platform |
916
 | Type    | Required | Platform |
934
 | ------- | -------- | -------- |
917
 | ------- | -------- | -------- |

+ 0
- 39
ios/RNCUIWebView.h Näytä tiedosto

1
-#import <React/RCTView.h>
2
-
3
-@class RNCUIWebView;
4
-
5
-/**
6
- * Special scheme used to pass messages to the injectedJavaScript
7
- * code without triggering a page load. Usage:
8
- *
9
- *   window.location.href = RNCJSNavigationScheme + '://hello'
10
- */
11
-extern NSString *const RNCJSNavigationScheme;
12
-
13
-@protocol RNCUIWebViewDelegate <NSObject>
14
-
15
-- (BOOL)webView:(RNCUIWebView *)webView
16
-shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
17
-   withCallback:(RCTDirectEventBlock)callback;
18
-
19
-@end
20
-
21
-@interface RNCUIWebView : RCTView
22
-
23
-@property (nonatomic, weak) id<RNCUIWebViewDelegate> delegate;
24
-
25
-@property (nonatomic, copy) NSDictionary *source;
26
-@property (nonatomic, assign) UIEdgeInsets contentInset;
27
-@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
28
-@property (nonatomic, assign) BOOL messagingEnabled;
29
-@property (nonatomic, copy) NSString *injectedJavaScript;
30
-@property (nonatomic, assign) BOOL scalesPageToFit;
31
-
32
-- (void)goForward;
33
-- (void)goBack;
34
-- (void)reload;
35
-- (void)stopLoading;
36
-- (void)postMessage:(NSString *)message;
37
-- (void)injectJavaScript:(NSString *)script;
38
-
39
-@end

+ 0
- 332
ios/RNCUIWebView.m Näytä tiedosto

1
-#import "RNCUIWebView.h"
2
-
3
-// #import <UIKit/UIKit.h>
4
-#import <React/RCTAutoInsetsProtocol.h>
5
-#import <React/RCTConvert.h>
6
-#import <React/RCTEventDispatcher.h>
7
-#import <React/RCTLog.h>
8
-#import <React/RCTUtils.h>
9
-#import <React/RCTView.h>
10
-#import <React/UIView+React.h>
11
-
12
-NSString *const RNCJSNavigationScheme = @"react-js-navigation";
13
-
14
-static NSString *const MessageHandlerName = @"ReactNativeWebView";
15
-
16
-@interface RNCUIWebView () <UIWebViewDelegate, RCTAutoInsetsProtocol>
17
-
18
-@property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
19
-@property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
20
-@property (nonatomic, copy) RCTDirectEventBlock onLoadingError;
21
-@property (nonatomic, copy) RCTDirectEventBlock onShouldStartLoadWithRequest;
22
-@property (nonatomic, copy) RCTDirectEventBlock onMessage;
23
-
24
-@end
25
-
26
-@implementation RNCUIWebView
27
-{
28
-  UIWebView *_webView;
29
-  NSString *_injectedJavaScript;
30
-}
31
-
32
-- (void)dealloc
33
-{
34
-  _webView.delegate = nil;
35
-}
36
-
37
-- (instancetype)initWithFrame:(CGRect)frame
38
-{
39
-  if ((self = [super initWithFrame:frame])) {
40
-    super.backgroundColor = [UIColor clearColor];
41
-    _automaticallyAdjustContentInsets = YES;
42
-    _contentInset = UIEdgeInsetsZero;
43
-    _webView = [[UIWebView alloc] initWithFrame:self.bounds];
44
-    _webView.delegate = self;
45
-#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
46
-    if ([_webView.scrollView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
47
-      _webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
48
-    }
49
-#endif
50
-    [self addSubview:_webView];
51
-  }
52
-  return self;
53
-}
54
-
55
-RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
56
-
57
-- (void)goForward
58
-{
59
-  [_webView goForward];
60
-}
61
-
62
-- (void)goBack
63
-{
64
-  [_webView goBack];
65
-}
66
-
67
-- (void)reload
68
-{
69
-  NSURLRequest *request = [RCTConvert NSURLRequest:self.source];
70
-  if (request.URL && !_webView.request.URL.absoluteString.length) {
71
-    [_webView loadRequest:request];
72
-  }
73
-  else {
74
-    [_webView reload];
75
-  }
76
-}
77
-
78
-- (void)stopLoading
79
-{
80
-  [_webView stopLoading];
81
-}
82
-
83
-- (void)postMessage:(NSString *)message
84
-{
85
-  NSDictionary *eventInitDict = @{
86
-    @"data": message,
87
-  };
88
-  NSString *source = [NSString
89
-    stringWithFormat:@"window.dispatchEvent(new MessageEvent('message', %@));",
90
-    RCTJSONStringify(eventInitDict, NULL)
91
-  ];
92
-  [_webView stringByEvaluatingJavaScriptFromString:source];
93
-}
94
-
95
-- (void)injectJavaScript:(NSString *)script
96
-{
97
-  [_webView stringByEvaluatingJavaScriptFromString:script];
98
-}
99
-
100
-- (void)setSource:(NSDictionary *)source
101
-{
102
-  if (![_source isEqualToDictionary:source]) {
103
-    _source = [source copy];
104
-
105
-    // Check for a static html source first
106
-    NSString *html = [RCTConvert NSString:source[@"html"]];
107
-    if (html) {
108
-      NSURL *baseURL = [RCTConvert NSURL:source[@"baseUrl"]];
109
-      if (!baseURL) {
110
-        baseURL = [NSURL URLWithString:@"about:blank"];
111
-      }
112
-      [_webView loadHTMLString:html baseURL:baseURL];
113
-      return;
114
-    }
115
-
116
-    NSURLRequest *request = [RCTConvert NSURLRequest:source];
117
-    // Because of the way React works, as pages redirect, we actually end up
118
-    // passing the redirect urls back here, so we ignore them if trying to load
119
-    // the same url. We'll expose a call to 'reload' to allow a user to load
120
-    // the existing page.
121
-    if ([request.URL isEqual:_webView.request.URL]) {
122
-      return;
123
-    }
124
-    if (!request.URL) {
125
-      // Clear the webview
126
-      [_webView loadHTMLString:@"" baseURL:nil];
127
-      return;
128
-    }
129
-    [_webView loadRequest:request];
130
-  }
131
-}
132
-
133
-- (void)layoutSubviews
134
-{
135
-  [super layoutSubviews];
136
-  _webView.frame = self.bounds;
137
-}
138
-
139
-- (void)setContentInset:(UIEdgeInsets)contentInset
140
-{
141
-  _contentInset = contentInset;
142
-  [RCTView autoAdjustInsetsForView:self
143
-                    withScrollView:_webView.scrollView
144
-                      updateOffset:NO];
145
-}
146
-
147
-- (void)setScalesPageToFit:(BOOL)scalesPageToFit
148
-{
149
-  if (_webView.scalesPageToFit != scalesPageToFit) {
150
-    _webView.scalesPageToFit = scalesPageToFit;
151
-    [_webView reload];
152
-  }
153
-}
154
-
155
-- (BOOL)scalesPageToFit
156
-{
157
-  return _webView.scalesPageToFit;
158
-}
159
-
160
-- (void)setBackgroundColor:(UIColor *)backgroundColor
161
-{
162
-  CGFloat alpha = CGColorGetAlpha(backgroundColor.CGColor);
163
-  self.opaque = _webView.opaque = (alpha == 1.0);
164
-  _webView.backgroundColor = backgroundColor;
165
-}
166
-
167
-- (UIColor *)backgroundColor
168
-{
169
-  return _webView.backgroundColor;
170
-}
171
-
172
-- (NSMutableDictionary<NSString *, id> *)baseEvent
173
-{
174
-  NSMutableDictionary<NSString *, id> *event = [[NSMutableDictionary alloc] initWithDictionary:@{
175
-    @"url": _webView.request.URL.absoluteString ?: @"",
176
-    @"loading" : @(_webView.loading),
177
-    @"title": [_webView stringByEvaluatingJavaScriptFromString:@"document.title"],
178
-    @"canGoBack": @(_webView.canGoBack),
179
-    @"canGoForward" : @(_webView.canGoForward),
180
-  }];
181
-
182
-  return event;
183
-}
184
-
185
-- (void)refreshContentInset
186
-{
187
-  [RCTView autoAdjustInsetsForView:self
188
-                    withScrollView:_webView.scrollView
189
-                      updateOffset:YES];
190
-}
191
-
192
-#pragma mark - UIWebViewDelegate methods
193
-
194
-- (BOOL)webView:(__unused UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
195
- navigationType:(UIWebViewNavigationType)navigationType
196
-{
197
-  BOOL isJSNavigation = [request.URL.scheme isEqualToString:RNCJSNavigationScheme];
198
-
199
-  static NSDictionary<NSNumber *, NSString *> *navigationTypes;
200
-  static dispatch_once_t onceToken;
201
-  dispatch_once(&onceToken, ^{
202
-    navigationTypes = @{
203
-      @(UIWebViewNavigationTypeLinkClicked): @"click",
204
-      @(UIWebViewNavigationTypeFormSubmitted): @"formsubmit",
205
-      @(UIWebViewNavigationTypeBackForward): @"backforward",
206
-      @(UIWebViewNavigationTypeReload): @"reload",
207
-      @(UIWebViewNavigationTypeFormResubmitted): @"formresubmit",
208
-      @(UIWebViewNavigationTypeOther): @"other",
209
-    };
210
-  });
211
-
212
-  // skip this for the JS Navigation handler
213
-  if (!isJSNavigation && _onShouldStartLoadWithRequest) {
214
-    NSMutableDictionary<NSString *, id> *event = [self baseEvent];
215
-    [event addEntriesFromDictionary: @{
216
-      @"url": (request.URL).absoluteString,
217
-      @"mainDocumentURL": (request.mainDocumentURL).absoluteString,
218
-      @"navigationType": navigationTypes[@(navigationType)]
219
-    }];
220
-    if (![self.delegate webView:self
221
-      shouldStartLoadForRequest:event
222
-                   withCallback:_onShouldStartLoadWithRequest]) {
223
-      return NO;
224
-    }
225
-  }
226
-
227
-  if (_onLoadingStart) {
228
-    // We have this check to filter out iframe requests and whatnot
229
-    BOOL isTopFrame = [request.URL isEqual:request.mainDocumentURL];
230
-    if (isTopFrame) {
231
-      NSMutableDictionary<NSString *, id> *event = [self baseEvent];
232
-      [event addEntriesFromDictionary: @{
233
-        @"url": (request.URL).absoluteString,
234
-        @"navigationType": navigationTypes[@(navigationType)]
235
-      }];
236
-      _onLoadingStart(event);
237
-    }
238
-  }
239
-
240
-  if (isJSNavigation && [request.URL.host isEqualToString:MessageHandlerName]) {
241
-    NSString *data = request.URL.query;
242
-    data = [data stringByReplacingOccurrencesOfString:@"+" withString:@" "];
243
-    data = [data stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
244
-
245
-    NSMutableDictionary<NSString *, id> *event = [self baseEvent];
246
-    [event addEntriesFromDictionary: @{
247
-      @"data": data,
248
-    }];
249
-
250
-    NSString *source = [NSString stringWithFormat:@"window.%@.messageReceived();", MessageHandlerName];
251
-
252
-    [_webView stringByEvaluatingJavaScriptFromString:source];
253
-
254
-    _onMessage(event);
255
-  }
256
-
257
-  // JS Navigation handler
258
-  return !isJSNavigation;
259
-}
260
-
261
-- (void)webView:(__unused UIWebView *)webView didFailLoadWithError:(NSError *)error
262
-{
263
-  if (_onLoadingError) {
264
-    if ([error.domain isEqualToString:NSURLErrorDomain] && error.code == NSURLErrorCancelled) {
265
-      // NSURLErrorCancelled is reported when a page has a redirect OR if you load
266
-      // a new URL in the WebView before the previous one came back. We can just
267
-      // ignore these since they aren't real errors.
268
-      // http://stackoverflow.com/questions/1024748/how-do-i-fix-nsurlerrordomain-error-999-in-iphone-3-0-os
269
-      return;
270
-    }
271
-
272
-    if ([error.domain isEqualToString:@"WebKitErrorDomain"] && error.code == 102) {
273
-      // Error code 102 "Frame load interrupted" is raised by the UIWebView if
274
-      // its delegate returns FALSE from webView:shouldStartLoadWithRequest:navigationType
275
-      // when the URL is from an http redirect. This is a common pattern when
276
-      // implementing OAuth with a WebView.
277
-      return;
278
-    }
279
-
280
-    NSMutableDictionary<NSString *, id> *event = [self baseEvent];
281
-    [event addEntriesFromDictionary:@{
282
-      @"domain": error.domain,
283
-      @"code": @(error.code),
284
-      @"description": error.localizedDescription,
285
-    }];
286
-    _onLoadingError(event);
287
-  }
288
-}
289
-
290
-- (void)webViewDidFinishLoad:(UIWebView *)webView
291
-{
292
-  if (_messagingEnabled) {
293
-    NSString *source = [NSString stringWithFormat:
294
-      @"(function() {"
295
-       "  var messageQueue = [];"
296
-       "  var messagePending = false;"
297
-
298
-       "  function processQueue () {"
299
-       "    if (!messageQueue.length || messagePending) return;"
300
-       "    messagePending = true;"
301
-       "    document.location = '%@://%@?' + encodeURIComponent(messageQueue.shift());"
302
-       "  }"
303
-
304
-       "  window.%@ = {"
305
-       "    postMessage: function (data) {"
306
-       "      messageQueue.push(String(data));"
307
-       "      processQueue();"
308
-       "    },"
309
-       "    messageReceived: function () {"
310
-       "      messagePending = false;"
311
-       "      processQueue();"
312
-       "    }"
313
-       "  };"
314
-       "})();", RNCJSNavigationScheme, MessageHandlerName, MessageHandlerName
315
-    ];
316
-    [webView stringByEvaluatingJavaScriptFromString:source];
317
-  }
318
-  if (_injectedJavaScript != nil) {
319
-    NSString *jsEvaluationValue = [webView stringByEvaluatingJavaScriptFromString:_injectedJavaScript];
320
-
321
-    NSMutableDictionary<NSString *, id> *event = [self baseEvent];
322
-    event[@"jsEvaluationValue"] = jsEvaluationValue;
323
-
324
-    _onLoadingFinish(event);
325
-  }
326
-  // we only need the final 'finishLoad' call so only fire the event when we're actually done loading.
327
-  else if (_onLoadingFinish && !webView.loading && ![webView.request.URL.absoluteString isEqualToString:@"about:blank"]) {
328
-    _onLoadingFinish([self baseEvent]);
329
-  }
330
-}
331
-
332
-@end

+ 0
- 5
ios/RNCUIWebViewManager.h Näytä tiedosto

1
-#import <React/RCTViewManager.h>
2
-
3
-@interface RNCUIWebViewManager : RCTViewManager
4
-
5
-@end

+ 0
- 154
ios/RNCUIWebViewManager.m Näytä tiedosto

1
-#import "RNCUIWebViewManager.h"
2
-
3
-#import <React/RCTBridge.h>
4
-#import <React/RCTUIManager.h>
5
-#import <React/UIView+React.h>
6
-#import "RNCUIWebView.h"
7
-
8
-@interface RNCUIWebViewManager () <RNCUIWebViewDelegate>
9
-
10
-@end
11
-
12
-@implementation RNCUIWebViewManager
13
-{
14
-  NSConditionLock *_shouldStartLoadLock;
15
-  BOOL _shouldStartLoad;
16
-}
17
-
18
-RCT_EXPORT_MODULE()
19
-
20
-- (UIView *)view
21
-{
22
-  RNCUIWebView *webView = [RNCUIWebView new];
23
-  webView.delegate = self;
24
-  return webView;
25
-}
26
-
27
-RCT_EXPORT_VIEW_PROPERTY(source, NSDictionary)
28
-RCT_REMAP_VIEW_PROPERTY(bounces, _webView.scrollView.bounces, BOOL)
29
-RCT_REMAP_VIEW_PROPERTY(scrollEnabled, _webView.scrollView.scrollEnabled, BOOL)
30
-RCT_REMAP_VIEW_PROPERTY(decelerationRate, _webView.scrollView.decelerationRate, CGFloat)
31
-RCT_EXPORT_VIEW_PROPERTY(scalesPageToFit, BOOL)
32
-RCT_EXPORT_VIEW_PROPERTY(messagingEnabled, BOOL)
33
-RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
34
-RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
35
-RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
36
-RCT_EXPORT_VIEW_PROPERTY(onLoadingStart, RCTDirectEventBlock)
37
-RCT_EXPORT_VIEW_PROPERTY(onLoadingFinish, RCTDirectEventBlock)
38
-RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock)
39
-RCT_EXPORT_VIEW_PROPERTY(onMessage, RCTDirectEventBlock)
40
-RCT_EXPORT_VIEW_PROPERTY(onShouldStartLoadWithRequest, RCTDirectEventBlock)
41
-RCT_REMAP_VIEW_PROPERTY(allowsInlineMediaPlayback, _webView.allowsInlineMediaPlayback, BOOL)
42
-RCT_REMAP_VIEW_PROPERTY(mediaPlaybackRequiresUserAction, _webView.mediaPlaybackRequiresUserAction, BOOL)
43
-RCT_REMAP_VIEW_PROPERTY(dataDetectorTypes, _webView.dataDetectorTypes, UIDataDetectorTypes)
44
-RCT_REMAP_VIEW_PROPERTY(showsHorizontalScrollIndicator, _webView.scrollView.showsHorizontalScrollIndicator, BOOL)
45
-RCT_REMAP_VIEW_PROPERTY(showsVerticalScrollIndicator, _webView.scrollView.showsVerticalScrollIndicator, BOOL)
46
-RCT_REMAP_VIEW_PROPERTY(directionalLockEnabled, _webView.scrollView.directionalLockEnabled, BOOL)
47
-
48
-RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
49
-{
50
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCUIWebView *> *viewRegistry) {
51
-    RNCUIWebView *view = viewRegistry[reactTag];
52
-    if (![view isKindOfClass:[RNCUIWebView class]]) {
53
-      RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
54
-    } else {
55
-      [view goBack];
56
-    }
57
-  }];
58
-}
59
-
60
-RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
61
-{
62
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
63
-    RNCUIWebView *view = viewRegistry[reactTag];
64
-    if (![view isKindOfClass:[RNCUIWebView class]]) {
65
-      RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
66
-    } else {
67
-      [view goForward];
68
-    }
69
-  }];
70
-}
71
-
72
-RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
73
-{
74
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCUIWebView *> *viewRegistry) {
75
-    RNCUIWebView *view = viewRegistry[reactTag];
76
-    if (![view isKindOfClass:[RNCUIWebView class]]) {
77
-      RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
78
-    } else {
79
-      [view reload];
80
-    }
81
-  }];
82
-}
83
-
84
-RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
85
-{
86
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCUIWebView *> *viewRegistry) {
87
-    RNCUIWebView *view = viewRegistry[reactTag];
88
-    if (![view isKindOfClass:[RNCUIWebView class]]) {
89
-      RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
90
-    } else {
91
-      [view stopLoading];
92
-    }
93
-  }];
94
-}
95
-
96
-RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
97
-{
98
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCUIWebView *> *viewRegistry) {
99
-    RNCUIWebView *view = viewRegistry[reactTag];
100
-    if (![view isKindOfClass:[RNCUIWebView class]]) {
101
-      RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
102
-    } else {
103
-      [view postMessage:message];
104
-    }
105
-  }];
106
-}
107
-
108
-RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
109
-{
110
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCUIWebView *> *viewRegistry) {
111
-    RNCUIWebView *view = viewRegistry[reactTag];
112
-    if (![view isKindOfClass:[RNCUIWebView class]]) {
113
-      RCTLogError(@"Invalid view returned from registry, expecting RNCUIWebView, got: %@", view);
114
-    } else {
115
-      [view injectJavaScript:script];
116
-    }
117
-  }];
118
-}
119
-
120
-#pragma mark - Exported synchronous methods
121
-
122
-- (BOOL)webView:(__unused RNCUIWebView *)webView
123
-shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
124
-   withCallback:(RCTDirectEventBlock)callback
125
-{
126
-  _shouldStartLoadLock = [[NSConditionLock alloc] initWithCondition:arc4random()];
127
-  _shouldStartLoad = YES;
128
-  request[@"lockIdentifier"] = @(_shouldStartLoadLock.condition);
129
-  callback(request);
130
-
131
-  // Block the main thread for a maximum of 250ms until the JS thread returns
132
-  if ([_shouldStartLoadLock lockWhenCondition:0 beforeDate:[NSDate dateWithTimeIntervalSinceNow:.25]]) {
133
-    BOOL returnValue = _shouldStartLoad;
134
-    [_shouldStartLoadLock unlock];
135
-    _shouldStartLoadLock = nil;
136
-    return returnValue;
137
-  } else {
138
-    RCTLogWarn(@"Did not receive response to shouldStartLoad in time, defaulting to YES");
139
-    return YES;
140
-  }
141
-}
142
-
143
-RCT_EXPORT_METHOD(startLoadWithResult:(BOOL)result lockIdentifier:(NSInteger)lockIdentifier)
144
-{
145
-  if ([_shouldStartLoadLock tryLockWhenCondition:lockIdentifier]) {
146
-    _shouldStartLoad = result;
147
-    [_shouldStartLoadLock unlockWithCondition:0];
148
-  } else {
149
-    RCTLogWarn(@"startLoadWithResult invoked with invalid lockIdentifier: "
150
-               "got %lld, expected %lld", (long long)lockIdentifier, (long long)_shouldStartLoadLock.condition);
151
-  }
152
-}
153
-
154
-@end

ios/RNCWKWebView.h → ios/RNCWebView.h Näytä tiedosto

9
 #import <React/RCTDefines.h>
9
 #import <React/RCTDefines.h>
10
 #import <WebKit/WebKit.h>
10
 #import <WebKit/WebKit.h>
11
 
11
 
12
-@class RNCWKWebView;
12
+@class RNCWebView;
13
 
13
 
14
-@protocol RNCWKWebViewDelegate <NSObject>
14
+@protocol RNCWebViewDelegate <NSObject>
15
 
15
 
16
-- (BOOL)webView:(RNCWKWebView *)webView
16
+- (BOOL)webView:(RNCWebView *)webView
17
    shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
17
    shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
18
    withCallback:(RCTDirectEventBlock)callback;
18
    withCallback:(RCTDirectEventBlock)callback;
19
 
19
 
20
 @end
20
 @end
21
 
21
 
22
-@interface RNCWKWebView : RCTView
22
+@interface RNCWebView : RCTView
23
 
23
 
24
-@property (nonatomic, weak) id<RNCWKWebViewDelegate> delegate;
24
+@property (nonatomic, weak) id<RNCWebViewDelegate> delegate;
25
 @property (nonatomic, copy) NSDictionary *source;
25
 @property (nonatomic, copy) NSDictionary *source;
26
 @property (nonatomic, assign) BOOL messagingEnabled;
26
 @property (nonatomic, assign) BOOL messagingEnabled;
27
 @property (nonatomic, copy) NSString *injectedJavaScript;
27
 @property (nonatomic, copy) NSString *injectedJavaScript;

ios/RNCWKWebView.m → ios/RNCWebView.m Näytä tiedosto

5
  * LICENSE file in the root directory of this source tree.
5
  * LICENSE file in the root directory of this source tree.
6
  */
6
  */
7
 
7
 
8
-#import "RNCWKWebView.h"
8
+#import "RNCWebView.h"
9
 #import <React/RCTConvert.h>
9
 #import <React/RCTConvert.h>
10
 #import <React/RCTAutoInsetsProtocol.h>
10
 #import <React/RCTAutoInsetsProtocol.h>
11
 #import "RNCWKProcessPoolManager.h"
11
 #import "RNCWKProcessPoolManager.h"
27
 }
27
 }
28
 @end
28
 @end
29
 
29
 
30
-@interface RNCWKWebView () <WKUIDelegate, WKNavigationDelegate, WKScriptMessageHandler, UIScrollViewDelegate, RCTAutoInsetsProtocol>
30
+@interface RNCWebView () <WKUIDelegate, WKNavigationDelegate, WKScriptMessageHandler, UIScrollViewDelegate, RCTAutoInsetsProtocol>
31
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
31
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingStart;
32
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
32
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingFinish;
33
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingError;
33
 @property (nonatomic, copy) RCTDirectEventBlock onLoadingError;
38
 @property (nonatomic, copy) WKWebView *webView;
38
 @property (nonatomic, copy) WKWebView *webView;
39
 @end
39
 @end
40
 
40
 
41
-@implementation RNCWKWebView
41
+@implementation RNCWebView
42
 {
42
 {
43
   UIColor * _savedBackgroundColor;
43
   UIColor * _savedBackgroundColor;
44
   BOOL _savedHideKeyboardAccessoryView;
44
   BOOL _savedHideKeyboardAccessoryView;
45
   BOOL _savedKeyboardDisplayRequiresUserAction;
45
   BOOL _savedKeyboardDisplayRequiresUserAction;
46
-  
46
+
47
   // Workaround for StatusBar appearance bug for iOS 12
47
   // Workaround for StatusBar appearance bug for iOS 12
48
   // https://github.com/react-native-community/react-native-webview/issues/62
48
   // https://github.com/react-native-community/react-native-webview/issues/62
49
   BOOL _isFullScreenVideoOpen;
49
   BOOL _isFullScreenVideoOpen;
86
       addObserver:self
86
       addObserver:self
87
       selector:@selector(keyboardWillShow)
87
       selector:@selector(keyboardWillShow)
88
       name:UIKeyboardWillShowNotification object:nil];
88
       name:UIKeyboardWillShowNotification object:nil];
89
-    
89
+
90
     // Workaround for StatusBar appearance bug for iOS 12
90
     // Workaround for StatusBar appearance bug for iOS 12
91
     // https://github.com/react-native-community/react-native-webview/issues/62
91
     // https://github.com/react-native-community/react-native-webview/issues/62
92
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toggleFullScreenVideoStatusBars) name:@"_MRMediaRemotePlayerSupportedCommandsDidChangeNotification" object:nil];
92
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toggleFullScreenVideoStatusBars) name:@"_MRMediaRemotePlayerSupportedCommandsDidChangeNotification" object:nil];
93
   }
93
   }
94
-  
94
+
95
   return self;
95
   return self;
96
 }
96
 }
97
 
97
 
449
         _savedKeyboardDisplayRequiresUserAction = keyboardDisplayRequiresUserAction;
449
         _savedKeyboardDisplayRequiresUserAction = keyboardDisplayRequiresUserAction;
450
         return;
450
         return;
451
     }
451
     }
452
-  
452
+
453
     if (_savedKeyboardDisplayRequiresUserAction == true) {
453
     if (_savedKeyboardDisplayRequiresUserAction == true) {
454
         return;
454
         return;
455
     }
455
     }
456
-  
456
+
457
     UIView* subview;
457
     UIView* subview;
458
-  
458
+
459
     for (UIView* view in _webView.scrollView.subviews) {
459
     for (UIView* view in _webView.scrollView.subviews) {
460
         if([[view.class description] hasPrefix:@"WK"])
460
         if([[view.class description] hasPrefix:@"WK"])
461
             subview = view;
461
             subview = view;
462
     }
462
     }
463
-  
463
+
464
     if(subview == nil) return;
464
     if(subview == nil) return;
465
-  
465
+
466
     Class class = subview.class;
466
     Class class = subview.class;
467
-  
467
+
468
     NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0};
468
     NSOperatingSystemVersion iOS_11_3_0 = (NSOperatingSystemVersion){11, 3, 0};
469
     NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0};
469
     NSOperatingSystemVersion iOS_12_2_0 = (NSOperatingSystemVersion){12, 2, 0};
470
     NSOperatingSystemVersion iOS_13_0_0 = (NSOperatingSystemVersion){13, 0, 0};
470
     NSOperatingSystemVersion iOS_13_0_0 = (NSOperatingSystemVersion){13, 0, 0};
507
             ((void (*)(id, SEL, void*, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3);
507
             ((void (*)(id, SEL, void*, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3);
508
         });
508
         });
509
     }
509
     }
510
-  
510
+
511
     method_setImplementation(method, override);
511
     method_setImplementation(method, override);
512
 }
512
 }
513
 
513
 
623
 {
623
 {
624
   [super layoutSubviews];
624
   [super layoutSubviews];
625
 
625
 
626
-  // Ensure webview takes the position and dimensions of RNCWKWebView
626
+  // Ensure webview takes the position and dimensions of RNCWebView
627
   _webView.frame = self.bounds;
627
   _webView.frame = self.bounds;
628
   _webView.scrollView.contentInset = _contentInset;
628
   _webView.scrollView.contentInset = _contentInset;
629
 }
629
 }

+ 17
- 29
ios/RNCWebView.xcodeproj/project.pbxproj Näytä tiedosto

8
 
8
 
9
 /* Begin PBXBuildFile section */
9
 /* Begin PBXBuildFile section */
10
 		3515965E21A3C86000623BFA /* RNCWKProcessPoolManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 3515965D21A3C86000623BFA /* RNCWKProcessPoolManager.m */; };
10
 		3515965E21A3C86000623BFA /* RNCWKProcessPoolManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 3515965D21A3C86000623BFA /* RNCWKProcessPoolManager.m */; };
11
-		E914DBF6214474710071092B /* RNCUIWebViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E914DBF3214474710071092B /* RNCUIWebViewManager.m */; };
12
-		E914DBF7214474710071092B /* RNCUIWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = E914DBF4214474710071092B /* RNCUIWebView.m */; };
13
-		E91B351D21446E6C00F9801F /* RNCWKWebViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E91B351B21446E6C00F9801F /* RNCWKWebViewManager.m */; };
14
-		E91B351E21446E6C00F9801F /* RNCWKWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = E91B351C21446E6C00F9801F /* RNCWKWebView.m */; };
11
+		E91B351D21446E6C00F9801F /* RNCWebViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E91B351B21446E6C00F9801F /* RNCWebViewManager.m */; };
12
+		E91B351E21446E6C00F9801F /* RNCWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = E91B351C21446E6C00F9801F /* RNCWebView.m */; };
15
 /* End PBXBuildFile section */
13
 /* End PBXBuildFile section */
16
 
14
 
17
 /* Begin PBXCopyFilesBuildPhase section */
15
 /* Begin PBXCopyFilesBuildPhase section */
30
 		134814201AA4EA6300B7C361 /* libRNCWebView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNCWebView.a; sourceTree = BUILT_PRODUCTS_DIR; };
28
 		134814201AA4EA6300B7C361 /* libRNCWebView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNCWebView.a; sourceTree = BUILT_PRODUCTS_DIR; };
31
 		3515965D21A3C86000623BFA /* RNCWKProcessPoolManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNCWKProcessPoolManager.m; sourceTree = "<group>"; };
29
 		3515965D21A3C86000623BFA /* RNCWKProcessPoolManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNCWKProcessPoolManager.m; sourceTree = "<group>"; };
32
 		3515965F21A3C87E00623BFA /* RNCWKProcessPoolManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNCWKProcessPoolManager.h; sourceTree = "<group>"; };
30
 		3515965F21A3C87E00623BFA /* RNCWKProcessPoolManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNCWKProcessPoolManager.h; sourceTree = "<group>"; };
33
-		E914DBF2214474710071092B /* RNCUIWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCUIWebView.h; sourceTree = "<group>"; };
34
-		E914DBF3214474710071092B /* RNCUIWebViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCUIWebViewManager.m; sourceTree = "<group>"; };
35
-		E914DBF4214474710071092B /* RNCUIWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCUIWebView.m; sourceTree = "<group>"; };
36
-		E914DBF5214474710071092B /* RNCUIWebViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCUIWebViewManager.h; sourceTree = "<group>"; };
37
-		E91B351921446E6C00F9801F /* RNCWKWebViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCWKWebViewManager.h; sourceTree = "<group>"; };
38
-		E91B351A21446E6C00F9801F /* RNCWKWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCWKWebView.h; sourceTree = "<group>"; };
39
-		E91B351B21446E6C00F9801F /* RNCWKWebViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCWKWebViewManager.m; sourceTree = "<group>"; };
40
-		E91B351C21446E6C00F9801F /* RNCWKWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCWKWebView.m; sourceTree = "<group>"; };
31
+		E91B351921446E6C00F9801F /* RNCWebViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCWebViewManager.h; sourceTree = "<group>"; };
32
+		E91B351A21446E6C00F9801F /* RNCWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCWebView.h; sourceTree = "<group>"; };
33
+		E91B351B21446E6C00F9801F /* RNCWebViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCWebViewManager.m; sourceTree = "<group>"; };
34
+		E91B351C21446E6C00F9801F /* RNCWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCWebView.m; sourceTree = "<group>"; };
41
 /* End PBXFileReference section */
35
 /* End PBXFileReference section */
42
 
36
 
43
 /* Begin PBXFrameworksBuildPhase section */
37
 /* Begin PBXFrameworksBuildPhase section */
62
 		58B511D21A9E6C8500147676 = {
56
 		58B511D21A9E6C8500147676 = {
63
 			isa = PBXGroup;
57
 			isa = PBXGroup;
64
 			children = (
58
 			children = (
65
-				E914DBF2214474710071092B /* RNCUIWebView.h */,
66
-				E914DBF4214474710071092B /* RNCUIWebView.m */,
67
-				E914DBF5214474710071092B /* RNCUIWebViewManager.h */,
68
-				E914DBF3214474710071092B /* RNCUIWebViewManager.m */,
69
-				E91B351A21446E6C00F9801F /* RNCWKWebView.h */,
70
-				E91B351C21446E6C00F9801F /* RNCWKWebView.m */,
71
-				E91B351921446E6C00F9801F /* RNCWKWebViewManager.h */,
72
-				E91B351B21446E6C00F9801F /* RNCWKWebViewManager.m */,
59
+				E91B351A21446E6C00F9801F /* RNCWebView.h */,
60
+				E91B351C21446E6C00F9801F /* RNCWebView.m */,
61
+				E91B351921446E6C00F9801F /* RNCWebViewManager.h */,
62
+				E91B351B21446E6C00F9801F /* RNCWebViewManager.m */,
73
 				3515965D21A3C86000623BFA /* RNCWKProcessPoolManager.m */,
63
 				3515965D21A3C86000623BFA /* RNCWKProcessPoolManager.m */,
74
 				3515965F21A3C87E00623BFA /* RNCWKProcessPoolManager.h */,
64
 				3515965F21A3C87E00623BFA /* RNCWKProcessPoolManager.h */,
75
 				134814211AA4EA7D00B7C361 /* Products */,
65
 				134814211AA4EA7D00B7C361 /* Products */,
112
 			};
102
 			};
113
 			buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNCWebView" */;
103
 			buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNCWebView" */;
114
 			compatibilityVersion = "Xcode 3.2";
104
 			compatibilityVersion = "Xcode 3.2";
115
-			developmentRegion = English;
105
+			developmentRegion = en;
116
 			hasScannedForEncodings = 0;
106
 			hasScannedForEncodings = 0;
117
 			knownRegions = (
107
 			knownRegions = (
118
 				en,
108
 				en,
132
 			isa = PBXSourcesBuildPhase;
122
 			isa = PBXSourcesBuildPhase;
133
 			buildActionMask = 2147483647;
123
 			buildActionMask = 2147483647;
134
 			files = (
124
 			files = (
135
-				E91B351D21446E6C00F9801F /* RNCWKWebViewManager.m in Sources */,
136
-				E914DBF7214474710071092B /* RNCUIWebView.m in Sources */,
137
-				E914DBF6214474710071092B /* RNCUIWebViewManager.m in Sources */,
138
-				E91B351E21446E6C00F9801F /* RNCWKWebView.m in Sources */,
125
+				E91B351D21446E6C00F9801F /* RNCWebViewManager.m in Sources */,
126
+				E91B351E21446E6C00F9801F /* RNCWebView.m in Sources */,
139
 				3515965E21A3C86000623BFA /* RNCWKProcessPoolManager.m in Sources */,
127
 				3515965E21A3C86000623BFA /* RNCWKProcessPoolManager.m in Sources */,
140
 			);
128
 			);
141
 			runOnlyForDeploymentPostprocessing = 0;
129
 			runOnlyForDeploymentPostprocessing = 0;
227
 		58B511F01A9E6C8500147676 /* Debug */ = {
215
 		58B511F01A9E6C8500147676 /* Debug */ = {
228
 			isa = XCBuildConfiguration;
216
 			isa = XCBuildConfiguration;
229
 			buildSettings = {
217
 			buildSettings = {
218
+				FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../node_modules/react-native/**";
230
 				HEADER_SEARCH_PATHS = (
219
 				HEADER_SEARCH_PATHS = (
231
 					"$(inherited)",
220
 					"$(inherited)",
232
-					/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
233
-					"$(SRCROOT)/../../../React/**",
221
+					"$(SRCROOT)/../node_modules/react-native/React/**",
234
 					"$(SRCROOT)/../../react-native/React/**",
222
 					"$(SRCROOT)/../../react-native/React/**",
235
 				);
223
 				);
236
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
224
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
243
 		58B511F11A9E6C8500147676 /* Release */ = {
231
 		58B511F11A9E6C8500147676 /* Release */ = {
244
 			isa = XCBuildConfiguration;
232
 			isa = XCBuildConfiguration;
245
 			buildSettings = {
233
 			buildSettings = {
234
+				FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../node_modules/react-native/**";
246
 				HEADER_SEARCH_PATHS = (
235
 				HEADER_SEARCH_PATHS = (
247
 					"$(inherited)",
236
 					"$(inherited)",
248
-					/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
249
-					"$(SRCROOT)/../../../React/**",
237
+					"$(SRCROOT)/../node_modules/react-native/React/**",
250
 					"$(SRCROOT)/../../react-native/React/**",
238
 					"$(SRCROOT)/../../react-native/React/**",
251
 				);
239
 				);
252
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
240
 				LIBRARY_SEARCH_PATHS = "$(inherited)";

ios/RNCWKWebViewManager.h → ios/RNCWebViewManager.h Näytä tiedosto

7
 
7
 
8
 #import <React/RCTViewManager.h>
8
 #import <React/RCTViewManager.h>
9
 
9
 
10
-@interface RNCWKWebViewManager : RCTViewManager
10
+@interface RNCWebViewManager : RCTViewManager
11
 @end
11
 @end

ios/RNCWKWebViewManager.m → ios/RNCWebViewManager.m Näytä tiedosto

5
  * LICENSE file in the root directory of this source tree.
5
  * LICENSE file in the root directory of this source tree.
6
  */
6
  */
7
 
7
 
8
-#import "RNCWKWebViewManager.h"
8
+#import "RNCWebViewManager.h"
9
 
9
 
10
 #import <React/RCTUIManager.h>
10
 #import <React/RCTUIManager.h>
11
 #import <React/RCTDefines.h>
11
 #import <React/RCTDefines.h>
12
-#import "RNCWKWebView.h"
12
+#import "RNCWebView.h"
13
 
13
 
14
-@interface RNCWKWebViewManager () <RNCWKWebViewDelegate>
14
+@interface RNCWebViewManager () <RNCWebViewDelegate>
15
 @end
15
 @end
16
 
16
 
17
 @implementation RCTConvert (UIScrollView)
17
 @implementation RCTConvert (UIScrollView)
27
 
27
 
28
 @end
28
 @end
29
 
29
 
30
-@implementation RNCWKWebViewManager
30
+@implementation RNCWebViewManager
31
 {
31
 {
32
   NSConditionLock *_shouldStartLoadLock;
32
   NSConditionLock *_shouldStartLoadLock;
33
   BOOL _shouldStartLoad;
33
   BOOL _shouldStartLoad;
37
 
37
 
38
 - (UIView *)view
38
 - (UIView *)view
39
 {
39
 {
40
-  RNCWKWebView *webView = [RNCWKWebView new];
40
+  RNCWebView *webView = [RNCWebView new];
41
   webView.delegate = self;
41
   webView.delegate = self;
42
   return webView;
42
   return webView;
43
 }
43
 }
80
 
80
 
81
 RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
81
 RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
82
 {
82
 {
83
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
84
-    RNCWKWebView *view = viewRegistry[reactTag];
85
-    if (![view isKindOfClass:[RNCWKWebView class]]) {
86
-      RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
83
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWebView *> *viewRegistry) {
84
+    RNCWebView *view = viewRegistry[reactTag];
85
+    if (![view isKindOfClass:[RNCWebView class]]) {
86
+      RCTLogError(@"Invalid view returned from registry, expecting RNCWebView, got: %@", view);
87
     } else {
87
     } else {
88
       [view postMessage:message];
88
       [view postMessage:message];
89
     }
89
     }
90
   }];
90
   }];
91
 }
91
 }
92
 
92
 
93
-RCT_CUSTOM_VIEW_PROPERTY(bounces, BOOL, RNCWKWebView) {
93
+RCT_CUSTOM_VIEW_PROPERTY(bounces, BOOL, RNCWebView) {
94
   view.bounces = json == nil ? true : [RCTConvert BOOL: json];
94
   view.bounces = json == nil ? true : [RCTConvert BOOL: json];
95
 }
95
 }
96
 
96
 
97
-RCT_CUSTOM_VIEW_PROPERTY(useSharedProcessPool, BOOL, RNCWKWebView) {
97
+RCT_CUSTOM_VIEW_PROPERTY(useSharedProcessPool, BOOL, RNCWebView) {
98
   view.useSharedProcessPool = json == nil ? true : [RCTConvert BOOL: json];
98
   view.useSharedProcessPool = json == nil ? true : [RCTConvert BOOL: json];
99
 }
99
 }
100
 
100
 
101
-RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RNCWKWebView) {
101
+RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RNCWebView) {
102
   view.scrollEnabled = json == nil ? true : [RCTConvert BOOL: json];
102
   view.scrollEnabled = json == nil ? true : [RCTConvert BOOL: json];
103
 }
103
 }
104
 
104
 
105
-RCT_CUSTOM_VIEW_PROPERTY(sharedCookiesEnabled, BOOL, RNCWKWebView) {
105
+RCT_CUSTOM_VIEW_PROPERTY(sharedCookiesEnabled, BOOL, RNCWebView) {
106
     view.sharedCookiesEnabled = json == nil ? false : [RCTConvert BOOL: json];
106
     view.sharedCookiesEnabled = json == nil ? false : [RCTConvert BOOL: json];
107
 }
107
 }
108
 
108
 
109
-RCT_CUSTOM_VIEW_PROPERTY(decelerationRate, CGFloat, RNCWKWebView) {
109
+RCT_CUSTOM_VIEW_PROPERTY(decelerationRate, CGFloat, RNCWebView) {
110
   view.decelerationRate = json == nil ? UIScrollViewDecelerationRateNormal : [RCTConvert CGFloat: json];
110
   view.decelerationRate = json == nil ? UIScrollViewDecelerationRateNormal : [RCTConvert CGFloat: json];
111
 }
111
 }
112
 
112
 
113
-RCT_CUSTOM_VIEW_PROPERTY(directionalLockEnabled, BOOL, RNCWKWebView) {
113
+RCT_CUSTOM_VIEW_PROPERTY(directionalLockEnabled, BOOL, RNCWebView) {
114
     view.directionalLockEnabled = json == nil ? true : [RCTConvert BOOL: json];
114
     view.directionalLockEnabled = json == nil ? true : [RCTConvert BOOL: json];
115
 }
115
 }
116
 
116
 
117
-RCT_CUSTOM_VIEW_PROPERTY(showsHorizontalScrollIndicator, BOOL, RNCWKWebView) {
117
+RCT_CUSTOM_VIEW_PROPERTY(showsHorizontalScrollIndicator, BOOL, RNCWebView) {
118
   view.showsHorizontalScrollIndicator = json == nil ? true : [RCTConvert BOOL: json];
118
   view.showsHorizontalScrollIndicator = json == nil ? true : [RCTConvert BOOL: json];
119
 }
119
 }
120
 
120
 
121
-RCT_CUSTOM_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL, RNCWKWebView) {
121
+RCT_CUSTOM_VIEW_PROPERTY(showsVerticalScrollIndicator, BOOL, RNCWebView) {
122
   view.showsVerticalScrollIndicator = json == nil ? true : [RCTConvert BOOL: json];
122
   view.showsVerticalScrollIndicator = json == nil ? true : [RCTConvert BOOL: json];
123
 }
123
 }
124
 
124
 
125
-RCT_CUSTOM_VIEW_PROPERTY(keyboardDisplayRequiresUserAction, BOOL, RNCWKWebView) {
125
+RCT_CUSTOM_VIEW_PROPERTY(keyboardDisplayRequiresUserAction, BOOL, RNCWebView) {
126
   view.keyboardDisplayRequiresUserAction = json == nil ? true : [RCTConvert BOOL: json];
126
   view.keyboardDisplayRequiresUserAction = json == nil ? true : [RCTConvert BOOL: json];
127
 }
127
 }
128
 
128
 
129
 RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
129
 RCT_EXPORT_METHOD(injectJavaScript:(nonnull NSNumber *)reactTag script:(NSString *)script)
130
 {
130
 {
131
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
132
-    RNCWKWebView *view = viewRegistry[reactTag];
133
-    if (![view isKindOfClass:[RNCWKWebView class]]) {
134
-      RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
131
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWebView *> *viewRegistry) {
132
+    RNCWebView *view = viewRegistry[reactTag];
133
+    if (![view isKindOfClass:[RNCWebView class]]) {
134
+      RCTLogError(@"Invalid view returned from registry, expecting RNCWebView, got: %@", view);
135
     } else {
135
     } else {
136
       [view injectJavaScript:script];
136
       [view injectJavaScript:script];
137
     }
137
     }
140
 
140
 
141
 RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
141
 RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
142
 {
142
 {
143
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
144
-    RNCWKWebView *view = viewRegistry[reactTag];
145
-    if (![view isKindOfClass:[RNCWKWebView class]]) {
146
-      RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
143
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWebView *> *viewRegistry) {
144
+    RNCWebView *view = viewRegistry[reactTag];
145
+    if (![view isKindOfClass:[RNCWebView class]]) {
146
+      RCTLogError(@"Invalid view returned from registry, expecting RNCWebView, got: %@", view);
147
     } else {
147
     } else {
148
       [view goBack];
148
       [view goBack];
149
     }
149
     }
152
 
152
 
153
 RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
153
 RCT_EXPORT_METHOD(goForward:(nonnull NSNumber *)reactTag)
154
 {
154
 {
155
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
156
-    RNCWKWebView *view = viewRegistry[reactTag];
157
-    if (![view isKindOfClass:[RNCWKWebView class]]) {
158
-      RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
155
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWebView *> *viewRegistry) {
156
+    RNCWebView *view = viewRegistry[reactTag];
157
+    if (![view isKindOfClass:[RNCWebView class]]) {
158
+      RCTLogError(@"Invalid view returned from registry, expecting RNCWebView, got: %@", view);
159
     } else {
159
     } else {
160
       [view goForward];
160
       [view goForward];
161
     }
161
     }
164
 
164
 
165
 RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
165
 RCT_EXPORT_METHOD(reload:(nonnull NSNumber *)reactTag)
166
 {
166
 {
167
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
168
-    RNCWKWebView *view = viewRegistry[reactTag];
169
-    if (![view isKindOfClass:[RNCWKWebView class]]) {
170
-      RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
167
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWebView *> *viewRegistry) {
168
+    RNCWebView *view = viewRegistry[reactTag];
169
+    if (![view isKindOfClass:[RNCWebView class]]) {
170
+      RCTLogError(@"Invalid view returned from registry, expecting RNCWebView, got: %@", view);
171
     } else {
171
     } else {
172
       [view reload];
172
       [view reload];
173
     }
173
     }
176
 
176
 
177
 RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
177
 RCT_EXPORT_METHOD(stopLoading:(nonnull NSNumber *)reactTag)
178
 {
178
 {
179
-  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWKWebView *> *viewRegistry) {
180
-    RNCWKWebView *view = viewRegistry[reactTag];
181
-    if (![view isKindOfClass:[RNCWKWebView class]]) {
182
-      RCTLogError(@"Invalid view returned from registry, expecting RNCWKWebView, got: %@", view);
179
+  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNCWebView *> *viewRegistry) {
180
+    RNCWebView *view = viewRegistry[reactTag];
181
+    if (![view isKindOfClass:[RNCWebView class]]) {
182
+      RCTLogError(@"Invalid view returned from registry, expecting RNCWebView, got: %@", view);
183
     } else {
183
     } else {
184
       [view stopLoading];
184
       [view stopLoading];
185
     }
185
     }
188
 
188
 
189
 #pragma mark - Exported synchronous methods
189
 #pragma mark - Exported synchronous methods
190
 
190
 
191
-- (BOOL)          webView:(RNCWKWebView *)webView
191
+- (BOOL)          webView:(RNCWebView *)webView
192
 shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
192
 shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
193
              withCallback:(RCTDirectEventBlock)callback
193
              withCallback:(RCTDirectEventBlock)callback
194
 {
194
 {

+ 3
- 3
package.json Näytä tiedosto

8
     "Thibault Malbranche <malbranche.thibault@gmail.com>"
8
     "Thibault Malbranche <malbranche.thibault@gmail.com>"
9
   ],
9
   ],
10
   "license": "MIT",
10
   "license": "MIT",
11
-  "version": "6.11.1",
11
+  "version": "7.0.1",
12
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
12
   "homepage": "https://github.com/react-native-community/react-native-webview#readme",
13
   "scripts": {
13
   "scripts": {
14
     "ci": "CI=true && yarn lint && yarn test",
14
     "ci": "CI=true && yarn lint && yarn test",
20
   },
20
   },
21
   "peerDependencies": {
21
   "peerDependencies": {
22
     "react": "^16.0",
22
     "react": "^16.0",
23
-    "react-native": ">=0.57 <0.60"
23
+    "react-native": ">=0.60 <0.62"
24
   },
24
   },
25
   "dependencies": {
25
   "dependencies": {
26
     "escape-string-regexp": "1.0.5",
26
     "escape-string-regexp": "1.0.5",
48
     "jest": "24.5.0",
48
     "jest": "24.5.0",
49
     "metro-react-native-babel-preset": "0.53.1",
49
     "metro-react-native-babel-preset": "0.53.1",
50
     "react": "16.8.3",
50
     "react": "16.8.3",
51
-    "react-native": "0.59.1",
51
+    "react-native": "0.60.5",
52
     "semantic-release": "15.10.3",
52
     "semantic-release": "15.10.3",
53
     "typescript": "3.3.3333"
53
     "typescript": "3.3.3333"
54
   },
54
   },

+ 4
- 5
src/WebView.android.tsx Näytä tiedosto

15
 import {
15
 import {
16
   defaultOriginWhitelist,
16
   defaultOriginWhitelist,
17
   createOnShouldStartLoadWithRequest,
17
   createOnShouldStartLoadWithRequest,
18
-  getViewManagerConfig,
19
   defaultRenderError,
18
   defaultRenderError,
20
   defaultRenderLoading,
19
   defaultRenderLoading,
21
 } from './WebViewShared';
20
 } from './WebViewShared';
68
 
67
 
69
   webViewRef = React.createRef<NativeWebViewAndroid>();
68
   webViewRef = React.createRef<NativeWebViewAndroid>();
70
 
69
 
71
-  getCommands = () => getViewManagerConfig('RNCWebView').Commands;
70
+  getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
72
 
71
 
73
   goForward = () => {
72
   goForward = () => {
74
     UIManager.dispatchViewManagerCommand(
73
     UIManager.dispatchViewManagerCommand(
107
 
106
 
108
   requestFocus = () => {
107
   requestFocus = () => {
109
     UIManager.dispatchViewManagerCommand(
108
     UIManager.dispatchViewManagerCommand(
110
-        this.getWebViewHandle(),
111
-        this.getCommands().requestFocus,
112
-        null,
109
+      this.getWebViewHandle(),
110
+      this.getCommands().requestFocus,
111
+      null,
113
     );
112
     );
114
   };
113
   };
115
 
114
 

+ 13
- 79
src/WebView.ios.tsx Näytä tiedosto

13
 import {
13
 import {
14
   defaultOriginWhitelist,
14
   defaultOriginWhitelist,
15
   createOnShouldStartLoadWithRequest,
15
   createOnShouldStartLoadWithRequest,
16
-  getViewManagerConfig,
17
   defaultRenderError,
16
   defaultRenderError,
18
   defaultRenderLoading,
17
   defaultRenderLoading,
19
 } from './WebViewShared';
18
 } from './WebViewShared';
28
   ViewManager,
27
   ViewManager,
29
   State,
28
   State,
30
   CustomUIManager,
29
   CustomUIManager,
31
-  WebViewNativeConfig,
32
 } from './WebViewTypes';
30
 } from './WebViewTypes';
33
 
31
 
34
 import styles from './WebView.styles';
32
 import styles from './WebView.styles';
36
 const UIManager = NotTypedUIManager as CustomUIManager;
34
 const UIManager = NotTypedUIManager as CustomUIManager;
37
 
35
 
38
 const { resolveAssetSource } = Image;
36
 const { resolveAssetSource } = Image;
39
-let didWarnAboutUIWebViewUsage = false;
40
-// Imported from https://github.com/facebook/react-native/blob/master/Libraries/Components/ScrollView/processDecelerationRate.js
41
 const processDecelerationRate = (
37
 const processDecelerationRate = (
42
   decelerationRate: DecelerationRateConstant | number | undefined,
38
   decelerationRate: DecelerationRateConstant | number | undefined,
43
 ) => {
39
 ) => {
50
   return newDecelerationRate;
46
   return newDecelerationRate;
51
 };
47
 };
52
 
48
 
53
-const RNCUIWebViewManager = NativeModules.RNCUIWebViewManager as ViewManager;
54
-const RNCWKWebViewManager = NativeModules.RNCWKWebViewManager as ViewManager;
49
+const RNCWebViewManager = NativeModules.RNCWebViewManager as ViewManager;
55
 
50
 
56
-const RNCUIWebView: typeof NativeWebViewIOS = requireNativeComponent(
57
-  'RNCUIWebView',
58
-);
59
-const RNCWKWebView: typeof NativeWebViewIOS = requireNativeComponent(
60
-  'RNCWKWebView',
51
+const RNCWebView: typeof NativeWebViewIOS = requireNativeComponent(
52
+  'RNCWebView',
61
 );
53
 );
62
 
54
 
63
 class WebView extends React.Component<IOSWebViewProps, State> {
55
 class WebView extends React.Component<IOSWebViewProps, State> {
64
   static defaultProps = {
56
   static defaultProps = {
65
-    useWebKit: true,
66
     javaScriptEnabled: true,
57
     javaScriptEnabled: true,
67
     cacheEnabled: true,
58
     cacheEnabled: true,
68
     originWhitelist: defaultOriginWhitelist,
59
     originWhitelist: defaultOriginWhitelist,
81
 
72
 
82
   webViewRef = React.createRef<NativeWebViewIOS>();
73
   webViewRef = React.createRef<NativeWebViewIOS>();
83
 
74
 
84
-  // eslint-disable-next-line camelcase
85
-  UNSAFE_componentWillMount() {
86
-    if (!this.props.useWebKit && !didWarnAboutUIWebViewUsage) {
87
-      didWarnAboutUIWebViewUsage = true;
88
-      console.warn(
89
-        'UIWebView is deprecated and will be removed soon, please use WKWebView (do not override useWebkit={true} prop),'
90
-          + ' more infos here: https://github.com/react-native-community/react-native-webview/issues/312',
91
-      );
92
-    }
93
-    if (
94
-      this.props.useWebKit === true
95
-      && this.props.scalesPageToFit !== undefined
96
-    ) {
97
-      console.warn(
98
-        'The scalesPageToFit property is not supported when useWebKit = true',
99
-      );
100
-    }
101
-    if (
102
-      !this.props.useWebKit
103
-      && this.props.allowsBackForwardNavigationGestures
104
-    ) {
105
-      console.warn(
106
-        'The allowsBackForwardNavigationGestures property is not supported when useWebKit = false',
107
-      );
108
-    }
109
-
110
-    if (!this.props.useWebKit && this.props.incognito) {
111
-      console.warn(
112
-        'The incognito property is not supported when useWebKit = false',
113
-      );
114
-    }
115
-  }
116
-
117
   // eslint-disable-next-line react/sort-comp
75
   // eslint-disable-next-line react/sort-comp
118
-  getCommands = () =>
119
-    !this.props.useWebKit
120
-      ? getViewManagerConfig('RNCUIWebView').Commands
121
-      : getViewManagerConfig('RNCWKWebView').Commands;
76
+  getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
122
 
77
 
123
   /**
78
   /**
124
    * Go forward one page in the web view's history.
79
    * Go forward one page in the web view's history.
170
    */
125
    */
171
   requestFocus = () => {
126
   requestFocus = () => {
172
     UIManager.dispatchViewManagerCommand(
127
     UIManager.dispatchViewManagerCommand(
173
-        this.getWebViewHandle(),
174
-        this.getCommands().requestFocus,
175
-        null,
128
+      this.getWebViewHandle(),
129
+      this.getCommands().requestFocus,
130
+      null,
176
     );
131
     );
177
   };
132
   };
178
 
133
 
285
     _url: string,
240
     _url: string,
286
     lockIdentifier: number,
241
     lockIdentifier: number,
287
   ) => {
242
   ) => {
288
-    let { viewManager }: WebViewNativeConfig = this.props.nativeConfig || {};
243
+    const viewManager
244
+      = (this.props.nativeConfig && this.props.nativeConfig.viewManager)
245
+      || RNCWebViewManager;
289
 
246
 
290
-    if (this.props.useWebKit) {
291
-      viewManager = viewManager || RNCWKWebViewManager;
292
-    } else {
293
-      viewManager = viewManager || RNCUIWebViewManager;
294
-    }
295
-    invariant(viewManager != null, 'viewManager expected to be non-null');
296
     viewManager.startLoadWithResult(!!shouldStart, lockIdentifier);
247
     viewManager.startLoadWithResult(!!shouldStart, lockIdentifier);
297
   };
248
   };
298
 
249
 
299
   componentDidUpdate(prevProps: IOSWebViewProps) {
250
   componentDidUpdate(prevProps: IOSWebViewProps) {
300
-    if (!(prevProps.useWebKit && this.props.useWebKit)) {
301
-      return;
302
-    }
303
-
304
     this.showRedboxOnPropChanges(prevProps, 'allowsInlineMediaPlayback');
251
     this.showRedboxOnPropChanges(prevProps, 'allowsInlineMediaPlayback');
305
     this.showRedboxOnPropChanges(prevProps, 'incognito');
252
     this.showRedboxOnPropChanges(prevProps, 'incognito');
306
     this.showRedboxOnPropChanges(prevProps, 'mediaPlaybackRequiresUserAction');
253
     this.showRedboxOnPropChanges(prevProps, 'mediaPlaybackRequiresUserAction');
307
     this.showRedboxOnPropChanges(prevProps, 'dataDetectorTypes');
254
     this.showRedboxOnPropChanges(prevProps, 'dataDetectorTypes');
308
-
309
-    if (this.props.scalesPageToFit !== undefined) {
310
-      console.warn(
311
-        'The scalesPageToFit property is not supported when useWebKit = true',
312
-      );
313
-    }
314
   }
255
   }
315
 
256
 
316
   showRedboxOnPropChanges(
257
   showRedboxOnPropChanges(
333
       originWhitelist,
274
       originWhitelist,
334
       renderError,
275
       renderError,
335
       renderLoading,
276
       renderLoading,
336
-      scalesPageToFit = this.props.useWebKit ? undefined : true,
337
       style,
277
       style,
338
-      useWebKit,
339
       ...otherProps
278
       ...otherProps
340
     } = this.props;
279
     } = this.props;
341
 
280
 
368
 
307
 
369
     const decelerationRate = processDecelerationRate(decelerationRateProp);
308
     const decelerationRate = processDecelerationRate(decelerationRateProp);
370
 
309
 
371
-    let NativeWebView = nativeConfig.component as typeof NativeWebViewIOS;
372
-
373
-    if (useWebKit) {
374
-      NativeWebView = NativeWebView || RNCWKWebView;
375
-    } else {
376
-      NativeWebView = NativeWebView || RNCUIWebView;
377
-    }
310
+    const NativeWebView
311
+      = (nativeConfig.component as typeof NativeWebViewIOS | undefined)
312
+      || RNCWebView;
378
 
313
 
379
     const webView = (
314
     const webView = (
380
       <NativeWebView
315
       <NativeWebView
390
         onScroll={this.props.onScroll}
325
         onScroll={this.props.onScroll}
391
         onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
326
         onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
392
         ref={this.webViewRef}
327
         ref={this.webViewRef}
393
-        scalesPageToFit={scalesPageToFit}
394
         // TODO: find a better way to type this.
328
         // TODO: find a better way to type this.
395
         source={resolveAssetSource(this.props.source as ImageSourcePropType)}
329
         source={resolveAssetSource(this.props.source as ImageSourcePropType)}
396
         style={webViewStyles}
330
         style={webViewStyles}

+ 1
- 20
src/WebViewShared.tsx Näytä tiedosto

1
 import escapeStringRegexp from 'escape-string-regexp';
1
 import escapeStringRegexp from 'escape-string-regexp';
2
 import React from 'react';
2
 import React from 'react';
3
-import {
4
-  Linking,
5
-  UIManager as NotTypedUIManager,
6
-  View,
7
-  ActivityIndicator,
8
-  Text,
9
-} from 'react-native';
3
+import { Linking, View, ActivityIndicator, Text } from 'react-native';
10
 import {
4
 import {
11
   WebViewNavigationEvent,
5
   WebViewNavigationEvent,
12
   OnShouldStartLoadWithRequest,
6
   OnShouldStartLoadWithRequest,
13
-  CustomUIManager,
14
 } from './WebViewTypes';
7
 } from './WebViewTypes';
15
 import styles from './WebView.styles';
8
 import styles from './WebView.styles';
16
 
9
 
17
-const UIManager = NotTypedUIManager as CustomUIManager;
18
-
19
 const defaultOriginWhitelist = ['http://*', 'https://*'];
10
 const defaultOriginWhitelist = ['http://*', 'https://*'];
20
 
11
 
21
 const extractOrigin = (url: string): string => {
12
 const extractOrigin = (url: string): string => {
65
   };
56
   };
66
 };
57
 };
67
 
58
 
68
-const getViewManagerConfig = (
69
-  viewManagerName: 'RNCUIWebView' | 'RNCWKWebView' | 'RNCWebView',
70
-) => {
71
-  if (!UIManager.getViewManagerConfig) {
72
-    return UIManager[viewManagerName];
73
-  }
74
-  return UIManager.getViewManagerConfig(viewManagerName);
75
-};
76
-
77
 const defaultRenderLoading = () => (
59
 const defaultRenderLoading = () => (
78
   <View style={styles.loadingOrErrorView}>
60
   <View style={styles.loadingOrErrorView}>
79
     <ActivityIndicator />
61
     <ActivityIndicator />
95
 export {
77
 export {
96
   defaultOriginWhitelist,
78
   defaultOriginWhitelist,
97
   createOnShouldStartLoadWithRequest,
79
   createOnShouldStartLoadWithRequest,
98
-  getViewManagerConfig,
99
   defaultRenderLoading,
80
   defaultRenderLoading,
100
   defaultRenderError,
81
   defaultRenderError,
101
 };
82
 };

+ 31
- 36
src/WebViewTypes.ts Näytä tiedosto

22
 }
22
 }
23
 
23
 
24
 export interface CustomUIManager extends UIManagerStatic {
24
 export interface CustomUIManager extends UIManagerStatic {
25
-  getViewManagerConfig?: (
25
+  getViewManagerConfig: (
26
     name: string,
26
     name: string,
27
   ) => {
27
   ) => {
28
     Commands: WebViewCommands;
28
     Commands: WebViewCommands;
32
     command: Function,
32
     command: Function,
33
     params: object | null,
33
     params: object | null,
34
   ) => void;
34
   ) => void;
35
-  RNCUIWebView: {
36
-    Commands: WebViewCommands;
37
-  };
38
-  RNCWKWebView: {
39
-    Commands: WebViewCommands;
40
-  };
41
   RNCWebView: {
35
   RNCWebView: {
42
     Commands: WebViewCommands;
36
     Commands: WebViewCommands;
43
   };
37
   };
125
 
119
 
126
 export type WebViewEvent = NativeSyntheticEvent<WebViewNativeEvent>;
120
 export type WebViewEvent = NativeSyntheticEvent<WebViewNativeEvent>;
127
 
121
 
128
-export type WebViewProgressEvent = NativeSyntheticEvent<WebViewNativeProgressEvent>;
122
+export type WebViewProgressEvent = NativeSyntheticEvent<
123
+  WebViewNativeProgressEvent
124
+>;
129
 
125
 
130
 export type WebViewNavigationEvent = NativeSyntheticEvent<WebViewNavigation>;
126
 export type WebViewNavigationEvent = NativeSyntheticEvent<WebViewNavigation>;
131
 
127
 
133
 
129
 
134
 export type WebViewErrorEvent = NativeSyntheticEvent<WebViewError>;
130
 export type WebViewErrorEvent = NativeSyntheticEvent<WebViewError>;
135
 
131
 
136
-export type DataDetectorTypes
137
-  = | 'phoneNumber'
132
+export type DataDetectorTypes =
133
+  | 'phoneNumber'
138
   | 'link'
134
   | 'link'
139
   | 'address'
135
   | 'address'
140
   | 'calendarEvent'
136
   | 'calendarEvent'
224
   onLoadingStart: (event: WebViewNavigationEvent) => void;
220
   onLoadingStart: (event: WebViewNavigationEvent) => void;
225
   onMessage: (event: WebViewMessageEvent) => void;
221
   onMessage: (event: WebViewMessageEvent) => void;
226
   onShouldStartLoadWithRequest: (event: WebViewNavigationEvent) => void;
222
   onShouldStartLoadWithRequest: (event: WebViewNavigationEvent) => void;
227
-  scalesPageToFit?: boolean;
228
   showsHorizontalScrollIndicator?: boolean;
223
   showsHorizontalScrollIndicator?: boolean;
229
   showsVerticalScrollIndicator?: boolean;
224
   showsVerticalScrollIndicator?: boolean;
230
   // TODO: find a better way to type this.
225
   // TODO: find a better way to type this.
239
 
234
 
240
 export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps {
235
 export interface AndroidNativeWebViewProps extends CommonNativeWebViewProps {
241
   allowFileAccess?: boolean;
236
   allowFileAccess?: boolean;
237
+  scalesPageToFit?: boolean;
242
   allowUniversalAccessFromFileURLs?: boolean;
238
   allowUniversalAccessFromFileURLs?: boolean;
243
   androidHardwareAccelerationDisabled?: boolean;
239
   androidHardwareAccelerationDisabled?: boolean;
244
   domStorageEnabled?: boolean;
240
   domStorageEnabled?: boolean;
261
   automaticallyAdjustContentInsets?: boolean;
257
   automaticallyAdjustContentInsets?: boolean;
262
   bounces?: boolean;
258
   bounces?: boolean;
263
   contentInset?: ContentInsetProp;
259
   contentInset?: ContentInsetProp;
264
-  contentInsetAdjustmentBehavior?: 'automatic'| 'scrollableAxes' | 'never' | 'always';
260
+  contentInsetAdjustmentBehavior?:
261
+    | 'automatic'
262
+    | 'scrollableAxes'
263
+    | 'never'
264
+    | 'always';
265
   dataDetectorTypes?: DataDetectorTypes | ReadonlyArray<DataDetectorTypes>;
265
   dataDetectorTypes?: DataDetectorTypes | ReadonlyArray<DataDetectorTypes>;
266
   decelerationRate?: number;
266
   decelerationRate?: number;
267
   directionalLockEnabled?: boolean;
267
   directionalLockEnabled?: boolean;
272
 }
272
 }
273
 
273
 
274
 export interface IOSWebViewProps extends WebViewSharedProps {
274
 export interface IOSWebViewProps extends WebViewSharedProps {
275
-  /**
276
-   * If true, use WKWebView instead of UIWebView.
277
-   * @platform ios
278
-   */
279
-  useWebKit?: boolean;
280
-
281
   /**
275
   /**
282
    * Does not store any data within the lifetime of the WebView.
276
    * Does not store any data within the lifetime of the WebView.
283
    */
277
    */
331
    * content area of the scroll view. The default value of this property is
325
    * content area of the scroll view. The default value of this property is
332
    * "never". Available on iOS 11 and later.
326
    * "never". Available on iOS 11 and later.
333
    */
327
    */
334
-  contentInsetAdjustmentBehavior?: 'automatic'| 'scrollableAxes' | 'never' | 'always'
328
+  contentInsetAdjustmentBehavior?:
329
+    | 'automatic'
330
+    | 'scrollableAxes'
331
+    | 'never'
332
+    | 'always';
335
 
333
 
336
   /**
334
   /**
337
    * The amount by which the web view content is inset from the edges of
335
    * The amount by which the web view content is inset from the edges of
408
   allowsLinkPreview?: boolean;
406
   allowsLinkPreview?: boolean;
409
 
407
 
410
   /**
408
   /**
411
-   * Set true if shared cookies from HTTPCookieStorage should used for every load request in the
412
-   * `RNCWKWebView`. The default value is `false`.
409
+   * Set true if shared cookies from HTTPCookieStorage should used for every load request.
410
+   * The default value is `false`.
413
    * @platform ios
411
    * @platform ios
414
    */
412
    */
415
   sharedCookiesEnabled?: boolean;
413
   sharedCookiesEnabled?: boolean;
437
   /**
435
   /**
438
    * A String value that indicates which URLs the WebView's file can then
436
    * A String value that indicates which URLs the WebView's file can then
439
    * reference in scripts, AJAX requests, and CSS imports. This is only used
437
    * reference in scripts, AJAX requests, and CSS imports. This is only used
440
-   * in `RNCWKWebView` for WebViews that are loaded with a source.uri set to a
441
-   * `'file://'` URL.
442
-   * 
438
+   * for WebViews that are loaded with a source.uri set to a `'file://'` URL.
439
+   *
443
    * If not provided, the default is to only allow read access to the URL
440
    * If not provided, the default is to only allow read access to the URL
444
    * provided in source.uri itself.
441
    * provided in source.uri itself.
445
    * @platform ios
442
    * @platform ios
463
    */
460
    */
464
   overScrollMode?: OverScrollModeType;
461
   overScrollMode?: OverScrollModeType;
465
 
462
 
463
+  /**
464
+   * Boolean that controls whether the web content is scaled to fit
465
+   * the view and enables the user to change the scale. The default value
466
+   * is `true`.
467
+   */
468
+  scalesPageToFit?: boolean;
469
+
466
   /**
470
   /**
467
    * Sets whether Geolocation is enabled. The default is false.
471
    * Sets whether Geolocation is enabled. The default is false.
468
    * @platform android
472
    * @platform android
543
    * @platform android
547
    * @platform android
544
    */
548
    */
545
   mixedContentMode?: 'never' | 'always' | 'compatibility';
549
   mixedContentMode?: 'never' | 'always' | 'compatibility';
546
-  
550
+
547
   /**
551
   /**
548
    * Sets ability to open fullscreen videos on Android devices.
552
    * Sets ability to open fullscreen videos on Android devices.
549
-  */
553
+   */
550
   allowsFullscreenVideo?: boolean;
554
   allowsFullscreenVideo?: boolean;
551
 }
555
 }
552
 
556
 
562
    * @platform android
566
    * @platform android
563
    */
567
    */
564
   javaScriptEnabled?: boolean;
568
   javaScriptEnabled?: boolean;
565
-  
569
+
566
   /**
570
   /**
567
    * Function that returns a view to show if there's an error.
571
    * Function that returns a view to show if there's an error.
568
    */
572
    */
645
    */
649
    */
646
   showsVerticalScrollIndicator?: boolean;
650
   showsVerticalScrollIndicator?: boolean;
647
 
651
 
648
-  /**
649
-   * Boolean that controls whether the web content is scaled to fit
650
-   * the view and enables the user to change the scale. The default value
651
-   * is `true`.
652
-   *
653
-   * On iOS, when `useWebKit=true`, this prop will not work.
654
-   */
655
-  scalesPageToFit?: boolean;
656
-
657
   /**
652
   /**
658
    * Boolean that determines whether HTML5 audio and video requires the user
653
    * Boolean that determines whether HTML5 audio and video requires the user
659
    * to tap them before they start playing. The default value is `true`.
654
    * to tap them before they start playing. The default value is `true`.