[11.2] AdMob support for iOS + EU Consent

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
bio1712
Citizen
Posts: 58
Joined: Wed Aug 19, 2015 4:13 pm
Location: Italy

[11.2] AdMob support for iOS + EU Consent

Post by bio1712 » Fri Jul 21, 2017 9:14 pm

AdMob support for iOS!

Android Library

(Old content)
Here I made a modified version of LÖVE 0.10.2, with a new module:
love.ads!

With this module is possible to request and display ads from LÖVE!
An AdMob account is needed in order to use this module.


(New content)

The library has been updated to LÖVE 11.2!
With this library you can display AdMob ads (banners, interstitial and rewarded video) and collect consent from the European users as required by the GPDR law (more info here)

I have added 11 functions and 5 callbacks:

love.ads Functions
  • love.ads.createBanner(string adUnitID,string position)
    string adUnitID : Your banner ad unit id.
    string position : The position of the banner. Can be "top" or "bottom".
    Initializes the banner ad without displaying it. This function may be fired only once.
    The banner inizialized is a smart banner.
  • love.ads.showBanner()
    Displays the banner ad. This function may be fired after createBanner
  • love.ads.hideBanner()
    Hides the banner ad. This function may be fired after createBanner
  • love.ads.requestInterstitial(string adUnitID)
    string adUnitID : Your interstitial ad unit id.
    Requests an interstitial ad. This function should be called every time a new ad is needed.
  • love.ads.isInterstitialLoaded()
    Check if the interstitial ad previously requested is ready to be shown.

    Returns:
    bool isAdReady: true if the ad is ready to be shown.
  • love.ads.showInterstitial()
    Displays the interstitial ad. May be called only if the ad is loaded.
  • love.ads.requestRewardedAd(string adUnitID)
    string adUnitID : Your rewarded ad unit id.
    Requests a rewarded video ad. This function should be called every time a new ad is needed.
  • love.ads.isRewardedAdLoaded()
    Check if the rewarded video ad previously requested is ready to be shown.

    Returns:
    bool isAdReady: true if the ad is ready to be shown.
  • love.ads.showRewardedAd()
    Displays the rewarded video ad. May be called only if the ad is loaded.
  • love.ads.getDeviceLanguage()
    Returns:
    string deviceLanguage: the code of the language set on the device. (Example: EN,FR,IT)
    It can be useful for internationalization.
  • love.ads.changeEUConsent()
    Shows the Consent View to let the user change his consent.
love.ads Callbacks
  • love.interstitialFailedToLoad()
    Fired when an interstitial ad fails to load.
  • love.interstitialClosed()
    Fired when the user closes an interstitial ad.
  • love.rewardedAdFailedToLoad()
    Fired when a rewarded video ad fails to load.
  • love.rewardUserWithReward(string rewardType,number rewardQuantity)
    string rewardType : The type of the reward you set in your AdMob dashboard.
    number rewardQuantity : The quantity of rewards you set in you AdMob dashboard.

    Fired when a rewarded video ad successfully finishes playing.
  • love.rewardedAdDidStop()
    Fired when a rewarded video ad is closed by the user.
    This callback is fired even if the video has already finished.
love.ads.createBanner(adID,"bottom") takes into account the safe area in devices without a home button.

Here is the repository of the library:
https://bitbucket.org/bio1712/love2d-ad ... rc/master/

In order to use it, just open the Xcode project and build it!
Then, open liblove.xcodeproj/modules/ads/Ads.mm and:
1) Insert your privacy policy URL at line 81 (needed for Consent SDK)
2) Insert your application ID at line 82
3) Insert your publisher ID at line 83
4) Set up your test devices.
You can disable the Consent SDK by turning the boolean collectConsent at line 84 to false.

Included in the source, there is an example game.love.

Note: all the Ad-Unit IDs in the game.love are from this url.

Screenshots:

Image

Image

Image

Image

Second note: This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Last edited by bio1712 on Tue Jul 09, 2019 5:23 pm, edited 3 times in total.

User avatar
yetneverdone
Party member
Posts: 351
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: AdMob support for iOS!

Post by yetneverdone » Mon Jul 24, 2017 9:50 am

Cool! That's what i was waiting for. Thanks.

Anyways, i have question:
1. What do you need to build a project with that added functions?

bio1712
Citizen
Posts: 58
Joined: Wed Aug 19, 2015 4:13 pm
Location: Italy

Re: AdMob support for iOS!

Post by bio1712 » Mon Jul 24, 2017 11:49 am

