Last active
December 26, 2019 14:17
-
-
Save nucklearproject/119533ebf1906db34aaa7b8322b05e7c to your computer and use it in GitHub Desktop.
Problema con lag al mostrar ads flutter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:firebase_admob/firebase_admob.dart'; | |
import '../services/globals.dart'; | |
class Ads { | |
InterstitialAd myInterstitial; | |
MobileAdTargetingInfo targetingInfo = new MobileAdTargetingInfo( | |
testDevices: TEST_DEVICES, | |
); | |
InterstitialAd createBannerInter() { | |
return new InterstitialAd( | |
adUnitId: AD_MOB_INTERSITIAL_ID, //InterstitialAd.testAdUnitId, | |
targetingInfo: targetingInfo, | |
listener: (MobileAdEvent event) { | |
print("BannerAd event is $event"); | |
if (event == MobileAdEvent.closed) { | |
} | |
}, | |
); | |
} | |
showPub() { | |
/*La instancia ya esta inicializada globalmente para que cargue banners tambien, por eso no se repite aca | |
FirebaseAdMob.instance.initialize(appId: AD_MOB_APP_ID); | |
El problema es el lag que hay entre el load y show, natural por la conexion de internet, | |
necesito que se separe los dos metodos asi puedo hacer un load al inicio de la pantalla y | |
luego enviar el show cuando otro evento suceda, que en este caso es un cambio de pantalla. | |
Por ese motivo admob me suspendio los ads. Por que cuando ocurre el evento para cambiar de pantalla | |
se hace el load y show, luego despues de que la otra pantalla ya cargó. Espero se entienda... | |
*/ | |
myInterstitial = createBannerInter()..load()..show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment