The Sourcepoint Native Message API allows your developers to integrate consent management capabilities into your mobile apps while still allowing campaign management to be handled by non-technical users.
This API will allow developers to build native consent experiences for their users that include both IAB concepts for the TCF v2 (Vendors, Purposes, Features, Special Features, Special Purposes) as well as non-TCF (GDPR Standard), custom purposes and vendors.
Note: The documentation to set native message first layer and privacy managers can be found in our article Native App Messages - Message Builder. This step is required to complete the setup.
Please refer to the complete native message documentation in the Sourcepoint Github resource centre for iOS and Android.
App setup
In your app code your developers will need to specify the ids for account, campaign, property and the property name. In the class ViewController you will need to update these values in the code:
Parameter | Description | Example value |
accountId |
The account id of your organization | 22 |
propertyName |
The property name as shown in the Sourcepoint portal dashboard | tcfv2.mobile.demo |
gdprPMId |
The id of the GDPR property manager | 566358 |
ccpaPMId |
The id of the U.S. Privacy - CCPA property manager | 566360 |
Note: This code sample is from Sourcepoint's iOS app resource page on Github.
import UIKit
import Foundation
import ConsentViewController
class ViewController: UIViewController {
var idfaStatus: SPIDFAStatus { SPIDFAStatus.current() }
let myVendorId = "5f23e826b8e05c0c0d4fdb8f" // sourcepoint vendor id
let myPurposesId = [
"61767550ee493f0617946a3e", // Store and/or access information on a device
"61767550ee493f0617946a5b", // Select personalised content
"61767550ee493f0617946a66", // Measure content performance
"61767550ee493f0617946a71" // Develop and improve products
]
let accountId = 22
let propertyName = try! SPPropertyName("ios.native.demo")
let campaigns = SPCampaigns (
gdpr: SPCampaign(),
ccpa: SPCampaign(),
ios14: SPCampaign()
)
let gdprPMId = "566358"
let ccpaPMId = "566360"
@IBOutlet weak var idfaStatusLabel: UILabel!
@IBOutlet weak var myVendorAcceptedLabel: UILabel!
@IBOutlet weak var acceptMyVendorButton: UIButton!
@IBOutlet weak var gdprPMButton: UIButton!
@IBOutlet weak var ccpaPMButton: UIButton!
var messageController: NativeMessageViewController!
@IBAction func onNetworkCallsTap(_ sender: Any) {
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "wormholy_fire"), object: nil)
}
@IBAction func onClearConsentTap(_ sender: Any) {
SPConsentManager.clearAllData()
updateUI()
}
@IBAction func onGDPRPrivacyManagerTap(_ sender: Any) {
consentManager.loadGDPRPrivacyManager(withId: gdprPMId)
showSpinner()
}
@IBAction func onCCPAPrivacyManagerTap(_ sender: Any) {
consentManager.loadCCPAPrivacyManager(withId: ccpaPMId)
showSpinner()
}
@IBAction func onAcceptMyVendorTap(_ sender: Any) {
consentManager.customConsentGDPR (vendors: [myVendorId], categories: myPurposesId, legIntCategories: []) {
[weak self] consents in
let vendorAccepted = consents.vendorGrants[self?.myVendorId ?? ""]?.granted
self?.updateMyVendorUI(vendorAccepted)
}
}
lazy var consentManager: SPConsentManager = { SPConsentManager(
accountId: accountId,
propertyName: propertyName,
campaigns: campaigns,
delegate: self
)}()
override func viewDidLoad() {
super.viewDidLoad()
updateUI()
consentManager.loadMessage()
}
}
Note: This code sample is from Sourcepoint's Android app resource page on Github.
package com.sourcepoint.app.v6
import android.os.Bundle
import android.text.method.ScrollingMovementMethod
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.graphics.toColorInt
import com.sourcepoint.cmplibrary.NativeMessageController
import com.sourcepoint.cmplibrary.SpClient
import com.sourcepoint.cmplibrary.core.nativemessage.MessageStructure
import com.sourcepoint.cmplibrary.core.nativemessage.NativeAction
import com.sourcepoint.cmplibrary.core.nativemessage.NativeComponent
import com.sourcepoint.cmplibrary.creation.delegate.spConsentLibLazy
import com.sourcepoint.cmplibrary.exception.CampaignType
import com.sourcepoint.cmplibrary.model.ConsentAction
import com.sourcepoint.cmplibrary.model.MessageLanguage
import com.sourcepoint.cmplibrary.model.PMTab
import com.sourcepoint.cmplibrary.model.exposed.NativeMessageActionType
import com.sourcepoint.cmplibrary.model.exposed.SPConsents
import com.sourcepoint.cmplibrary.util.clearAllData
import kotlinx.android.synthetic.main.native_message.view.*
import kotlinx.android.synthetic.main.only_gdpr.*
import org.json.JSONObject
class NativeMessageActivity : AppCompatActivity() {
private val spConsentLib by spConsentLibLazy {
activity = this@NativeMessageActivity
spClient = LocalClient()
config {
accountId = 22
propertyName = "mobile.multicampaign.native.demo2"
messLanguage = MessageLanguage.ENGLISH
messageTimeout = 3000
+(CampaignType.GDPR)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.only_gdpr)
review_consents_gdpr.setOnClickListener {
spConsentLib.loadPrivacyManager (
"548285",
PMTab.PURPOSES,
CampaignType.GDPR
)
}
clear_all.setOnClickListener { clearAllData(this) }
}
override fun onResume() {
super.onResume()
spConsentLib.loadMessage()
}
...
...
...
private fun setRejectAllBtn(view: View, na: NativeAction) {
view.reject_all.run {
text = na.text
setBackgroundColor(na.style.backgroundColor.toColorInt() ?: throw RuntimeException())
setTextColor(na.style.color?.toColorInt() ?: throw RuntimeException())
textSize = na.style.fontSize ?: 10F
}
}
private fun setAcceptAllBtn(view: View, na: NativeAction) {
view.accept_all.run {
text = na.text
setBackgroundColor(na.style.backgroundColor.toColorInt() ?: throw RuntimeException())
setTextColor(na.style.color?.toColorInt() ?: throw RuntimeException())
textSize = na.style.fontSize ?: 10F
}
}
}
Use of the Native Message API may require the developer to persist some state information like:
- User identifiers
- Campaign related metadata
Comments
0 comments