Skip to content

Instantly share code, notes, and snippets.

@johncodeos johncodeos/Constant.kt
Last active Sep 6, 2019

Embed
What would you like to do?
class Constant {
class MoPub {
companion object {
val BANNER_AD_UNIT = "b195f8dd8ded45fe847ad89ed1d016da"
val MAIN_TEXT =
"This app presonalizes your advertising experience " +
"through MoPub, a division of Twitter International " +
"company. By consenting to this enhanced ad " +
"experience, you'll see ads that MoPub and it's " +
"partners believe are more relevant to you. " +
"Depending on your privacy settings, MoPub and it's " +
"partners may collect and process personal data " +
"such as device identifiers, location data, and other " +
"demographic and interest data about you to " +
"provide this personalized advertising experience."
val NOTE_TEXT =
"By agreeing, you are confirming that you are over " +
"the age of 16 and would like a personalized ad " +
"experience."
val FOOTER_TEXT =
"I understand that I will see ads, but they may " +
"not be as relevant to my interests"
}
}
}
class CustomConsentDialog : AppCompatActivity() {
private lateinit var mPersonalInfoManager: PersonalInfoManager
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_custom_consent_dialog)
title = "Personalize Your Experience"
mPersonalInfoManager = MoPub.getPersonalInformationManager()!!
gdpr_main_text.text = Constant.MoPub.MAIN_TEXT
gdpr_note_text.text = Constant.MoPub.NOTE_TEXT
gdpr_footer_text.text = Constant.MoPub.FOOTER_TEXT
gdpr_agree_btn.setOnClickListener {
// Call this to let MoPub know the user has granted consent
mPersonalInfoManager.grantConsent()
finish()
}
gdpr_disagree_btn.setOnClickListener {
// Call this to let MoPub know the user has revoked consent.
mPersonalInfoManager.revokeConsent()
finish()
}
}
}
private fun GDPRConsent() {
mPersonalInfoManager = MoPub.getPersonalInformationManager()!!
Log.d("MoPub", "This country covered by GDPR? ${mPersonalInfoManager.gdprApplies()}")
if (mPersonalInfoManager.shouldShowConsentDialog()) {
val intent = Intent(mContext, CustomConsentDialog::class.java)
mContext.startActivity(intent)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.