GPDR Consent Management Provider for Android
Switch branches/tags
Nothing to show
Clone or download
Latest commit 13e8bb3 Jun 11, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app Update build.gradle Jun 11, 2018
gradle/wrapper initial commit. May 27, 2018
.gitignore initial commit. May 27, 2018
README.md Update README.md May 31, 2018
build.gradle initial commit. May 27, 2018
gdpr_demo_1.png Add files via upload May 27, 2018
gdpr_demo_2.png Add files via upload May 27, 2018
gdpr_demo_3.png Add files via upload May 27, 2018
gdpr_demo_4.png Add files via upload May 27, 2018
gradle.properties initial commit. May 27, 2018
gradlew initial commit. May 27, 2018
gradlew.bat initial commit. May 27, 2018
settings.gradle initial commit. May 27, 2018

README.md

GPDR Consent Management Provider for Android

Android GDPR consent collection UI. Shows how shocklingly easy it is to detect if user is EU and subsequently present the CMP (Consent Management Platform). Writes the consent string in IAB format to shared preferences as specified by the IAB group. See MainActivityJava or MainActivityKotlin (both do the same thing!) https://github.com/gdprsdk/android-gdpr-demo/tree/master/app/src/main/java/org/gdpr/demo

Watch the video to see how the Demo works: https://bit.ly/2GTA9Dk

Link to the APK: https://bit.ly/2KTYjQD

The Demo app has 1 simple screen. This screen shows the current GDPR consent string and shows how to set this app as being subject to GDPR policy. Clicking on the 'Privacy Settings' button invokes the sdk by starting the GDPR CMP Activity for gathering consent from user (below).


This is the main GDPR SDK screen for gathering consent from user. The consent process is as simple as choosing "I Consent" or "I Do Not Consent". However, if the user wishes to have a more detailed/customized consent setup, press the Details button, leading us to the next screen below. There is a Trial notice, but everything will continue to work fine.


This is the customized/detailed GDPR SDK screen for gathering consent on a more granular level. The user may consent or (not consent) to itemized privacy categories and individual vendors. There are approximately 5 privacy categories and currently over 300 vendors! Checking or unchecking categories will automatically select or unselect vendors associated to those categories. Again, this screen exists for users who wish to have a more granular, customized privacy setup. Simply consenting to "I Consent" or "I Do Not Consent" on the previous main consent screen will suffice. The user needs to press 'SAVE' button to save their choices and the consent string will be saved.


After the user has gone thru the consent experience, which could be as simple as pressing "I Consent" or "I Do Not Consent" or "Save", the sdk brings you back to your original Demo app screen. You can see the new consent string. You can go back to the details screen to verify that the user consent settings have been persisted and saved.


Ideal use-case scenario in your app or game:

  1. Use our sdk method to determine if the user is in the EU --> GdprCmp.isSubjectToGDPR(..) Of course, you may use your own method to determine EU. The sdk method uses device locale.
  2. If EU, then set the application as being subject to GDPR. --> GdprCmp.setIsSubjectToGDPR(true)
  3. If user has not seen the consent UI yet, show it --> GdprCmp.startCmpActivityForResult(..)
  4. Receive onActivityResult callback and check result code against CmpActivityResult codes.
  5. If the user made a choice, then the consent string has been saved and you are done.
  6. Now, call GdprCmp.getGDPRConsentString() and set that value into the various 3rd party SDK's that require it.
  7. Finally, provide an overflow menu option for the user, if they wish, to open the privacy settings again. This provides users a way to change their privacy settings at any time.

GdprCmp methods:

/**
 * Starts the main CMP activity for gathering user consent.
 *
 * @param activity - parent activity
 * @param requestCode - activity request code
 * @param allowBackButton - if true, allows user to back out of CMP screen.  Otherwise, no.
 * @param defaultConsentAll - if true and if the first time and user goes thru to CMP Details, then
 *                          all consent items will be checked on.  Otherwise, all checked off.
 *                          
 * Uses CmpActivityResult for activity result codes.
 */
