Coder Social home page Coder Social logo

tw1ddle / samcodes-consent Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 1.2 MB

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

Home Page: https://samcodes.co.uk/code/

License: MIT License

Haxe 8.07% Batchfile 0.12% C++ 3.48% Objective-C++ 7.13% Shell 0.30% Objective-C 51.91% HTML 28.99%
gdpr gdpr-consent haxe openfl ads

samcodes-consent's Introduction

Samcodes Consent

License

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

This is deprecated - I am no longer updating it because I do not currently use ads requiring GDPR consent in my projects. Feel free to fork this and bring it up to date though!

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.

samcodes-consent's People

Contributors

tw1ddle avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

filipp8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.