This RoboPod requires you to download and add the native 3rd party library manually:
- Download the SDK for iOS from https://dev.flurry.com
- Put the
libFlurryAds_X.X.X.a
file in your iOS project'slibs/
folder - Add the following to your
robovm.xml
<config>
...
<libs>
<lib>libs/libFlurryAds_X.X.X.a</lib>
</libs>
</config>
Change X.X.X
with the version number of the library.
Add the following dependency to your build.gradle
:
dependencies {
... other dependencies ...
compile "com.mobidevelop.robovm:robopods-flurry-ios-ads:$robopodsVersion"
}
Add the following dependency to your pom.xml
:
<dependency>
<groupId>com.mobidevelop.robovm</groupId>
<artifactId>robopods-flurry-ios-ads</artifactId>
<version>${robopods.version}</version>
</dependency>
Before you can display any ads, you have to setup the SDK.
Add the following code to your application's entry point, typically didFinishLaunching()
in your app delegate.
Flurry.startSession("API_KEY");
Change the API_KEY
with your key that you can find in your Flurry dashboard.
When setting up Flurry it's very helpful to get logs.
Add the following code before starting Flurry:
Flurry.setDebugLogEnabled(true);
Flurry.setLogLevel(FlurryLogLevel.All); // Adjust level to your needs.
...
Flurry.startSession("API_KEY");
Note: Don't forget to disable debug logging when you release your app!
- Make sure you have setup an app in your Flurry dashboard
and specified the correct
API_KEY
. - Check your logs for any errors, like network failures.
Cache and display ads.
Create a new instance of FlurryAdInterstitial
and store it as a member variable:
adInterstitial = new FlurryAdInterstitial("AD_SPACE_NAME");
Change AD_SPACE_NAME
with the one you setup in your Flurry dashboard.
You can optionally listen for certain events by setting the ad delegate:
adInterstitial.setAdDelegate(new FlurryAdInterstitialDelegateAdapter() {
@Override
public void didFetchAd(FlurryAdInterstitial interstitialAd) {
// You can choose to present the ad as soon as it is received.
// adInterstitial.present(viewController);
}
@Override
public void didDismiss(FlurryAdInterstitial interstitialAd) {
// Ideal time to fetch a new ad.
adInterstitial.fetchAd();
}
@Override
public void didFail(FlurryAdInterstitial interstitialAd, FlurryAdError adError, NSError errorDescription) {
// Ideal time to fetch a new ad.
adInterstitial.fetchAd();
}
});
To be able to display an ad later, you have to fetch an ad first. Do this as early as possible.
adInterstitial.fetchAd();
To display the interstitial use the following code:
if (adInterstitial.isReady()) {
adInterstitial.present(viewController);
} else {
adInterstitial.fetchAd();
}
You have to pass a UIViewController
when presenting the ad. Ideally you should setup the interstitial
in a view controller subclass and specify this
.
If you're developing a libGDX game you can just use the root view controller of the application:
UIViewController viewController = UIApplication.getSharedApplication().getKeyWindow().getRootViewController();
Create a new instance of FlurryAdBanner
and store it as a member variable:
adBanner = new FlurryAdBanner("AD_SPACE_NAME");
Change AD_SPACE_NAME
with the one you setup in your Flurry dashboard.
You can optionally listen for certain events by setting the ad delegate:
adBanner.setAdDelegate(new FlurryAdBannerDelegateAdapter() {
@Override
public void didFetchAd(FlurryAdBanner bannerAd) {
// If you used fetchAd(CGRect) you should display the banner now.
// adBanner.displayAd(viewController.getView(), viewController);
}
@Override
public void didFail(FlurryAdBanner bannerAd, FlurryAdError adError, NSError errorDescription) {
// Ideal time to fetch a new ad.
adBanner.fetchAd(getView().getFrame());
}
});
To be able to display an ad later, you have to fetch an ad first. Do this as early as possible.
// You can either only fetch the ad and display at a later time;
adBanner.fetchAd(viewController.getView().getFrame());
// Or you fetch and display the ad ASAP.
adBanner.fetchAndDisplayAd(viewController.getView(), viewController);
You have to pass a UIView
and UIViewController
when presenting the ad. Ideally you should setup
the banner in a view controller subclass and specify this.getView()
and this
.
If you're developing a libGDX game you can just get the root view controller of the application:
UIViewController viewController = UIApplication.getSharedApplication().getKeyWindow().getRootViewController();
Add the code for interstitials and banners to your app. If you want to see test ads, you can specify special targeting options on your ad instance:
FlurryAdTargeting targeting = new FlurryAdTargeting();
targeting.setTestAdsEnabled(true);
ad.setTargeting(targeting);
Run the app and display the ads. With test ads enabled you should always see an ad.