getGrantedNames(): TConsentName[]¶
The getGrantedNames
method returns an array of consents that have been granted by the user.
Input parameters¶
none
Returned value¶
A returned value has a type of TConsentName[]
which represents an array of consent names. To see all the possible consent names see the Consent names section of the Customer Privacy API.
Example¶
In this example we make a customerPrivacyApi
call to get names of the currently granted consents.
useStorefront((storefront) => {
const customerPrivacyApi = await storefront.getApi('customerPrivacyApi');
const grantedConsents = customerPrivacyApi.getGrantedNames(); // ['marketingConsent', 'analyticsConsent']
});
Customer Privacy API methods reference¶
- grantConsents
- onAnalyticsConsentGranted
- onMarketingConsentGranted
- onFunctionalConsentGranted
- onPlatformConsentGranted
- showConsentsModal
- showAdvancedConsentsModal
- withdrawConsents
- saveConsents
- isCookieInformationEnabled