6
votes

I'm developing a safari app extension. I've to listen to "beforeNavigate" event as in old Safari JS Extensions, we could listen to these events using Safari's Windows & Tabs API.

I went through the How to create Safari App Extension, but unfortunately couldn't find anything related to these events there.

Can anybody please help me with similar APIs for Safari App Extensions as we had in old Safari JS Extensions.

2
Please add and explain what you tried so far and where you got stuck. Give us a verifiable and complete example and please avoid posting again before reading and understanding HOW TO ASK a good question.Simo

2 Answers

1
votes

Starting Safari 13, Apple added an API for page navigation notifications.

In your SafariExtensionHandler.swift, you can now override func page(_ page: SFSafariPage, willNavigateTo url: URL?).

Source: https://developer.apple.com/documentation/safari_release_notes/safari_13_release_notes

0
votes

Unfortunately, there is not equivalent in Safari App Extension. The only thing you can do is catching a new tab id displayed through validateToolbarItem.

Or try to add a content or network filter in your App...