public static void startCmpActivityForResult(Activity activity, int requestCode, boolean allowBackButton, boolean defaultConsentAll);



/**
 * Starts the CMP Details activity for gathering user consent.
 *
 * @param activity - parent activity
 * @param requestCode - activity request code
 * @param allowBackButton - if true, allows user to back out of CMP screen.  Otherwise, no.
 * @param defaultConsentAll - if true and if the first time, then all consent items will be checked on.  
 *                          Otherwise, all checked off.
 *                          
 * Uses CmpActivityResult for activity result codes.
 */
public static void startCmpDetailsActivityForResult(Activity activity, int requestCode, boolean allowBackButton, boolean defaultConsentAll);



/**
 * Stores the consent string to default shared preferences following IAB specs.
 *
 * @param context
 * @param iabConsentString
 */
public static void setGDPRConsentString(final Context context, final String iabConsentString);



/**
 * Sets the app as being subject to GDPR or not.
 *
 * @param context
 * @param isSubjectToGDPR - true sets this app as being subject to GDPR.  false, not subject.
 */
public static void setIsSubjectToGDPR(final Context context, final boolean isSubjectToGDPR);



/**
 * Indicates if the app is subject to GDPR.  If 'setIsSubjectToGDPR' has not been invoked yet,
 * then checks device settings to see if it's in a EU country.  If in EU country, then returns true.  
 *
 * @param context
 * @return
 */
public static boolean isSubjectToGDPR(Context context);



/**
 * Returns the existing consent string stored in shared preferences.
 *
 * @param context
 * @return consent string. null, if not yet stored.
 */
public static String getGDPRConsentString(Context context);




/**
 * Indicates if consent string has been set.
 *
 * @param context
 * @return
 */
public static boolean hasGDPRConsentString(Context context);



/**
 * Removes GDPR settings from shared preferences of this app.  Useful for testing.
 * Otherwise, not recommended.
 *
 * @param context
 */
public static void clearGDPRSettings(Context context);



/**
 * Starts the CMP Details activity for gathering user consent.
 *
 * @param activity - parent activity
 * @param requestCode - activity request code
 * @param allowBackButton - if true, allows user to back out of CMP screen.  Otherwise, no.
 * @param defaultConsentAll - if true and if the first time, then all consent items will be checked on.  
 *                          Otherwise, all checked off.
 *                          
 * Uses CmpActivityResult for activity result codes.
 */
public static void startCmpDetailsActivityForResult(Activity activity, int requestCode, boolean allowBackButton, boolean defaultConsentAll);



/**
 * Stores the consent string to default shared preferences following IAB specs.
 *
 * @param context
 * @param iabConsentString
 */
public static void setGDPRConsentString(final Context context, final String iabConsentString);



/**
 * Sets the app as being subject to GDPR or not.
 *
 * @param context
 * @param isSubjectToGDPR - true sets this app as being subject to GDPR.  false, not subject.
 */
public static void setIsSubjectToGDPR(final Context context, final boolean isSubjectToGDPR);



/**
 * Indicates if the app is subject to GDPR.  If 'setIsSubjectToGDPR' has not been invoked yet,
 * then checks device settings to see if it's in a EU country.  If in EU country, then returns true.  
 *
 * @param context
 * @return
 */
public static boolean isSubjectToGDPR(Context context);



/**
 * Returns the existing consent string stored in shared preferences.
 *
 * @param context
 * @return consent string. null, if not yet stored.
 */
public static String getGDPRConsentString(Context context);



/**
 * Indicates if consent string has been set, i.e. stored in shared preferences.
 *
 * @param context
 * @return
 */
public static boolean hasGDPRConsentString(Context context);



/**
 * Removes GDPR settings from shared preferences of this app.  Useful for testing.
 * Otherwise, not recommended.
 *
 * @param context
 */
public static void clearGDPRSettings(Context context);