Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

412
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda