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

262
Vistas
React Native Rewarded interstitial Ads - undefined is not an object

currently, I am learning how to show ads in React Native. While inApp ads always bothered me, I thought over to give it a try. Gone to open source. done setting firebase and admob. After completing each part carefully, onclick 'watch ad' I get this following error:

TypeError: undefined is not an object 
(evaluating '_$$_REQUIRE(_dependencyMap[6], "../components/Ads").Ads.showRewarded')

My codes are provided below:

Ads.js

import { RewardedAd, RewardedAdEventType } from "@react-native-firebase/admob";

const showRewarded = async () => {
  const rewarded = RewardedAd.createForAdRequest(UNIT_ID, {
    requestNonPersonalizedAdsOnly: false,
  });
  let loaded = false;
  let gotReward = false;
  const eventListener = rewarded.onAdEvent((type, error, reward) => {
    if (type === RewardedAdEventType.LOADED) {
      rewarded.show();
      loaded = true;
    } else if (type === RewardedAdEventType.EARNED_REWARD) {
      gotReward = true;
    } else if (error) {
      console.warn(error);
    }
  });
  rewarded.load();
  while (!loaded) {
    await new Promise((resolve, reject) => setTimeout(resolve, 1000));
  }
  return gotReward;
};

button.js or onclick event

import React from 'react';
import {
  View,
  Text,
  TouchableOpacity
} from 'react-native';
import { Ads } from '../components';

function showAd() {
    // Wait while user has not been get a reward (or skiped the ad)
    const reward = Ads.showRewarded();
    console.log(`The reward is ${reward}`);
  }


TouchableOpacity style={styles.item} onPress={() => showAd()}>

            <Text>Watch Ads</Text>

     </TouchableOpacity>
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