Safari Extensions

RSS for tag

Enhance and customize the web browsing experience on Mac, iPhone, and iPad with Safari Extensions

Posts under Safari Extensions tag

103 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

TestFlight is installing the incorrect version and build of the application.
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?
1
0
333
Mar ’24
Team Error encountered while publishing the Safari extension via Xcode
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
0
0
357
Mar ’24
Feasibility understanding
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?
0
0
277
Mar ’24
Safari App Extension: JavaScript script is responding to phantom messages
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.
1
0
397
Mar ’24
How secure is the communication between iOS app and its safari mobile extensions
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?
0
0
353
Mar ’24
Sending messages from the native app to the Safari web extension from a specific profile
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.
0
0
315
Feb ’24
Safari Web Extension - runtime.sendNativeMessage() failed with error 4099
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.
0
0
309
Feb ’24
How to take a screenshot of a tab
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.
1
0
334
Feb ’24
How to customize native modal for safari web extension in iOS?
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!
0
0
325
Feb ’24
TCC permissions for Safari App Extensions incorrectly displayed in Security & Privacy preferences
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?
0
0
351
Jan ’24
How to receive redirects in Safari extensions
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.
1
1
533
Feb ’24
Safari Web Extension allow external connection from any website
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!
1
1
389
Jan ’24
Safari Web Extension browser.tabs.captureVisibleTab() is not capturing the image correctly
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.
1
0
516
Jan ’24
Updating Safari content blocker from daemon
I'm building a Safari content blocker extension. The app is able to use SFContentBlockerManager.reloadContentBlocker to update the content blocker's JSON rules. However, I'm also trying to update the rules in the background through a daemon. The daemon app is embedded inside the main app, and is registered by the main app through SMAppService. The issue I'm running into is I can't get both the GUI app and the daemon to both update the content blocker: If I embed the Safari extension inside the main app and not the daemon, the main app is able to update the extension, but the daemon fails with an "operation couldn’t be completed" error (supposedly because it isn't the owner of the app) Alternatively, if I embed the extension inside the daemon, the main GUI app can no longer update the extension (also failing with "operation couldn't be completed" If I try to embed the extension inside both the main app and the daemon, it works fine when running from Xcode, but App Store Connect verification fails because it won't allow an bundle ID with two periods after the main app ID (e.g. the main app is com.example.App, the daemon is com.example.App.daemon, and the extension is com.example.App.daemon.extension) I'm wondering if I'm missing something here? Is there a way to get Safari to recognize both the main app and the daemon as "owners" of the extension? Thanks in advance!
2
1
401
Jan ’24