0

I have an HTML file in Safari App Extension bundle

enter image description here

I want to load this file in this method.

override func page(_ page: SFSafariPage, willNavigateTo url: URL?) {} 
Imran
  • 3,045
  • 2
  • 22
  • 33

1 Answers1

1

Please use this code

override func page(_ page: SFSafariPage, willNavigateTo url: URL?) {
       if (url?.absoluteString.hasPrefix("safari-extension://") ?? true) {
           return
       }
       DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(1000)) {
           page.getContainingTab { tab in

               SFSafariExtension.getBaseURI { baseURI in
                   guard let baseURI = baseURI else { return }
                   tab.navigate(to:baseURI.appendingPathComponent("testHTML.html"))
               }
           }
       }
   }
Imran
  • 3,045
  • 2
  • 22
  • 33
  • You should be using [[NSBundle bundleWithIdentifier:@"the.bundle.identifier.of.your.safari.app.exetension"] URLForResource:@"new-tab" withExtension:@"html"]; or the swift equivalent – I make my mark May 21 '20 at 07:10