I'm trying to develop a Safari app extension and want to enable a persistent background page for it. I could find examples of how to enable it for Web extensions using manifest.json, but for App Extension it seems that I need to use Info.plist and I couldn't find any documentation on it. How can I use the background page?
Safari Extensions
RSS for tagEnhance and customize the web browsing experience on Mac, iPhone, and iPad with Safari Extensions
Posts under Safari Extensions tag
120 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I have created a new build for my Safari web extension and distrbuted it to test flight. Test Flight says I am using the correct version - but when I go to the Setting > Extensions in Safari and enable it - it still has the old version number.
App Store showing the correct version is in testing
Test Flight confirming said version number
Safari with the incorrect version
Any idea what I am doing wrong?
I've created a Safari extension using Xcode, and it works fine on my local system. However, when I try to deploy the extension, I encounter an error message stating "No team found in archive." I've already added the team while setting up the extension. Could someone please assist me in identifying what I might be doing incorrectly? Below are screenshots showing my configuration and the error message I'm encountering during deployment.
Following are the configuration screeshots
Following is the error screeshot
Hi,
I converted a chrome extension to safari extension and in order to pass review
I have to have a thorough description in the safari extension pane (which is within safari when you configure/setup the extension)
Do anybody know where I can change this description in xcode?
Tyler
I want to develop a safari extension for a study for a pet project website. I want to understand the challenges faced by the users while making searches on my e-commerce website. So the extension would basically trigger a survey when active on my website. If I were to understand what was searched on the website I would need to capture the url for the current page on they are on. Would this be possible? Would it comply with Apple regulation policies?
My Safari App Extension is having trouble with one website. This is typical for some other websites as well.
Navigating to that website results in 6 “Load” events. For each such event I send a “safari.extension.dispatchMessage” to my objC code.
For the first of these Load messages, my objC code sends a ‘sendMeIcons” message to “safari.self.addEventListener('message', function(event)”. The other 5 Load events are ignored by my objC code and do not send this message.
safari.self.addEventListener('message', function(event) receives sendMeIcons JUST once. Yet, the event handler for this message) is invoked 4 times. The first invocation is correct. The other 3 are spurious.
I have no idea why this is happening.
Here is my objC code
safari.self.addEventListener('message', function(event)
{
if (event.name === "Load My URL")
{
console.log('In event listener Load My URL');
...
return;
}
if (event.name === "sendMeIcons")
{
...
if (hrefs.length <1) //THIS IS ALWAYS TRUE FOR THIS TEST CASE.
{
safari.extension.dispatchMessage("js Found No Icons");
return;
}
else
{
...
safari.extension.dispatchMessage("IconsReturned",{"urls": arrayOfUrls});
return;
}
}
I don't have a clue how to proceed. Any suggestions.
Can someone share how secure is the communication between iOS app and its safari mobile extension. Is it encrypted? Are there any references to best practices to follow?
If a user has opened multiple tabs and has multiple extensions can there be security issues during their communication like one extension able to read other extensions memory?
The SFSafariViewController documentation mentions not to display content from websites when using the pageSheet and formSheet presentation styles for the In-App browser.
Is this a hard restriction that is enforced or more of a loose guideline? And if possible, providing the reasoning behind it would be great.
Thanks in advance.
As far as I can determine, there is no way to save the data in my Safari App Extension when Safari terminates. It seems I have to save the data every time the page changes. That's wasteful. Does anyone know of a work around?
Is there any way to configure SFSafariApplication.dispatchMessage to send a message to the web extension from a specific profile?
According to the documentation , using SFExtensionProfileKey, the native app can determine the profile that sent a message.
Can SFSafariApplication.dispatchMessage send a message to a specific profile? The default behavior seems to be to send the message to all profiles.
Hey,
I am developing Safari Web Extension and trying to communicate with the swift handler (SafariWebExtensionHandler) using runtime.sendNativeMessage api (as describe here - https://developer.apple.com/documentation/safariservices/safari_web_extensions/messaging_between_the_app_and_javascript_in_a_safari_web_extension). I'm getting the following error when calling it -
calling runtime.sendNativeMessage(): Error Domain=NSCocoaErrorDomain Code=4099 "Couldn’t communicate with a helper application."
I have no Idea what is missing and couldn't find any meaningful error message anywhere. I do have nativeMessaging permission in my manifest.json. Assist will be appreciated.
I recently noticed that using Google Docs, Google Sheets, and any other Google-related sites on a Safari browser uses tons of RAM. It usually consumes around 4-5 GB of RAM.
Compare it to when I use Google Docs on Chrome; it only uses around 1-2 GB.
Why is this so? I want to use Safari alone for work, but it's so slow. Do you have any tips on this?
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.
We're seeing a delay of between 50mS to 150mS when just sending a short "ping-pong" message between 'inject.js -> extension code (swift) -> inject.js'
what might be wrong?
are there any ways to get a more reasonable IPC communication channel between the javascript and swift side. I would like to achive <= 1mS delay roundtrip.
I've successfully built a Safari extension for my app, but I've noticed that some applications have a slightly different style when opening the native modal through the "aA" button (I'm not referring to the injected cloned modal, but the "native" one).
There are two major differences I observed: the first is the header color, which is gray instead of the regular white, and the second is that this modal doesn't open in full screen when dragged to the top, unlike the regular one. I'm interested in knowing how they achieved this. I couldn’t find any information about it anywhere on the web/docs. Thanks!
Hi,
We provide a Safari App Extension to our customers. It follows the standard Safari Extension App layout - the Extension is inside the App, the App takes care of installing the Extension in Safari. The Extension requires the Input Monitoring and Screen Recording permissions to be granted from the user. At some point during its execution, the Extension runs the code that triggers the TCC permission prompt. When the user goes to Security & Privacy Preferences dialog and clicks on the checkbox next to the Extension entry to grant the permission, the checkbox remains unchecked, however, the permissions are actually granted. This is the issue, and it is confusing for the user. Moreover, if the user decides not to grant the permissions (closes the initial prompt by clicking on the 'Deny' button) s/he will be prompted again when the Extension runs the next time (and every time).
The App that contains the Extension does not suffer the same problem. Its entry in Security & Privacy Preferences responds correctly to checking/unchecking the checkbox. Unfortunately, the permissions granted to the app do not apply to the Extension contained within.
Querying the main TCC database (/Library/Application Support/com.apple.TCC/TCC.db) shows one kTCCServiceListenEvent entry for the app, identified by its BundleID (permissions granted). For the Extension there are two entries - one identified by the the BundleID (permissions granted) and the other identified by the path to the Extension (permissions not granted).
kTCCServiceListenEvent|/Volumes/Common/Sandboxes/Monterey/AppExtPermissons/DerivedData/AppExtPermissons/Build/Products/Debug/AppExtPermissons.app/Contents/PlugIns/AppExtPermissons Extension.appex|1|0
kTCCServiceListenEvent|com.gemalto.AppExtPermissons|0|2
kTCCServiceListenEvent|com.gemalto.AppExtPermissons.Extension|0|2
The system logs show some tccd-related errors when trying to check the checkbox:
Console logs when trying to grant permissions
We suspect this might be the reason why the checkbox next to the Extension entry under Input Monitoring in Security & Privacy does not respond to clicks. The same problem applies to granting Screen Recording permissions to the Extension.
I constructed a minimal example based on the default Safari App Extension project - basically only added code that would trigger the permission granting prompt in the App and the Extension. Can provide a link to a zip if deemed useful.
Are we doing something wrong, maybe missing an ID or a plist string somewhere?
I am developing a safari extension
When a redirect occurs on a web page, I want to detect the redirect and obtain all redirect URLs.
If there is any way, please let me know
Below is what I tried
manifest version is 3
1, Use webNabvigation in background.js
browser.webNavigation.onBeforeNavigate.addListener(function(details) {
console.log("Redirected to:", details.url);
});
This works, but I couldn't get the expected URL
2, Use webRequest in background.js
This resulted in an error as it was not possible to listen to events in a non-persistent background.
This is caused by using manifest version 3.
Hey! We are developing a Safari Web Extension which requires the background script for localhost Web Socket communication (it doesn't work if we try to connect from the injected content script), everything works fine but we need it to be accessible from any URL since we have a SDK that is distributed to the customers and the domain name depends on each of them, is there a way to do this? Or is there any workaround to not have to use browser.runtime.connect or browser.runtime.sendMessage for communication between the injected content script and the background script? We have tried to use <all_urls> but that's not allowed for externally_connectable. Thanks!
On Safari Mobile and iOS version 16 or 17, while scrolling the webpage, the function browser.tabs.captureVisibleTab() is not returning the expected screen image.
The image is cropped from the top.
The probable reason for the same is the collapsible Address Bar.
The below attached image is the iPad mini (6th generation ) Simulator OS Version:17.0 simulator
The below attached image is created by browser.tabs.captureVisibleTab()
I tested it on
iPad mini (6th generation ) Simulator OS Version:17.0 and
iPad (8th generation) - iPadOS Version 16.2.
Hey,
Is it possible to automatic install AppStore extension on Mac clients without interaction from the user?
We have a lot of users who don't have an Apple ID. And as we have quite a lot of freelancers and temporary workers we mostly have users without an Apple ID and find it not making sense for these users to create an ID.
Any ideas?
Thanks.