Skip to content

Google Mobile Ads Consent SDK Haxe bindings for Haxe OpenFL Android/iOS targets

License

Notifications You must be signed in to change notification settings

filipp8/samcodes-consent

 
 

Repository files navigation

Samcodes Consent

Travis Build Status License

Unofficial Google Mobile Ads Consent SDK bindings for Haxe OpenFL Android and iOS targets. See the demo app here.

Features

Supports:

  • Retrieving GDPR/ads consent status a user has picked.
  • Displaying pre-made Google Mobile Ads SDK consent form.
  • Customizable listeners for handling Consent SDK events.
  • Checking if a consent request came from within the EEA.

Install

haxelib git samcodes-consent https://github.com/Tw1ddle/samcodes-consent

Example

See the demo app for an example.

Screenshot of demo app

Usage

Getting the user's current consent status:

// Extend ConsentListener to handle the onConsentInfoUpdated and onFailedToUpdateConsentInfo callbacks
Consent.setConsentListener(new MyConsentListener());

// Make the request to determine the status of a user's consent
Consent.requestStatus("your-publisher-id-from-ads-dashboard");

When we receive the current status, we can check if the request came from within the European Economic Area:

// Note this will only return a valid value after the onConsentInfoUpdated callback triggers
if(!Consent.isRequestLocationInEeaOrUnknown()) {
    return; // There is no need to show a consent form to users outside EEA, and the SDK might not let you anyway
}

Finally you can load and display the consent form:

// Extend ConsentFormListener to handle the onConsentFormLoaded, onConsentFormOpened, onConsentFormClosed and onConsentFormError callbacks
// Note, you need to call Consent.showConsentForm() in the onConsentFormLoaded callback to actually show the form once it loads.
Consent.setConsentFormListener(new MyConsentFormListener());

// Request the Google-rendered consent form
var personalizedAdsOption = true;
var nonPersonalizedAdsOption = true;
var adFreeOption = false;
Consent.requestConsentForm("https://www.samcodes.co.uk", personalizedAdsOption, nonPersonalizedAdsOption, adFreeOption);

Finally record the consent response from the onConsentFormClosed callback to game saved data (or whatever is appropriate) so you don't have to show the form every time.

Notes

  • At time of writing, callbacks on Android run on the wrong thread due to an issue in lime.
  • At time of writing, the Consent SDK form shows lots of partner privacy policies that may be irrelevant to your app.
  • On iOS you have to drag-drop the consent form from the PersonalizedAdConsent bundle into your Xcode project. See this thread in the OpenFL forums.
  • Refer to the official Google Mobile Ads Consent SDK documentation for Android and iOS.
  • Use #if (android || ios) conditionals around your imports and calls to this library for cross platform projects - there is no stub/fallback implementation included in the haxelib.
  • If you need to rebuild the iOS or simulator ndlls, navigate to /project and run rebuild_ndlls.sh.
  • Got an idea or suggestion? Open an issue on GitHub, or send Sam a message on Twitter.

About

Google Mobile Ads Consent SDK Haxe bindings for Haxe OpenFL Android/iOS targets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Haxe 30.8%
  • Objective-C 27.2%
  • Objective-C++ 27.1%
  • C++ 13.2%
  • Shell 1.2%
  • Batchfile 0.5%