Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

416
Views
React Native WebView onMessage doesn't respond

When I run my application through visual studio code (it doesn't matter if connected to an emulator or a real device), there is no problem. After I release my project, I don't get any response from onMessage when I install my application on my real device with apk. For example, when I run apk on real device, I can't see alert('3'). Also other codes (usestate, etc...) inside onMessage doesn't work, neither. Only 1 and 2 appear.

import {WebView} from 'react-native-webview';
import React, {useEffect, useRef, useState} from 'react';

...

const webView = useRef();

...

const getDslBootTime = async () => {
    updateLogs('1');
    await delay(3500);

    webView.current.injectJavaScript(`location.reload();`);

    //DSL Boot Time
    webView.current.injectJavaScript(`window.ReactNativeWebView.postMessage(
      JSON.stringify({
        "name": "DSL Boot Tıme",
        "stat" : 
        document.querySelectorAll('[id="boot_days"]')[0].innerHTML + " Day " +
        document.querySelectorAll('[id="boot_hours"]')[0].innerHTML + " Hour " +
        document.querySelectorAll('[id="boot_minutes"]')[0].innerHTML + " Mınute " +
        document.querySelectorAll('[id="boot_seconds"]')[0].innerHTML + " Second"
      })
          )
    `);

    updateLogs('2');
  };

const updateLogs = log => {
    alert(log);
  };

...

<WebView
        ref={webView}
        source={{
          uri: url,
        }}
        onMessage={event => {
          updateLogs('3');
          const js_data = JSON.parse(event.nativeEvent.data);
          ...
        }}
      />

...
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!