Invalidate Security Scoped Bookmarks

35 views Asked by At

Is there a way to invalidate a Security Scoped Bookmark? What I mean is that a bookmark becomes invalid and the user has to re-allow access to the file or folder, even if the app has stored the bookmark. A new bookmark should be issued this way.

1

There are 1 answers

1
Klay On

The only way a bookmark can become invalid (in that the user needs to grant access to the URL again) is if resolving the bookmark via URL(resolvingBookmarkData:options:relativeTo:bookmarkDataIsStale:) throws, and you don't have access to the original URL where you could create a new bookmark via URL.bookmarkData(options:includingResourceValuesForKeys:relativeTo:).

To my knowledge, there is no way for a user to explicitly remove access to a bookmark. A bookmark may become stale (see the bookmarkDataIsStale parameter), in which you'll need to use the mentioned bookmarkData method to create a new bookmark from the returned URL (note: you don't need to resolve the bookmark again).