I'm developing Safari App Extension for iOS 15.0+ and I need to get URL of active tab in popup.js and display.
Here is how I do that in popup.js:
document.getElementById("appresponse").innerHTML = safari.application.activeBrowserWindow.activeTab.url;
As result it returns nothing.
Also I tried
document.getElementById("appresponse").innerHTML = document.URL
but it returns path to current popup.js file.
Here is my permissions from manifest.json:
"permissions": ["nativeMessaging", "activeTab"]
And info.plist:
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>10</integer>
</dict>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.Safari.web-extension</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).SafariWebExtensionHandler</string>
</dict>