1

i Used Webview to integration with PayPal: sample of the code:

<Modal
                    animationType={"fade"}
                    transparent={false}
                    visible={this.state.modalVisible}
                    onRequestClose={() => {
                        alert("Modal has been closed")
                    }}
                    >
                        <WebView
                            source={ require('./PayPalIntegration.html')}
                            style={{flex: 10, width: width, height: height, margin: 20, alignItems: 'center', alignSelf: 'center'}}
                            javaScriptEnabled={true}
                            automaticallyAdjustContentInsets={true}
                        />
                        <TouchableOpacity style={{marginLeft: 10, marginBottom: 10,}}onPress={() => {
                            this.setState({ modalVisible: false})
                        }}>
                            <Text>
                                X Close
                            </Text>
                        </TouchableOpacity>
                    </Modal>

It works when i use iOS emulator from Xcode, work on AndroidStudio's AVD manager, and also works when i use react-native run-android direct to my device. But after generated APK and installed it, i see only the Modal and the WebView isn't working.

I did several things to try to fix this:

  1. I check the configurations of the proguard and according to other posts here and it was FALSE already, according to web view not loading page after exporting to signed APK

  2. I added -keepattributes JavascriptInterface according to JavascriptInterface on Android dont work with APK in release mode

I must say that i can check it only on ANDROID because i can only generate APK (do not have apple's developer account)

AmitK
  • 91
  • 1
  • 6
  • Help someone...? – AmitK May 28 '17 at 05:31
  • Hello there, I know this is old but I posted an answer at https://stackoverflow.com/a/50544869/2225316. The answer there is related to this one and will work for your use case. – Boomer Rogers May 26 '18 at 16:35
  • @BoomerRogers Thanks! It is an old post but still exist in the same old project. I'll try to fix it with your solution and will update soon. – AmitK May 28 '18 at 05:20

1 Answers1

1

Try to add android:usesCleartextTraffic="true" under application tag in AndroidManifest.xml. It should look like below snippet.

<application
      .........
      .........
      android:usesCleartextTraffic="true"
      .........
Sunny Prakash
  • 772
  • 1
  • 8
  • 13