0

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..

pj013
  • 1,393
  • 1
  • 10
  • 28
  • Your code works fine at my end. Not getting the error. Google opens without any error. – HAK May 29 '18 at 21:24
  • Look into this question:https://stackoverflow.com/questions/41221820/domain-nsurlerrordomain-code-1202 – HAK May 29 '18 at 21:30
  • I think in your styles you'll also have to remove `alignItems: 'center'` – ovidb May 29 '18 at 21:59

0 Answers0