Commit Graph

65 Commits

Author SHA1 Message Date
Kai Guo e402e739ea
fix(windows): Add postMessage for Windows WebView (#1263 by @kaiguo) 2020-05-29 13:19:11 -07:00
trcoffman 91df544fae
feat(webview): Allow javascript to open windows automatically (#1409 by @trcoffman)
[skip ci]
2020-05-28 09:54:20 -07:00
trcoffman a6010d93e0
feat(iOS): Add onFileDownload callback (#1214)
`onFileDownload` is called with the URL that you can use to download the file.
When RNCWebView detects that the HTTP response should result in a file download,
`onFileDownload` is called. The client can then provide code to download
the file.

RNCWebView determines that a file download should take place if either of the
following is true:
1. The HTTP response contains a `Content-Disposition` header that is of type
  'attachment'
2. The MIME type of the response cannot be rendered by the iOS WebView
2020-04-29 09:09:22 -07:00
RedPandaTronics d4ab332891
feat(iOS): Add Hardware Silence (#1218)
* Fixes Issue #1140

Fixes https://github.com/react-native-community/react-native-webview/issues/1140
Based on a solution found at: https://stackoverflow.com/questions/56460362/how-to-force-wkwebview-to-ignore-hardware-silent-switch-on-ios
I changed the code found in the linked source from Swift to Objective-C, as required by this project. WARNING: I haven't used Swift before and very limited experience with Objective-C.

- For me this seems to work, but it is not the cleanest solution in my opinion.
- It might also be possible to play generated sound (i.e. using oscillator) instead of hardcoding the silent base64 mp3 data.
- Maybe ignoring silence switch should only be done if a parameter is supplied

* fixes import path

* adds documentation for ignoreSilentHardwareSwitch

* adds ignoreSilentHardwareSwitch parameter

* reverting back to old import path

* Update Guide.md

Co-authored-by: Dominik Beste <dominik.beste@gmail.com>
2020-04-13 08:54:47 -07:00
Jamie Birch 9cb2f6e2f3
feat(iOS): WKUserScripts (e.g. injectedJavaScript) can now update upon props change; and can be configured to inject into all frames. (#1119)
BREAKING CHANGE: 
• Props updates to `injectedJavaScript` are no longer immutable.

• `injectedJavaScript` no longer attaches a `jsEvaluationValue` property to the `onLoadingFinish` event. Check out: https://github.com/react-native-community/react-native-webview/pull/1119#issuecomment-574919464 to migrate with the same behavior.
2020-03-17 14:01:20 -07:00
Kai Guo ffee0d4362
feat(Windows): Windows support! (#1220) 2020-03-16 19:30:25 -07:00
Luciano Lima 86c44588f8
chore(docs): Update React Native links to reactnative.dev (#1233) 2020-02-25 22:54:06 -08:00
Tom Underhill 1e572318ec
feat(macOS): macOS Support (#1164) 2020-02-12 15:39:11 -08:00
StasD 88b64981f4 fix(ios): Make allowFileAccessFromFileURLs work in iOS. (#1061) 2019-12-06 11:16:56 +01:00
Salvatore Randazzo 604495e399 feat(iOS): new prop injectedJavaScriptBeforeContentLoaded (#1038)
* Run the injectedJavaScript on DocumentStart for iOS

* Add new prop injectedJavaScriptBeforeContentLoaded
Update types
Update docs

* Self review
2019-12-06 11:15:02 +01:00
Thibault Malbranche ef5c36c88e
chore(docs): Document request focus method 2019-11-13 10:43:25 +01:00
Stanislav Shakirov 4a4f4a2c45 feat(android): add clearHistory, clearCache and clearFormData (#450)
* add clearHistory, clearCache and clearFormData android webview api.

* remove pointless `async`

* add docs for new android webview methods

* Update Reference.md

* update commands types

* add more strict type for RNCWebViewUIManager `Commands` property
2019-11-12 10:09:16 +01:00
Jamon Holmgren 8c9f986df0 chore(docs): Added guide for working with custom headers and cookies (#994)
* Added guide for working with custom headers and cookies

* Remove extraneous files
2019-11-04 17:30:51 +01:00
Borut Balazek 4db3d84dda feat(android): allowFileAccessFromFileURLs prop added (#831)
* add allowFileAccessFromFileURLs propery to do the expected on android

* Added types

* Update WebViewTypes.ts
2019-09-29 15:50:39 +02:00
Andres Castano 5da59251ce feat(android): Expose cacheMode property (#895) 2019-09-29 15:45:20 +02:00
Marco Marinangeli 902d3d1e7f feat(new prop): containerStyle (#912)
* feat(new prop): containerStyle

* chore(docs): Add documentation for `containerStyle`
2019-09-29 15:43:48 +02:00
Tyler Alves fc59cae4bf fix(android): Filter extra onLoadProgress & add url event (#643)
* Filter out extra onLoadProgress calls; add url to onLoadProgress

* remove note about onLoadProgress not having the url property in docs

* Update Reference.md
2019-09-23 10:35:49 +02:00
Samuel Sieg a76811da93 feat(iOS): Add callback for webViewWebContentProcessDidTerminate (#774)
* Add callback for WKWebView's onContentProcessDidTerminate

* Add platform information to docs

* Add new WebViewTerminatedEvent type
2019-09-23 10:20:12 +02:00
Jason Chia-Hsien Ho 552472c414 feat(new prop): onHttpError callback (#885) 2019-09-21 02:43:28 +02:00
George Montana Harkin 36ffbe0700 chore(docs): Update "source" doc, baseUrl comments about CORS (#881)
After needing to see what the origin of a "html" source'd WebView would be, I found the documentation that baseUrl would be utilized for the "origin" header when CORS requests are made.
2019-09-19 11:18:59 +02:00
Thibault Malbranche 8549be5fd0
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
2019-08-30 12:04:32 +02:00
Harry Yu 0424dd0801 feat(iOS): Add prop for allowingReadAccessToURL (#771) 2019-08-29 16:53:09 +02:00
aarondail 493b65de21 feat(iOS): added `contentInsetAdjustmentBehavior` prop
* Adding a `contentInsetAdjustmentBehavior` prop to the WebView for iOS.
This controls the way iOS will automatically adjust the insets when the
webview is behind things like the iPhone X notch.

* Removing the code to explicitly pass contentInsetAdjustmentBehavior to the WebView since it is already passed in otherProps.
2019-08-09 10:55:35 +02:00
Raphael Eidus 9c592d621c feat(android): polyfill applicationNameForUserAgent on Android (#707) 2019-08-02 10:46:03 +02:00
José Luis Pereira 25bc5a55c6 feat(android props): Add incognito to Android (#524) 2019-08-02 09:48:54 +02:00
BettyJJ 1e809932ff chore(types): Update Reference.md (#687)
added doc for the `textZoom` property
2019-07-02 17:38:00 +02:00
Penar Musaraj 71d1fcc675 feat(iOS WKWebView): Add mainDocumentURL to onShouldStartLoadWithRequest(#493)
* Pass mainDocumentURL to onShouldStartLoadWithRequest

* Update reference

* Update typescript types

* Update WebViewTypes.ts
2019-06-13 08:59:52 +02:00
Tijs Teulings a863c6557f chore(docs): Added additional note to `source` parameter (#621)
Added a note about the baseUrl usage since this has been the cause of some filed issues e.g. https://github.com/react-native-community/react-native-webview/issues/526#issuecomment-498067637
2019-06-04 16:46:27 +02:00
Penar Musaraj 4dc4b89e64 feat(iOS WkWebview): Add applicationNameForUserAgent support (#506) 2019-05-21 00:01:22 +02:00
Malcolm Scruggs a0daff92c0 chore(docs): Create example for injectedJavaScript (#571) 2019-05-17 00:24:18 +02:00
Daniel Vicory d72c2ae144 feat(fullscreen videos): Support fullscreen video on Android (#325)
* Extract WebChromeClient from an anonymous class

* Support fullscreen videos on Android

Forces landscape mode while playing.

* Use sticky immersive mode for fullscreen videos

No longer forces landscape mode as that is a problem for portrait videos - allow
the user to rotate as necessary.

Only supports KitKat or greater, and falls back to leaving the status and navigation
bars visible for lower than KitKat. This is the easiest way to prevent issues with
resizing the video during playback.

Also implement a lifecyle event listener which means if a user backgrounds the app
or locks the screen with the video fullscreen, the UI visibility is re-applied.

* Add allowsFullscreenVideo prop to control whether videos can be fullscreen on Android

Luckily, we're able to change the WebChromeClient on demand in response to prop changes
without seeming to do any harm. If you switch to disallow fullscreen, it will attempt
to close the currently fullscreened video (if there is one) so users aren't stuck.

I did notice a bug that if you go from fullscreen allowed, to fullscreen disallowed,
the fullscreen button will remain on the video. Tapping the button will have no effect.
2019-05-17 00:22:08 +02:00
Jamon Holmgren c0332ec607 chore(docs): Adds guide for intercepting hash URL changes (#555) 2019-05-13 09:42:25 +02:00
Eric Lewis 455c30e000 feat(WKWebView): Allow focus without user interaction (#540)
* [iOS] Allow focus without user interaction

* Add documentation for keyboardDisplayRequiresUserAction

* set keyboardDisplayRequiresUserAction default to true
2019-04-29 17:46:07 +02:00
SebiVPS cdbfc19cd2 feat(iOS cookies): implement sharedCookiesEnabled prop for iOS RNCWKWebView (#175)
We had the problem on iOS WebViews that local cookies (stored in local HTTPCookieStorage, set with  [react-native-cookie](https://github.com/shimohq/react-native-cookie) ) were not added in loadRequests. On Android the local stored cookies were sent like expected.
This kinda "hacky" solution is the only way we found, that works for us.
The stack overview link is in the code below.
If someone finds a better solution we would very much like to accept that.
2019-04-15 10:19:10 +02:00
Malcolm Scruggs ee3a7c4d34 chore(docs): Remove duplicate example of onShouldStartLoadWithRequest (#479) 2019-04-05 00:41:45 +02:00
Thibault Malbranche 453b7dd3a0
feat(typescript): Source code rewrite using typescript (#425)
Rewrote the whole repository into typescript. This will provide way better and up to date documentation. This should also add some safety for people contributing 😄 .
Flow types were not working until now which is why this PR doesn't have them but feel free to PR.

This also fixes #384 #435 #206 #171 #168.
2019-03-20 12:35:13 +00:00
Jian Wei 08cc600eb8 feat(WKWebView): add prop `directionalLockEnabled` for iOS (#389) 2019-03-07 10:27:29 +01:00
Jamon Holmgren 2260690810 chore(docs): Added guides for communication between React Native and web pages (#377)
* Added guides for communication between React Native and web pages

* Updated Guide a bit
2019-03-03 01:32:42 +01:00
Malcolm Scruggs 34b98de0bd chore(docs): Add API Examples in reference documentation (#329)
* Add reference examples for:
- onError
- onNavigationStateChange
- originWhiteList
- renderError
- renderLoading
- onShouldStartLoadWithRequest

* Update to use jsx as code
Add properties of objects passed into methods

* Add examples for:
- onLoad
- onLoadEnd
- onLoadStart
- onLoadProgress
- style

* Add object descriptions, fix style issues, and remove onShouldStartLoad example

Object Descriptions for:
- onLoad
- onLoadEnd
- onLoadStart
- onLoadProgress

* Update Reference.md
2019-03-01 01:36:56 +01:00
Jamon Holmgren d28071cf52 chore(docs): Adds example for onShouldStartLoadWithRequest (#321)
Per #320, this adds an example for onShouldStartLoadWithRequest.
2019-03-01 01:27:17 +01:00
Andrei Pfeiffer 8217cb5503 chore(docs): Update Reference.md (#359)
I was able to fix a bug with videos loaded from Azure that wouldn't start unless I set that prop to `false`
2019-02-28 22:10:47 +01:00
Chet Corcos 0e6e92a7f1 fix(WKWebview Scroll): Don't allow the scrollView to scroll when `scrollEnabled={false}`. (#158)
* Don't allow the scrollview to scroll the WebView body.

* Readme comment

* Remove duplicate protocol def
2019-02-28 22:01:42 +01:00
Jordan Sexton 92c20581ae feat(toggle scroll bar): added new props showsVerticalScrollIndicator / showsHorizontalScrollIndicator (#250) 2019-02-12 14:47:24 +01:00
Momazo7u7 80efc3155c chore(docs): Deleted onShouldStartLoadWithRequest platform reference (#317)
* Deleted onShouldStartLoadWithRequest platform reference

according to b1b662628e it's supported on android and Ios so  no platfor reference is needed

* Deleted onShouldStartLoadWithRequest platform reference 

Now with added note
2019-02-08 12:31:17 +01:00
Thibault Malbranche d5fc028383 fix(PostMessage): Renamed ReactNativeWebview to ReactNativeWebView
fixes #304
2019-02-01 22:04:11 +01:00
Thibault Malbranche e4b851e01a
Update Reference.md 2019-02-01 19:14:07 +01:00
Thibault Malbranche f3bdab5a22
feat(Android/iOS postMessage): refactoring the old postMessage implementation (#303)
fixes #29
fixes #272
fixes #221
fixes #105
fixes #66

BREAKING CHANGE: Communication from webview to react-native has been completely rewritten. React-native-webview will not use or override window.postMessage anymore. Reasons behind these changes can be found throughout so many issues that it made sense to go that way.

Instead of using window.postMessage(data, *), please now use window.ReactNativeWebView.postMessage(data).

Side note: if you wish to keep compatibility with the old version when you upgrade, you can use the injectedJavascript prop to do that:

const injectedJavascript = `(function() {
  window.postMessage = function(data) {
    window.ReactNativeWebView.postMessage(data);
  };
})()`;

Huge thanks to @jordansexton and @KoenLav!
2019-02-01 18:37:28 +01:00
Michael Diarmid 83ce79ff89 feat(iOS/Android): Add `cacheEnabled` prop (#152)
Added a new cacheEnabled prop to toggle Android & iOS webview caching behavior.

BREAKING CHANGE:  This change makes caching enabled by default when previously there was no caching behavior which may cause unexpected behaviour changes in your existing implementations.
2019-01-30 10:32:46 +01:00
Margaret d3fc5e6cde feat(android props): Add `androidHardwareAccelerationDisabled` prop (#265)
* add test code for disable hardware acceleration

* add interface to disable android hardware acceleration

* Update index.d.ts
2019-01-22 10:21:10 +01:00
Roy Zheng 245120df0c Fix typo in Reference.md (#252) 2019-01-18 02:26:20 +01:00