I trying to add helpcrunch chat in my mobile app via WebView. For it I need to add a few scripts in HTML:
<script type="text/javascript">
(function(w,d){
w.HelpCrunch=function(){w.HelpCrunch.q.push(arguments)};w.HelpCrunch.q=[];
function r(){var s=document.createElement('script');s.async=1;s.type='text/javascript';s.src='https://widget.helpcrunch.com/';(d.body||d.head).appendChild(s);}
if(w.attachEvent){w.attachEvent('onload',r)}else{w.addEventListener('load',r,false)}
})(window, document)
</script>
<script type="text/javascript">
HelpCrunch('init', 'app', {
applicationId: 2,
applicationSecret: 'appKEY'
})
HelpCrunch('showChatWidget');
</script>
In IOS all work well. But on android, this script doesn't work.
Code with my WebView:
<WebView
injectedJavaScript={INJECTED_SCRIPTS}
onMessage={this.onMessage}
javaScriptEnabled={true}
automaticallyAdjustContentInsets={false}
source={{ html: `<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1 id="about">regnergioi</h1>
</body>
</html>` }}
style={{ marginTop: 30, marginBottom: 10, height: 400 }}
renderError={(a) => this.handleError(a)}
onError={(a) => this.handleError(a)}
/>
I can't really help with the WebView problem but I can suggest a unofficial HelpCrunch library for React Native. It's a bit old but I think it will work fine after updating the SDK versions to latest for both platforms
https://www.npmjs.com/package/react-native-helpcrunch
Latest versions:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.