swiftsafarisafari-app-extension

Check if tab/page is pinned in Safari App Extension


I am writing a Safari App Extension which gets all open tabs as urls. Later I want to open them. The problem I am facing is that I cannot find an API for checking if a tab (page) is pinned. This leads to the problem that opening all gathered urls also opens all pinned ones, which is not desired.

Is there a way to identify if a tab/page is pinned?


Solution

  • After a further research I managed to solve this. To answer the question directly - at the moment there is no API to ask if a tab/page is pinned. But there is a workaround to check this.

    There is a discussion here and another answer here which discuss that getContainingWindow(completionHandler:) of SFSafariTab will return nil if the tab is pinned, as technically the pinned tabs belong to all windows, and not a single window.

    Therefore, if tab is pinned, nil is returned for containing window.