6

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.

Rizwan Yaqub
  • 102
  • 4
  • Please add and explain what you tried so far and where you got stuck. Give us a [verifiable and complete example](https://www.stackoverflow.com/help/mvce) and please avoid posting again before reading and understanding [HOW TO ASK](https://stackoverflow.com/help/how-to-ask) a good question. – Simo Sep 17 '18 at 11:00

2 Answers2

1

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

RawiSader
  • 21
  • 7
0

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...

Emmanuel Sellier
  • 526
  • 1
  • 5
  • 13