Post not yet marked as solved
With a Safari extension I add a link to certain websites to open the Maps app with coordinates found on the website.
In the content script I detect clicks on my added link and forward the message to the background script with browser.runtime.sendMessage({ coordinates: "some coordinates I found on the website" }).
The background script receives this message in its listener function and forwards the message to the extension handler like so
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
browser.runtime.sendNativeMessage( { message: request.coordinates }, function(response) {
});
}
The extension handler receives the message in its func beginRequest(with context: NSExtensionContext) function as expected.
In this function I convert the coordinates I receive to a valid CLLocationCoordinate2D object.
However, if I want to use the following code inside the beginRequest function to open the Maps app, it does not work on iOS. The same code works fine with a macOS Safari extension.
MKMapItem(placemark: MKPlacemark(coordinate: CLLocationCoordinate2D(latitude: 50.1234, longitude: 8.1234))).openInMaps()
Post not yet marked as solved
Safari version : 15.3
Os version : 12.2.1
This is after latest updates and manifest v3 is not supported. So i need to downgrade manifest version to 2.
What can be the solution to run manifest v3 with current mac and safari version?
Also, My safari is not getting updated after updating os, Im using intel processor. What can be done to update safari version to 15.4?
Post not yet marked as solved
I was tracking down an infinite loop and it's caused by calling:
browser.i18n.getMessage('faq_4a', ['$13.99'])
Where the "faq_4a" is defined as:
"faq_4a": {
"message": "Highlight all prices like $1"
},
The problem is the parameter ['$13.99'], if I use this parameter for any message that accepts a placeholder, it will just froze the console or whatever executed it.
Can someone please try to run this code to verify?
I need to know if this is a Safari issue or if just my Safari broken. I use Safari 15.3 (17612.4.9.1.8).
Thank you!
Post not yet marked as solved
I learned there are two types of safari extensions . Web extensions and app extensions . We are currently developing a safari web extension . The extension requires access on all web sites by default (without user granting permissions) . But there is no provision for same in web extension . However the same can be achieved in app extension by including safari website access in info.plist . Please clarify why there is no provision to achieve the same in web extension . However same is provided in app extension .
Post not yet marked as solved
new Worker(browser.runtime.getURL('source/worker.js'))
throws an error:
Error: This script should only be loaded in a browser extension.
I have a hefty background processing operation that I need to pass off to a web worker, but the script I try to execute causes this error.
Is there a standard way of spawning a web worker in a background script for a safari web extension?
Post not yet marked as solved
Can I use string entered in _locale / en / messages.json in the popup.js script file?
Post not yet marked as solved
I have implement reset text function in content.js file with static array. I need to manage this array with dynamic.
I have pass data app to extension with FileManager.
I have get store data in extension safariwebextension.swift. file.
How can use this array in content.js file. Need to replace store data in content.js file.
Your provided demo only supported mac version feature.
Post not yet marked as solved
My Safari Extension on iOS needs access to a Keychain item (password) that is secured by the userPresence and devicePasscode flag. In other words, FaceID/TouchID or the device PIN is necessary to access the password.
Is there a way for the extension to access the password?
SafariWebExtensionHandler.swift has access to the Keychain, but can't present FaceID/TouchID/device PIN interface to the user. Popup.js has UI access, but can't access the iOS Keychain.
One hack is to set touchIDAuthenticationAllowableReuseDuration of the Keychain item to an arbitrary time and have the user authenticate in the containing app.
However, in case of a time-out, the containing app has be opened by the extension with a custom URL scheme. openURL is not accessible in SafariWebExtensionHandler.swift either (I assume it can be handled by popup.js). This is a user-unfriendly solution. What is the best way to give the Safari extension access to a Keychain item?
Post not yet marked as solved
Hi there,
my iOS web extension for Safari, written in Xcode works fine in simulator but on a physical device the extension doesn't show in the extension area on phone.
When launched, the app spashscreen comes up, but the extension is not show in the extension are of the browser. Same on IPhone 13 simulator works without any prob.
What can I do?
Post not yet marked as solved
I have a problem with safari, the problem started on my iPhone 7 that some of experimental webkit features was changed so that many things stopped of working on safari and I bought new iPhone pro 13 and moved the data from the old device to the new and discovered the the problem became on my two devices now.
Post not yet marked as solved
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("activetaburl").innerHTML = document.URL
As result it returns path of current popup.js
Here is my permissions from manifest.json:
"permissions": ["nativeMessaging", "activeTab"]
And info.plist:
<dict>
<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>
</dict>
So how to fix the issue above and get url of active tab?
Thanks,
Serge
Post not yet marked as solved
I would like to call
navigator.mediaDevices.getUserMedia({ audio: true, video: true }).then(() => {...});
in my background.js.
But It will neither resolve nor reject.
I try to run it in console of background.js, but only get
Promise {status: "pending"} = $1
Post not yet marked as solved
Hello,
Is it possible to take a screenshot of a non-active tab? Firefox supports this via captureTab (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/captureTab)
With Safari App extensions that was possible via getScreenshotOfVisibleArea which doesn't seem to work with Safari extensions.
Post not yet marked as solved
I have converted my chrome extension to Safari and followed all the instructions:
here is my manifest:
{
"manifest_version": 2,
"default_locale": "en",
"name": "__MSG_extName__",
"version": "1.0",
"homepage_url": "https://mydomain.com/",
"description": "__MSG_appDesc__",
"icons": {
"16": "images/16.png",
"32": "images/32.png",
"48": "images/48.png",
"128": "images/128.png"
},
"background": {
"scripts": [ "background.js"],
"persistent": false
},
"permissions": ["storage", "tabs", "contextMenus", "nativeMessaging", "<all_urls>"],
"browser_action" : {
"default_icon" : "images/_48.png",
"default_title" : "MyAppName v0.0.1" ,
"default_popup" : "popup.html"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["js/content.js"],
}
]
}
I've removed everything from background.js and left the below lines for troubleshooting:
var bkg = chrome.extension.getBackgroundPage();
bkg.console.log("test1");
console.log("test2");
But I see no output. The same works for Safari macOS.
I'd like to know if background.js would ever work in iOS?
if yes, what do I need to do to get it working?
Post not yet marked as solved
Hello,
With iOS 15, we can now convert WEB extensions into APP extensions.
But does all the functionnalities available in a WEB extension are still available when I convert it to an APP extension ?
For example on MacOS, with a WEB extension, if I select a word or a sentence in Safari, I can display a button next to the text, that will allow me to launch an action.
Will I be able to do the same with an iOS app extension ? (ie: display my own button when the user select a word or a sentence while browsing Safari on his phone)
Thank you in advance for your help.
Patrick
Post not yet marked as solved
If someone installs the iOS extension and hasn't enabled it in safari settings, I want to alert/remind them to enable it when they open my website on Safari. So, if the user opens my website, can it detect that the iOS extension if it is already installed?
One of the solutions I tried is to set a cookie or modify content on my website from iOS extension, but without enabling the iOS extension, it is not possible.
Any help would be highly appreciated, thanks for your time!
Post not yet marked as solved
How well does Safari iOS15 support web apps. Does the A2HS icon of the progressive WEB APP function offline with no internet. This feature was broken in iOS 14.7. Doug D
Post not yet marked as solved
Hi!
We're currently building a web extension with iOS as a primary target.
Since haptics on iOS are really nice, we wanted to make use of it to give the experience a special feel on iPhone.
However, haptics don't seem to work when called from SafariWebExtensionHandler... maybe because the messaging layer between the web extension and the native code is in the background (is it?), and haptics don't work in apps that are in the background.
Anyway, is there any way we can make haptics work regardless?
Post not yet marked as solved
Are Safari extensions for iPad OS 15 available yet and if so, how do I get them?
Post not yet marked as solved
Feedback Assistant case: FB9545798
Installation and running
git clone git@github.com:birchill/10ten-ja-reader.git
cd 10ten-ja-reader
yarn install
npm run build:safari
Now open "xcode13/10ten Japanese Reader.xcodeproj".
For all four build targets, change the developer team to your own developer team.
Run the build target named "10ten Japanese Reader Extension (iOS)" on a real device (mine is an iPhone 11 Pro), selecting the app "Safari" to run the extension for.
Next, on your iPhone, go into Settings > General > Safari > Extensions and allow the extension named "10ten Japanese Reader".
Return to iOS Safari, refresh the current tab (if you want a consistent URL to test on, then let's choose https://ncode.syosetu.com/n4830bu/130/), and check the Share sheet.
Expected results
A Web Extension named "10ten Japanese Reader" or similar should appear in the Safari Share menu. You should be able to enable it, and something that looks like a hockey puck will immediately appear in the bottom-right of the web page.
Actual results
Although I was able to run this Web Extension just fine on iOS 15 beta 5, since updating to iOS 15 beta 6 (and the corresponding latest macOS and Xcode betas available at the time of writing), I have been unable to run the Web Extension. That is to say, it does not appear in the Share menu, even though it appears in Settings > General > Safari > Extensions and is allowed.
I have tried restarting both my Mac and my iPhone, and incrementing the build number, doing clean builds, etc., but nothing has helped.
I see no debug in Xcode that gives any clues, either.