question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onMessage did not triggering in release apk but worked in debug mode

See original GitHub issue

When Its is in debug mode OnMessage function triggered but when I build the Apk file it does not triggered

onWebviewLoaded = () => { if(this.props.storeName) { let storeName = this.props.storeName.toLowerCase(); storeName = storeName.replace(/ +/g, “”); console.log("storeName: ", storeName);

        let storeAttribute = this.props.scrapingAttributes[storeName];
        console.log("storeAttribute: ", storeAttribute);
        let jsCode = `
                     ${getMultipleInfoFromXpath}
                     ${trimString}
                     ${getValueByRegEx}
                     ${removeByRegEx}
                     let attributes = ${JSON.stringify(storeAttribute)};
                     let data = {};
                     for(let i in attributes){
                          data[i] = getMultipleInfoFromXpath(attributes[i])
                     }
                     window.ReactNativeWebView.postMessage(JSON.stringify(data))
                  `;

        this.setState({
            loaded: true,
            jsCode
        })
    }
};

onMessage = (data) => {
    let {productBrand, productImage, productName, productNewPrice ,productColor, productSize} = JSON.parse(data) ;
    this.setState({
        webInfo: JSON.parse(data),
        brand: productBrand[0],
        imageUrl:productImage[0],
        name: productName[0],
        newPrice: productNewPrice[0],
        productColor,
        productSize
    });
    Alert.alert(
        'onMessage',
        'My Alert Msg',
        [
            {text: 'Ask me later', onPress: () => console.log('Ask me later pressed')},
            {
                text: 'Cancel',
                onPress: () => console.log('Cancel Pressed'),
                style: 'cancel',
            },
            {text: 'OK', onPress: () => console.log('OK Pressed')},
        ],
        {cancelable: false},
    );
};

<WebView ref={r => this.webview = r} source={{uri: url}} renderLoading={this.renderLoading} startInLoadingState={true} onLoadEnd={this.onWebviewLoaded} onNavigationStateChange={(webViewState)=>{this.setState({ trackedUrl: webViewState.url, brand: ‘’, imageUrl:‘’, name: ‘’, newPrice: ‘’, productColor:[], productSize:[] })}} injectedJavaScript={loaded ? jsCode : null} onMessage = {(e) => {this.onMessage(e.nativeEvent.data)}} javaScriptEnabled={true} />

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:22

github_iconTop GitHub Comments

5reactions
hiennguyen92commented, May 28, 2019

I have the same problem with you, Android debug and iOS are all running smoothly. only android release is never called onMessage. any solution?

3reactions
codesinghanoopcommented, Aug 27, 2019

@expouic Is there any console.log which is printing event of onMessage callback if yes, then please strip it out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

onMessage did not triggering in release apk but worked in ...
When Its is in debug mode OnMessage function triggered but when I build the Apk file it does not triggered. onWebviewLoaded = ()...
Read more >
java - Android Studio - Stack Overflow
MessageClient.OnMessageReceivedListener not called in release mode, but working fine in debug mode - Android Studio · Ask Question. Asked 2 ...
Read more >
Firebase Cloud Messaging not working on Release mode (FCM)
I'm using the FCM for push notifications. Its perfectly working in Debug mode but not working in Release after I signed with KeyStore....
Read more >
Receive messages in a Flutter app - Firebase - Google
On iOS, if the user swipes away the application from the app switcher, it must be manually reopened for background messages to start...
Read more >
Debug an Android device that is not receiving mobile app ...
Debug an Android device that is not receiving mobile app messages ; loglevel, This parameter indicates to the SDK how much logging information ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found