Yes as far I have seen the way to grant request access to storage api is to ask for user gesture in iframe, but even I am unable to get the pop-up as well as when initating user gesture and calling the requeststorageaccess() fn through the button click in iframe , its still denying the storage access to third party cookies.
this https://webkit.org/blog/8124/introducing-storage-access-api/ article suggest to use iframe for requesting storage access if doesn't have access.
I have tried it in this way but its not working , if someone could help .... the third party cookie is shown as expired in safari , so in order to request storage access for it we needed user gesture in iframe
<script>
function onLoginClicked() {
document.requestStorageAccess().then(() => {
console.log('Access granted: Safe to access storage now');
settingCookie();
}).catch(e => {
console.log("access denied")
});
}
function settingCookie() {
document.cookie = "lastname=kumar";
console.log(document.cookie);
}
if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) {
document.addEventListener("DOMContentLoaded", () => {
document.hasStorageAccess().then(access => {
if (access) {
console.log('has access');
settingCookie();
} else {
console.log('no access')
}
});
});
}
else {
console.log('not safari browser')
}