Sending arbitrary data when the user takes an action. - SourcePointUSA/android-cmp-app GitHub Wiki
Publisher Data
Sourcepoint's endpoints allow for consent information to be retrieved programatically via APIs. Some times, you might want to send up some piece of information to our servers when the user takes an action, so you can retrieve it when querying our consent APIs/logs.
You can do that by mutating the consent action object before we send the action to our endpoints. When building the SDK, call the method setOnBeforeSendingConsent
passing a callback like the example below:
GDPRConsentLib.newBuilder(accountId, propertyName, propertyId, pmId, this)
// other .set methods
.setOnBeforeSendingConsent((action, done) -> {
HashMap<String, String> pubData = new HashMap<>();
pubData.put("foo", "bar");
action.setPubData(pubData);
done.post(action);
})
.build()
Notice: Since everything happens asynchronously, it's important to call the done.post(action)
to "notify" the SDK it can send the request to the server.
The SDK will send an object encoding your data in the shape of:
{
"pubData": {
"foo": "bar"
}
}