Integrate iframe-manager with CookieConsent
mainYou can synchronize the state of iframe-manager with CookieConsent (v1.2.0+) by using the onChange callback. When a user clicks the loadAllBtn button, the eventSource.type will be 'click'. You can then retrieve the currently accepted services from CookieConsent and merge them with the changedServices provided by the onChange callback to ensure all newly loaded services are also accepted in CookieConsent.
im.run({
currLang: 'en',
onChange: ({changedServices, eventSource}) => {
if(eventSource.type === 'click') {
/**
* Retrieve array of already accepted services
* and add the new service
*/
const servicesToAccept = [
...CookieConsent.getUserPreferences().acceptedServices['analytics'], //cookieconsent v3
...changedServices
];
CookieConsent.acceptService(servicesToAccept, 'analytics');
}
},
services: {
// ...
}
});