Skip to content

Commit c242140

Browse files
committed
Clean up code and update README.md
1 parent e3bf5ce commit c242140

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
This plugin provides the integration points for the OneTrust CMP SDK.
44

5+
For more information on on Segment Managed CMP, including how to use this integration, check out the analytics-kotlin-consent repo:
56

7+
[https://github.com/segment-integrations/analytics-kotlin-consent](https://github.com/segment-integrations/analytics-kotlin-consent).
68

79
## Getting Started
810

@@ -13,7 +15,6 @@ To get started add the dependency for OneTrust CMP consent integration to your a
1315
```
1416

1517

16-
1718
## License
1819
```
1920
MIT License

lib/src/main/java/com/segment/analytics/kotlin/destinations/consent/onetrust/OneTrustConsentChangedNotifier.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import com.onetrust.otpublishers.headless.Public.Keys.OTBroadcastServiceKeys
88
import com.segment.analytics.kotlin.destinations.consent.ConsentManagementPlugin
99
import java.lang.ref.WeakReference
1010

11-
class OneTrustConsentChangedNotifier(val contextReference: WeakReference<Context>, val categories: List<String>, val consentPlugin: ConsentManagementPlugin) {
11+
class OneTrustConsentChangedNotifier(
12+
val contextReference: WeakReference<Context>,
13+
val categories: List<String>,
14+
val consentPlugin: ConsentManagementPlugin
15+
) {
1216

1317
private val consentChangedReceiver: BroadcastReceiver? = null
1418

@@ -17,11 +21,14 @@ class OneTrustConsentChangedNotifier(val contextReference: WeakReference<Context
1721
unregister()
1822
}
1923

24+
val context = contextReference.get()
2025
categories.forEach {
21-
val context = contextReference.get()
2226

2327
if (context != null) {
24-
context.registerReceiver(OneTrustConsentChangedReceiver(consentPlugin), IntentFilter(OTBroadcastServiceKeys.OT_CONSENT_UPDATED))
28+
context.registerReceiver(
29+
OneTrustConsentChangedReceiver(consentPlugin),
30+
IntentFilter(OTBroadcastServiceKeys.OT_CONSENT_UPDATED)
31+
)
2532
}
2633
}
2734
}
@@ -32,10 +39,10 @@ class OneTrustConsentChangedNotifier(val contextReference: WeakReference<Context
3239
context.unregisterReceiver(consentChangedReceiver)
3340
}
3441
}
35-
3642
}
3743

38-
class OneTrustConsentChangedReceiver(val consentPlugin: ConsentManagementPlugin): BroadcastReceiver() {
44+
class OneTrustConsentChangedReceiver(val consentPlugin: ConsentManagementPlugin) :
45+
BroadcastReceiver() {
3946
override fun onReceive(context: Context?, intent: Intent?) {
4047
consentPlugin.notifyConsentChanged()
4148
}

testapp/src/main/java/com/segment/analytics/destinations/mydestination/testapp/MainApplication.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class MainApplication: Application() {
5050
)
5151
}
5252

53-
// List of categories we care about: Must be configured on the Segment
54-
// web app.
53+
// List of categories we care about; we will query OneTrust SDK locally on the status
54+
// of these categories when stamping an event with consent status.
5555
val categories = listOf<String>("C0001", "C0002")
5656
val consentCategoryProvider = OneTrustConsentCategoryProvider(otPublishersHeadlessSDK, categories)
5757
val store = SynchronousStore()

0 commit comments

Comments
 (0)