Angular
Angular is currently in public preview and as a result the way this feature is used may change over time.
Use with caution in production environments.
import { CommonModule } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { IabPrivacyConsentPurposeId, IabPrivacyConsentPurposeIdMap } from '@seeka-labs/converge';
import { SeekaService } from '@seeka-labs/converge-angular-lib';
@Component({
selector: 'app-home',
standalone: true,
imports: [CommonModule],
template: `
<div class="content">
<button (click)="optOut()">Consent opt out</button>
<button (click)="optIn()">Consent opt in</button>
</div>
`
})
export class HomeComponent implements OnInit {
trackingStatus: string | null = null;
constructor(private seekaService: SeekaService) { }
optOut(): void {
const converge = this.seekaService.getConverge();
if (converge) {
converge.privacy.setPrivacyState({
deniedIabPurposeIds: [IabPrivacyConsentPurposeIdMap[IabPrivacyConsentPurposeId.MeasureAdvertisingPerformance]],
grantedIabPurposeIds: []
});
}
}
optIn(): void {
const converge = this.seekaService.getConverge();
if (converge) {
converge.privacy.setPrivacyState({
deniedIabPurposeIds: [],
grantedIabPurposeIds: [IabPrivacyConsentPurposeIdMap[IabPrivacyConsentPurposeId.MeasureAdvertisingPerformance]]
});
}
}
}