This RoboPod requires you to download and add the native 3rd party framework manually:
- Put the
PersonalizedAdConsent.framework
into your iOS project'slibs
folder. - Put the
PersonalizedAdConsent.bundle
into your iOS project'sresources/
folder. - Add the following to your
robovm.xml
<config>
...
<frameworkPaths>
<path>libs</path>
</frameworkPaths>
<resources>
...
<resource>
<directory>resources</directory>
</resource>
</resources>
<frameworks>
...
<framework>GoogleMobileAds</framework>
</frameworks>
</config>
Add the following dependency to your build.gradle
:
dependencies {
... other dependencies ...
compile "com.mobidevelop.robovm:robopods-google-ad-consent-ios:$robopodsVersion"
}
Add the following dependency to your pom.xml
:
<dependency>
<groupId>com.mobidevelop.robovm</groupId>
<artifactId>robopods-google-ad-consent-ios</artifactId>
<version>${robopods.version}</version>
</dependency>
To use the SDK for debug purposes, you will need to retrieve the debug identifier for your device, and add it to the PACConsentInformation instance:
String debugAdIdentifier = ASIdentifierManager.getSharedManager().getAdvertisingIdentifier().asString();
PACConsentInformation.getSharedInstance().setDebugIdentifiers(NSArray.fromStrings(debugAdIdentifier));
The following code shows you how to set the debug location and consent status for your device, when the app loads:
PACConsentInformation.getSharedInstance().setDebugGeography(PACDebugGeography.EEA);
PACConsentInformation.getSharedInstance().setConsentStatus(PACConsentStatus.Unknown);
PACConsentInformation.getSharedInstance().requestConsentInfoUpdateForPublisherIdentifiers(NSArray.fromStrings("pub-0123456789012345"),
new VoidBlock1<NSError>() {
@Override
public void invoke(NSError nsError) {
if(nsError != null) {
// Error Occured
} else {
PACConsentStatus consentStatus = PACConsentInformation.getSharedInstance().getConsentStatus();
// Handle consentStatus
}
}
}
);
NSURL privacyUrl = new NSURL("https://yoursite.com/privacyurl");
PACConsentForm form = new PACConsentForm(privacyUrl);
form.setShouldOfferAdFree(true);
form.setShouldOfferNonPersonalizedAds(true);
form.setShouldOfferPersonalizedAds(true);
form.loadWithCompletionHandler(new VoidBlock1<NSError>() {
@Override
public void invoke(NSError nsError) {
if (nsError != null) {
// Error occured
} else {
UIViewController viewController = UIApplication.getSharedApplication().getKeyWindow().getRootViewController();
form.presentFromViewController(viewController, new VoidBlock2<NSError, Boolean>() {
@Override
public void invoke(NSError nsError, Boolean aBoolean) {
if (nsError != null) {
// Error occured
} else if(aBoolean) {
// User prefers ad free
} else {
PACConsentStatus consentStatus = PACConsentInformation.getSharedInstance().getConsentStatus();
// Handle consentStatus
}
}
});
}
}
});
GADExtras extras = new GADExtras();
extras.setAdditionalParameters(new NSDictionary<>(new NSString("npa"), new NSString("1")));
GADRequest request = new GADRequest();
request.registerAdNetworkExtras(extras);