iOS Library
(Old content)
Hi all.
As you may have noticed, the way to deploy Android apps has changed: the newest version of the official Android port doesn't use ant anymore, but uses the Gradle wrapper.
Therefore a new AdMob library is needed.
I want to thank Master Both, the author of this beautiful library for having let me use some of his code.
There is another reason I made this library: the functions are the same of the iOS library I have made before.
(New content)
The library has been updated to LÖVE 11.3!
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've added 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.
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.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.
https://bitbucket.org/bio1712/love2d-admob-android
(LÖVE version: 11.3)
How to use:
In order to use this library you need to follow the instructions here.
In addition, you have to open SDK manager and download Google Play Services under the extras menu.
Included in the source, there is an example game.love.
To use the library you need to open ./love/src/main/java/org/love2d/android/AdActivity.java and
1) Insert your app ID at line 63
2) Insert your publisher ID at line 66 (needed for the Consent SDK)
3) Insert your privacy policy URL at line 67 (needed for the Consent SDK)
4) Add your test devices for each kind of ad.
5) You can disable the Consent SDK by turning the boolean "collectConsent" to false at line 65.
Then, open ./app/src/main/AndroidManifest.xml and set your app ID at line 81.
Note: all the Ad-Unit IDs in the game.love are from this url.
Screenshots:
![Image](https://i.postimg.cc/yxkFj9dQ/Screenshot-20200207-152135-org-love2d-android.jpg)
![Image](https://i.postimg.cc/pT0fKk25/Screenshot-20200207-152203-org-love2d-android.jpg)
![Image](https://i.postimg.cc/CKgs0zP5/Screenshot-20200207-152239-org-love2d-android.jpg)
![Image](https://i.postimg.cc/k5GWNz5N/Screenshot-20200207-152419-org-love2d-android.jpg)
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.
Sample APK: https://bitbucket.org/bio1712/love2d-ad ... -debug.apk