[AdMob] How do I display two different interstitials?

Hi,

I need to display an interstitial ad in my app, which works fine.

However, I need to distinguish between two separate ad units, say ad1 and ad2. Both are interstitials.

The reason for this is that one of them is used as an standard ad, and the second one as a rewarded ad. Possibly I would like to distinguish among more than two units, so I could have different interstitials giving different rewards in various places in the game.

admob.init lets me specify a listener for when the ad was watched but no way to determine where from in the game it was called. So if I just show ‘interstitial’ then no matter the context it will trigger the same listener as any other one (i.e. the random ad giving the same reward as the rewarded ad). As far as I can tell having multiple admob.inits in one app is incorrect.

So is there a admob plugin ‘native’ way of doing this or do I need to try to find out which ad is being shown by means of external variables or something?

EDIT: Ok, I’ve realized I can load a specific ad unit via admob.load(). But how do I distinguish between them in the listener?

At the moment it’s not possible to distinguish one interstitial from another.

However it would be possible to add an extra data field to the callback which returns the adUnitId of the ad. You would need to set up 2 different ad units in the AdMob dashboard. With that setup you can check event.data returned in the callback and check which adUnitId generated the event. Keep in mind that with the existing API only one interstitial can be loaded at a time though…

BTW. I assume you’re using the paid AdMob plugin:

https://docs.coronalabs.com/plugin/admob/

Updates will only be made to this plugin. The legacy AdMob plugin will be retired in the near future although no specific date has been set yet.

Yes, I’m using the paid plugin. 

Good idea with checking event.data. Currently I settled for an external variable that is set to a particular value when the ad is displayed and then zeroed afterwards (two interstitials are never shown simultaneously so there’s no interference). The listener checks this variable to see the which ad is being shown.  It works but your way seems cleaner, I will do it.

Thanks!

I hope this gets more straightforward with updates. As a side note, it doesn’t seem the plugin supports rewarded ads, which is fine, because I prefer to handle this entirely client-side. Still, I hope that now that Admob is paid it will be developed more actively.

OK. You can use your method in the mean time.

FYI. AdMob doesn’t support rewarded ads with their own ad network. AdMob only supports interstitials and banners.

Their *SDK* supports rewarded ads but it requires using mediation with other ad networks. Support for AdMob mediation is currently not planned as we have other plugins like Appodeal that provide mediation with other networks including the AdMob network.

I see. I thought it was a new native Admob feature. 

No problem then. Also as I said, since the plugin allows for checking of various phases (like ‘shown’) it is perfectly possible to do rewarded ads ‘manually’.

Don’t forget you can set flags that identify the type of add you are showing and use the various listener events to examine the flag and make decisions.

Rob

Thanks for the suggestion, Rob. BTW while we’re at it, not to start another thread:

Is there a way to determine whether the user closed the ad prematurely? Rewarded ads don’t make much sense if the user can launch them and close immediately still receiving the reward. Admob doesn’t give us control over preventing closing of the ad. Also I have a feeling that rewarding users for clicking the ad client-side goes against Admob’s TOS.

This is probably a better question for Ingemar_cl to answer. I see phases to indicate that it was closed or clicked. Interstitials (taking video out for the moment)  can only be shown, clicked and closed. “Watched to completion” is a video ad feature and I’m not sure how AdMob handles that since to AdMob their video ads are just interstitials.

Rob

@pirx

The AdMob SDK doesn’t have any features to prevent an ad from being closed “prematurely”. I guess you could implement some sort of timer where you measure the time between your call to show() and the event.phase==“closed” event, and decide if a reward should be given or not based on the time delta.

@ingemar_cl

Yeah, I figured that too. After all, I don’t really want to “prevent” users from dismissing the ad. I just don’t want to give a reward when they do, because it defeats the purpose of rewarded ads. 

I will implement the timer, as you say, and then field test it.

At the moment it’s not possible to distinguish one interstitial from another.

However it would be possible to add an extra data field to the callback which returns the adUnitId of the ad. You would need to set up 2 different ad units in the AdMob dashboard. With that setup you can check event.data returned in the callback and check which adUnitId generated the event. Keep in mind that with the existing API only one interstitial can be loaded at a time though…

BTW. I assume you’re using the paid AdMob plugin:

https://docs.coronalabs.com/plugin/admob/

Updates will only be made to this plugin. The legacy AdMob plugin will be retired in the near future although no specific date has been set yet.

Yes, I’m using the paid plugin. 

Good idea with checking event.data. Currently I settled for an external variable that is set to a particular value when the ad is displayed and then zeroed afterwards (two interstitials are never shown simultaneously so there’s no interference). The listener checks this variable to see the which ad is being shown.  It works but your way seems cleaner, I will do it.

Thanks!

I hope this gets more straightforward with updates. As a side note, it doesn’t seem the plugin supports rewarded ads, which is fine, because I prefer to handle this entirely client-side. Still, I hope that now that Admob is paid it will be developed more actively.

OK. You can use your method in the mean time.

FYI. AdMob doesn’t support rewarded ads with their own ad network. AdMob only supports interstitials and banners.

Their *SDK* supports rewarded ads but it requires using mediation with other ad networks. Support for AdMob mediation is currently not planned as we have other plugins like Appodeal that provide mediation with other networks including the AdMob network.

I see. I thought it was a new native Admob feature. 

No problem then. Also as I said, since the plugin allows for checking of various phases (like ‘shown’) it is perfectly possible to do rewarded ads ‘manually’.

Don’t forget you can set flags that identify the type of add you are showing and use the various listener events to examine the flag and make decisions.

Rob

Thanks for the suggestion, Rob. BTW while we’re at it, not to start another thread:

Is there a way to determine whether the user closed the ad prematurely? Rewarded ads don’t make much sense if the user can launch them and close immediately still receiving the reward. Admob doesn’t give us control over preventing closing of the ad. Also I have a feeling that rewarding users for clicking the ad client-side goes against Admob’s TOS.

This is probably a better question for Ingemar_cl to answer. I see phases to indicate that it was closed or clicked. Interstitials (taking video out for the moment)  can only be shown, clicked and closed. “Watched to completion” is a video ad feature and I’m not sure how AdMob handles that since to AdMob their video ads are just interstitials.

Rob

@pirx

The AdMob SDK doesn’t have any features to prevent an ad from being closed “prematurely”. I guess you could implement some sort of timer where you measure the time between your call to show() and the event.phase==“closed” event, and decide if a reward should be given or not based on the time delta.

@ingemar_cl

Yeah, I figured that too. After all, I don’t really want to “prevent” users from dismissing the ad. I just don’t want to give a reward when they do, because it defeats the purpose of rewarded ads. 

I will implement the timer, as you say, and then field test it.