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.

AdMob: AdMobInterstitial.setTestDeviceID is deprecated

See original GitHub issue

🐛 Bug Report

Environment

Bare React Native App using RN 0.61.5

App target: iOS and Android Emulator

Steps to Reproduce

Install and configure AdMob as described in the docs. Run app on Emulator (iOS or Android).

For me it looks like this:

const INTERSTITIAL = Platform.OS === 'ios' ? AD_MOB_IOS : AD_MOB_ANDROID
AdMobInterstitial.setAdUnitID(INTERSTITIAL)
AdMobInterstitial.setTestDeviceID('EMULATOR')
await AdMobInterstitial.requestAdAsync({ servePersonalizedAds: false })
await AdMobInterstitial.showAdAsync()

Expected Behavior

Works without deprecation warnings

Actual Behavior

AdMobInterstitial.setTestDeviceID is deprecated. Test device IDs are now set globally. Use AdMob.setTestDeviceIDAsync instead.

When I use AdMob.setTestDeviceIDAsync I get an error.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
IjzerenHeincommented, Apr 30, 2020

it seems something has gone wrong with the documentation, and the latest AdMob page doesn’t show the correct API instructions. I fixed it but it will take a bit for it to show up on the website. This page describes the correct API usage: https://docs.expo.io/versions/v36.0.0/sdk/admob/

The problem you are experiencing is because of the import. setTestDeviceIDAsync is not defined on the default export, and you need to import it like this:

import { setTestDeviceIDAsync } from 'expo-ads-admob';
0reactions
omar-bakhshcommented, Jul 23, 2020

this is how i add banner easy 😊

in app.js

 import { AdMobBanner,} from 'expo-ads-admob';

 <AdMobBanner
  bannerSize="banner"
  adUnitID="ca-app-pub-yourKeyHere" 
  servePersonalizedAds={false}
  onDidFailToReceiveAdWithError={this.bannerError} />

in app.json

 "android": {
 
      "config": {
        "googleMobileAdsAppId": "ca-app-pub-yourKeyHere"}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Admob InterstitialAd Deprecated - Stack Overflow
after a quick search, I found that we need to use public abstract class InterstitialAd extends Object. instead of
Read more >
Deprecation and sunset | Android - Google Developers
With the release of a new major Google Mobile Ads SDK version, a deprecated major version may be given a sunset date, after...
Read more >
bamlab-react-native-admob - npm
A react-native component for Google AdMob banners and interstitials. Latest version: 1.4.0, last published: 5 years ago.
Read more >
expo-permissions is now deprecated - You.com - You.com
React Native expo-permission deprecated what to use now? ... setTestDeviceID('EMULATOR') await AdMobInterstitial. ... When I use AdMob.
Read more >
Admob - Expo Documentation
Admob. Deprecated. This module will be removed in SDK 46. There will be no replacement that works with ...
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