* [apple] Move iOS/macOS src into common apple dir
* [apple] Enable macOS as platform in podspec
* [example] Use CocoaPods & auto-linking on macOS
* [docs] Update setup for macOS
* [package] Include apple dir in distribution
* 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
* adds missing variable
Co-authored-by: Dominik Beste <dominik.beste@gmail.com>
* 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>
This converter is already defined in
[RCTScrollViewManager.m](https://github.com/facebook/react-native/blob/master/React/Views/ScrollView/RCTScrollViewManager.m#L40).
Redefining it in react-native-webview can cause undefined behaviour when
used. Since ScrollView is unlikely to go away, we can take a dependency on it.
All current tests should pass.
When building a React Native app with `react-native-webview`, the following
warning can be seen in the build logs:
```
Meta method 'UIScrollViewContentInsetAdjustmentBehavior:' in category from /~/Library/Developer/Xcode/DerivedData/App-geojljebaazfrrgvxfkjjpiwmdlg/Build/Products/Debug-iphonesimulator/React-Core/libReact-Core.a(RCTScrollViewManager.o) conflicts with same method from another category
```
The warning should go away after removing the offending function.
Co-authored-by: Jason Safaiyeh <safaiyeh@protonmail.com>
BREAKING CHANGE: if you use onNavigationStateChange on iOS it will now trigger on # changes to the url.
* Hook the `window.history` API on iOS to generate events
The underlying WKWebView doesn't seem to generate any events in response to the `window.history` API - none of the `WKNavigationDelegate` methods fire.
Given this limitation, the only way to know when the location changes via this API is to inject Javascript into the page and have it notify the native code directly when any of these functions are called.
The `setTimeout` call gives up the current tick, allowing the location to change before firing the event.
* Remove the outdated section about hash changes
Now that this bug is fixed, the workaround is no longer required.
UIWindowDidBecomeVisibleNotification and UIWindowDidBecomeHiddenNotification seem far more reliable at detecting fullscreen video.
Tested on iOS 11, 12 and 13
* fix(ios):use RCTConvert to convert url instead of using URLWithStringg
* fix(iOS):remove stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding, because it's deprecated in iOS 9
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
* 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.
* Changes error/redbox into warning/yellowbox. So wouldn't crash production releases
* Warning added actual error, useful for debugging bad JS injected into webview
* callback runs, whether there's error or not. As used in my app (https://medium.com/wonderswipe/rethink-mobile-search-10-100x-faster-introducing-wonderswipe-6f2ff0d0e667) which injects JS into sanitized html from the wild, small error in injected JS doesn't warrant the whole JS payload from being injected/run
* Add `onScroll` callback for iOS & Android
This code was mostly extracted from https://github.com/react-native-community/react-native-webview/pull/202
I tried and tried to make it work with `Animated.event`'s `useNativeDriver`, but I was unsuccessful 😢 that'll have to be done later once I understand better how Animated's native stuff is hooked up.
* fix crash for missing onScroll
* [iOS] Allow focus without user interaction
* Add documentation for keyboardDisplayRequiresUserAction
* set keyboardDisplayRequiresUserAction default to true
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.
This PR fixes two crashes when enableWebKit is true (which was the default) on iOS 9.x. The first one when the WebView component was mounted (fixes issue #150) and the second one, when the component was unmounted (fixes issue #213).
The first problem happen when the RNCWKWebView.m was loaded:
The programming guide for WebKit (version 2006) ([pdf](http://mirror.informatimago.com/next/developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/WebKit_DisplayWebContent.pdf)) from Apple said, that it is (was) required to check if the 'new' WebKit Framework was available. This was required when the WebKit framework was only available on Mac OS X (10.2) when the Safari was installed. 😆
Because WebKit is (currently..) a fix part of iOS we didn't need this check this anymore to determinate if WebKit is available. I also see no other reference that this is required in iOS so I just remove this code. Without this code the WebView works also on iOS 9.x.
The second issue happen when the WKWebView was removed from the native view hierarchy. Its required (only on iOS 9) to remove the UIScrollView delegate before cleaning up the webview.
Its possible to try this PR with:
```
npm install --save "react-native-webview@jerolimov/react-native-webview#fix-ios9-crash"
# or
yarn add "react-native-webview@jerolimov/react-native-webview#fix-ios9-crash"
```
If you use CocoaPods, you should also update your Pods with
```
cd ios && pod update && cd ..
```
fixes#29fixes#272fixes#221fixes#105fixes#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!
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.