I am trying to use webview to open up a browser within within a react-native app.
I have the following as a component:
import React from 'react';
import {
StyleSheet,
View,
Text,
Platform,
ScrollView,
WebView
} from 'react-native';
export default class Browser extends React.Component {
render() {
var DEFAULT_URL = 'https://github.com/facebook/react-native';
return (
<View style={{flex:1}}>
<WebView
automaticallyAdjustContentInsets={false}
source={{uri: DEFAULT_URL}}
javaScriptEnabled={true}
domStorageEnabled={true}
decelerationRate="normal"
startInLoadingState={true}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'space-between',
},
});
I am able to get the github open in both android and ios, but with the css styles missing.
But when i make DEFAULT_URL
to https://www.google.com
it gives me the following error:
NSURLErrorDomain
Error Code: -1202
Description: The certificate for this server is invalid. You might be connecting to a server that is pretending to be "www.google.com" which could put your confidential information at risk
I can open this in safari with Linking.openURL, but it would be nice if something can opened within a browser in the app itself.
Any ideas why this might be happening or how it can be resolved? Thanks in advance for the help..