Skip to content Skip to sidebar Skip to footer

Safari Itp 2.0 Storage Access Api - Trouble Nesting Requeststorageaccess In Hasstorageaccess - Non Nested Works

I'm currently trying to implement calling the storage access API, but am having trouble nesting the call to requestStorageAccess in hasStorageAccess. Here is an outline of the code

Solution 1:

The problem here is that requestStorageAccess() requires user intent to be called. By nesting it in the hasStorageAccess() promise, that user intent (click) is obscured, and Safari rejects the request automatically.

To counteract this, I resolve hasStorageAccess on iframe load (since it does not require user intent), store this result in a class variable, and then if it resolved to false, I check requestStorageAccess on click.

Post a Comment for "Safari Itp 2.0 Storage Access Api - Trouble Nesting Requeststorageaccess In Hasstorageaccess - Non Nested Works"