yetneverdone wrote:
Mon Jul 24, 2017 9:50 am
Cool! That's what i was waiting for. Thanks.

Anyways, i have question:
1. What do you need to build a project with that added functions?
Hi, thanks for replying.
To build this project you need only the source, and you build it like you built the official love project.
The love.ads module is automatically required by your game.love.

User avatar
Rucikir
Party member
Posts: 128
Joined: Tue Nov 05, 2013 6:33 pm
Location: Paris
Contact:

Re: AdMob support for iOS!

Post by Rucikir » Mon Jul 24, 2017 12:56 pm

You could fork LÖVE git repository and branch from 0.10.2, and apply your changes here. It will be easier to maintain and to use.
Lua script to distribute your LÖVE games. love-release.lua : Forum | Github
@Rucikir

User avatar
yetneverdone
Party member
Posts: 351
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: AdMob support for iOS!

Post by yetneverdone » Mon Jul 24, 2017 1:24 pm

I agree with ruckir

User avatar
Marty
Citizen
Posts: 89
Joined: Mon Dec 04, 2017 1:47 am
Location: Germany

Re: AdMob support for iOS!

Post by Marty » Sun Jan 07, 2018 9:46 pm

First of all, thank you for your great work.

Please make it easier to find the place where I have to put the App ID. On Android there is a string "YOUR-APP-ID-HERE" that is easy to spot in the AdActivity. However, this thing is missing in the Ads.mm and I was not able to spot it anywhere so far.

Where is it located?
Visual Studio Code TemplateRichLÖVE Mobile (AdMob+UnityAds+PlayGamesServices+GameCenter)Add me on Discord

───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄───
───█▒▒░░░░░░░░░▒▒█───
────█░░░░░░░░░█────
▄▄──█░░░▀█▀░░░█──▄▄
█░░█▀▄░░░░░░░▄▀█░░█

User avatar
Marty
Citizen
Posts: 89
Joined: Mon Dec 04, 2017 1:47 am
Location: Germany

Re: AdMob support for iOS!

Post by Marty » Fri Mar 23, 2018 2:34 am

For everybody having the same issue, here is what worked for me.

I replaced the constructor of the modules/ads/Ads.mm to

Code: Select all

Ads::Ads()
{
	[GADMobileAds configureWithApplicationID:@"YOUR_ADMOB_APP_ID"];
}
with my proper App-ID of course.


Also if you want to test it with real ads, make sure you configure your payment methods on the admob platform.
Visual Studio Code TemplateRichLÖVE Mobile (AdMob+UnityAds+PlayGamesServices+GameCenter)Add me on Discord

───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄───
───█▒▒░░░░░░░░░▒▒█───
────█░░░░░░░░░█────
▄▄──█░░░▀█▀░░░█──▄▄
█░░█▀▄░░░░░░░▄▀█░░█

bio1712
Citizen
Posts: 58
Joined: Wed Aug 19, 2015 4:13 pm
Location: Italy

Re: AdMob support for iOS!

Post by bio1712 » Fri Mar 23, 2018 3:13 pm

modiX wrote:
Sun Jan 07, 2018 9:46 pm
First of all, thank you for your great work.

Please make it easier to find the place where I have to put the App ID. On Android there is a string "YOUR-APP-ID-HERE" that is easy to spot in the AdActivity. However, this thing is missing in the Ads.mm and I was not able to spot it anywhere so far.

Where is it located?
Hi, I'm sorry I haven't seen this post before. Please forgive me.

As you have noticed, I've replied here.

deulamco
Prole
Posts: 1
Joined: Fri Apr 27, 2018 6:58 am

Re: AdMob support for iOS!

Post by deulamco » Fri Apr 27, 2018 7:00 am

Hello there, would you mind making a pull request to the official LOVE2D hub ?
So the Ads ( and future IAP module ) could come along with new version :D

bio1712
Citizen
Posts: 58
Joined: Wed Aug 19, 2015 4:13 pm
Location: Italy

Re: [11.2] AdMob support for iOS + EU Consent

Post by bio1712 » Tue Jul 09, 2019 5:31 pm

I've updated this library to work with LÖVE 11.2.
I've also implemented Google Consent SDK to collect consent from European users, as required by GPDR law.
Now, the banner at the bottom take into account the safe area in devices without a home button.
Finally I've added two new functions: love.ads.changeEUConsent() and love.ads.getDeviceLanguage(), that can be useful for internationalization.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests