Is your extension Web Extension format or Safari App Extension?
In the case of Web Extensions, ensure you have proper permissions in your manifest.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/create
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows (window api docs if you really want to open a new window)
Create a new tab with Web Extension:
browser.tabs.create({url: "https://www.apple.com"}, response => {
// ...
});
Create new tab with Safari App Extensions:
func openTab() {
guard let url = URL(string: "https://apple.com/") else { return }
SFSafariApplication.getActiveWindow { (window) in
window?.openTab(with: url, makeActiveIfPossible: true) { (tab) in
// ...
}
}
}
Topic:
Safari & Web
SubTopic:
General
Tags: