-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getEnabledVendorIds is not updated after user changes consent during showPreferences #41
Comments
A workaround is using getUserStatus ( EDIT: apparently this doesn't always work on iOS |
Workaround doesn't work on Android (a workaround for this is to call Didomi.reset before showPreferences, but then the user doesn't see its previous enabled/disabled cookies and you can dismiss the showPreferences without setting any preference) |
Hello Louis, Apologies for not replying earlier. The If what you need is to check if the user has enabled all Legitimate Interest and Consent purposes linked to vendors, then you might want to use The I hope this helps. Kind regards, Felipe |
Hello Felipe, Thanks for your answer. const handleConsents = async () => {
const userStatus = await Didomi.getUserStatus();
const enabledVendors = userStatus.vendors.global.enabled; // https://github.com/didomi/react-native/issues/41
// here I use enabledVendors to configure SDKs
};
export const useGDPRConsent = () => {
const [isConsenting, setIsConsenting] = useState(true);
useEffect(() => {
Didomi.onReady()
.then(async () => {
await Didomi.setupUI();
if (!(await Didomi.shouldConsentBeCollected())) {
await handleConsents();
setIsConsenting(false);
}
})
.catch(error => {
setIsConsenting(false);
handleError({
record: {
error,
context: 'Didomi ready',
},
});
});
Didomi.onError().then(error => {
setIsConsenting(false);
handleError({
record: {
error:
error instanceof Error
? error
: new Error(typeof error === 'string' ? error : JSON.stringify(error)),
context: 'Didomi initialization',
},
});
});
Didomi.addEventListener(DidomiEventType.CONSENT_CHANGED, async () => {
try {
await handleConsents();
} catch (error) {
handleError({
record: {
error,
context: 'Didomi consent change',
},
});
} finally {
setIsConsenting(false);
}
});
Didomi.initialize(env.DIDOMI_API_KEY);
return () => {
Didomi.removeAllEventListeners();
};
}, []);
return {
isConsenting,
};
}; And the on press callback on the button to manage cookies: const showCookieConsentSettings = useCallback(async () => {
await Didomi.reset(); // https://github.com/didomi/react-native/issues/41
return Didomi.showPreferences();
}, []); |
Hello, you are correct about the deprecated method, it seems we forgot to deprecate some of the status methods in typescript. This will be fixed in the next release. |
I reproduced it today too after having updated the SDK, on Android but not on iOS. (although this doesn't mean anything since it looks like a race condition) |
Step 1 : install a fresh app
Step 2 : accept all cookies => getEnabledVendorIds contains everything
Step 3 : showPreferences
Step 4 : refuse all cookies => getEnabledVendors still contains everything instead of nothing
Not tested on Android
The text was updated successfully, but these errors were encountered: