Explore the integration of web technologies within your app. Discuss building web-based apps, leveraging Safari functionalities, and integrating with web services.

All subtopics

Post

Replies

Boosts

Views

Activity

Safari Extension doesn't load after running Product > Archive
I've been developing a Safari web extension for MacOS and iOS, and I'm running into a very strange issue. I ported over my Chrome extension to Safari, and for several days as I was iterating on the extension (change code, build, run, test in Safari), everything worked perfectly fine. Once I was finished with the extension, I followed the instructions on how to prepare to submit the Safari web extension (and it's containing MacOS and iOS apps) to the App Store for review. For the MacOS app and Safari web extension on Mac, I changed my target from "My Mac" (which I'd been using for testing), to "Any Mac". I then went to the "Product" menu in Xcode and selected "Archive" That's when things started to go wrong. The next time I went to Safari, my web extension could no longer find critical files to run the extension (such as background.js, popup.html, etc.) This was despite there being no code changes before or after me creating a build archive. When I restarted Safari, the extension no longer appeared in the list of extensions within preferences. No matter what I do (clean build folder and re-run, restart Safari, restart Xcode, restart computer), nothing will get my extension to show up in Safari again. Note that this does not happen with the Safari web extension in the iOS simulator. It only happens on Mac. I was confident that my extension was working, so I submitted my extension to the Mac App Store for review. It was approved, and a few users have downloaded it and it works totally fine. To further try to figure out what's going on, I created a new sample Xcode project. From the new project screen, I chose the "Safari web extension" under "Multiplatform". Without making any code changes, I build and run that project, and the default MacOS app and Safari web extension from the template. I then immediately create an archive (with no code changes). Once I try to run the project for my Mac again, the extension no longer works. So I have verified that this problem does not have to do with my extension's code, but I cannot for the life of me figure out what is wrong. I have examined every possible build setting, but given that I ran a default project template, made no changes, and it still had this problem, I'm not sure what else could be wrong.
2
0
280
Jan ’25
Universal Link Failures in Safari
We encountered an issue with universal links where the link failed to open the iOS application from Safari when triggered by an javascript outside a click event. However, when we modified the code to open the link directly via a user click, the application launched as expected. Based on our testing, this issue seems to occur only when there is information for the application cached in Safari (i.e. IDP page cached, redirects to our app, javascript based universal link navigation fails). Here is a code example of what caused the universal link failure: const openUniversalLink = () => { buttonClicked = True } useEffect(()=> { if (buttonClicked) { window.location.href = universal_link } } <Button onClick={openUniversalLink} /> Here is a code example of what caused our universal links to open successfully: const openUniversalLink = () => { window.location.href = universal_link } <Button onClick={openUniversalLink} /> Are there defined practices of when we are able to open universal links triggered by javascript vs when they must be opened directly through user action?
1
1
241
Jan ’25
Universal Link failures in Safari with EventListener
Hi everyone! We encountered an issue with universal links where the link failed to open the iOS application from Safari when triggered by an event listener. However, when we modified the code to open the link directly via a user click, the application launched as expected. Based on our testing, this issue seems to occur only when there is information for the application cached in Safari. Our previous flow that resulted in the broken universal link included: Data is loaded and a screen with a button to open the universal link is available for the user When the data is loaded it sets a state variable to true for DataLoaded The user clicks on the button to open the universal link When the user clicks the button to open the link it sets a variable to true for ButtonClicked When DataLoaded and ButtonClicked are true then the universal link is opened Our new flow that results in the successful universal link includes: Data is loaded and the user is hit with a loading screen until it is finished The user clicks on the button to open the universal link and the universal link is opened directly Does anyone have insights into why universal links must be triggered by direct user action, and in what scenarios this behavior is enforced?
1
0
162
Jan ’25
Angular/Cordova application not responding to touch events
We have a Angular/Cordova application which is internal and is deployed on 10th gen iPad's currently. After updating the iOS version to 18.2 (current patch 18.2.1) the touch events on buttons and other views forms such as div are not firing the desired typescript methods. We are getting the touch events on the screen with relevant script which uses eventListner for debugging the touchevent but it doesn't fire at relevant methods at times. "click" can be replaced with "touchend "and "submit". document.addEventListener('click', (event) => { handleGlobalEvent(event, 'click'); });
1
0
193
Jan ’25
Authorizing Apple Pay via non-Safari browser fails to decode merchant session.
When attempting to authorize an Apple Payment on an iOS 18 device using the scannable code in a non-Safari browser (i.e. Chrome), the payment sheet displays briefly, then dismisses. This same exact implementation of Apple Pay on the Web works flawlessly in Safari, so this feels like a bug given that the merchant session works fine in Safari. The following errors were found in my iOS device logs: (PassbookUIService) Codable: Failed to decode Merchant Session Created: Error Domain=NSCocoaErrorDomain Code=4864 UserInfo={NSDebugDescription=<private>, NSCodingPath=<private>} (PassbookUIService) Session 29592: Fatal Error: Failed to decode merchant session created`
4
1
351
Jan ’25
Issue with Safari v18.2: Extension Prevents Video Playback When Inspecting
I am a developer working on a Safari extension that handles video playback, and I’ve encountered an issue with Safari version 18.2. When I open the developer tools to inspect the browser, videos fail to play as expected. It worked well on safari version 18.1. Details: Safari Version: 18.2 Operating System: macOS Sequoia v15.2 Additional Information: I’ve tested the extension with various video formats and sites. Clearing the cache and disabling other extensions did not resolve the issue. There are no error messages displayed in the console related to the extension. If I close inspecting, then extension(video playback) works well. I would appreciate any insights or suggestions on how to address this issue, as it impacts the functionality of my extension. Thank you for your help!
2
0
313
Jan ’25
Can't use Clipboard API after sending a message to the background script?
Hi, I’m encountering an unexpected issue in Safari. Specifically, navigator.clipboard.writeText() fails when called from a content script in my extension immediately after sending a message to background.js while it works fine in Chrome and Firefox. Is this expected? Environment Safari 18.2 (20620.1.16.11.8) Technology Preview 210 macOS Sequoia 15.2 (24C101) Example This is a minimal reproducible example, which adds a button to example.com: https://github.com/mshibanami/ClipboarAPIIssueExample Below is the related code: // content.js copyButton.addEventListener('click', async () => { // 👇️ This call seems to trigger the issue await chrome.runtime.sendMessage({}); try { await navigator.clipboard.writeText(text); alert(`✅ Copied '${text}' to clipboard!`); } catch (err) { alert(err + '\n\n' + `navigator.userActivation.isActive: ${navigator.userActivation.isActive}`); } }); // background.js chrome.runtime.onMessage.addListener(() => { }); When I click the button, I expect the text to be copied successfully. However, I receive an error in Safari.: Interestingly, if I remove chrome.runtime.sendMessage(), the clipboard operation works without any problems. Also, note that navigator.userActivation.isActive is true, which might mean it's not related to the User Activation API. Misc. This might be related to another question I posted here: https://developer.apple.com/forums/thread/772275
0
0
251
Jan ’25
Service Worker isn't working in Internal iframe: WebView file://
Is it a specification that the Service Worker doesn’t work in an internal iframe only when the parent page in a WebView is file://? It works in Mobile Safari under the same conditions, and we couldn’t find any specification that says Service Worker-like behavior doesn’t work with this combination. Step to reproduce: We use Vite to develop the application. For the iframe in Webview, Install vite-plugin-pwa with version ^0.20.5 Add VitePWA({...}) to plugins[] array in vite.config.ts Build and preview the app: npm run build && npm run preview. We open a Webview with file:// and then open the iframe with the URL to which we preview the app (We use ngrok to create the URL). Then we open Safari and inspect the Webview but inside the Developer > Service workers tab doesn’t have a registered service worker. For safari, we do the same step 1-3, We open Safari browser with the URL that we have deployed the app (The same URL we used in the iframe in Webview). We go inside the Developer > Service workers tab and it has a registered service worker. Environment: Simulator: IOS 18.2 Safari: MacOS 15.2 Expectation: Safari and the iframe in Webview should have a registered service worker inside the Developer > Service workers.
0
0
247
Jan ’25
Subscription permission denied on webapp push
HI, please can someone help? I have a web app where push notifications are in place for Chrome, Firefox, and Edge. Providing the user allows notifications then when they log in for the first time their details are registered to the subscriptions table in the backend. All good so far. When trying to do the same with Safari on Mac I'm faced with this issue: "Safari doesn’t support invisible push notifications. Present push notifications to the user immediately after your service worker receives them. If you don’t, Safari revokes the push notification permission for your site." and the user is not registered in the subscription table with the Safari console just saying variations of this: [Warning] Notification permission denied. (notifications_frontend.js, line 177, x2) [Log] Enable Notifications button clicked (notifications_frontend.js, line 245) [Log] Safari Push Notifications detected (notifications_frontend.js, line 248) [Warning] Safari Push Permission denied. (notifications_frontend.js, line 278) I've found this on an another forrum: "Safari requires that you immediately post a notification when a push message is received. "Immediately" means that it cannot be after some async operation. If you display a notification immediately from the service worker itself, it will stop displaying that error. I cannot remember 100% but I think if you clear your cache and cookies you will be able to receive push messages again if you accidentally get blocked while testing." and I've tried adding buttons to trigger allowing notifications but it all seem to late to get the subscription registered in the subscription table. I'm pretty new to coding so if any has a similar experience and can advice how to get the subscriptions registered when the user logs on for the first time in Safari in a Mac it would be greatly appreciated. Thanks...
0
0
220
Jan ’25
Clipboard API `writeText()` fails in Safari due to User Activation API, but works in Firefox and Chrome
Hi, I'm encountering an issue with the Clipboard API's writeText() method in Safari. It throws a NotAllowedError even when triggered by a user action (selecting an option from a <select> element). Is this expected? This issue seems specific to Safari, as the same code works perfectly in Firefox and Chrome. Perhaps I should send feedback to Apple, but I'd like to post it here first in case I misunderstand something. Problem In Safari, when I try to copy text to the clipboard using navigator.clipboard.writeText() within an input event listener attached to a <select> element, it fails with the following error: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission. Environment Safari 18.2 (20620.1.16.11.8) Technology Preview 210 macOS Sequoia 15.2 (24C101) Example I've created a minimal reproducible example on CodePen: https://codepen.io/mshibanami/pen/LEPdxXZ Here's the relevant JavaScript code from the example: selectElement.addEventListener('input', async (event) => { const selectedText = event.target.options[event.target.selectedIndex].text; try { await navigator.clipboard.writeText(selectedText); alert(`Text copied to clipboard: ${selectedText}`); } catch (err) { alert('Failed to copy text to clipboard: ' + err); } }); Firefox and Chrome handle this code without any issues, successfully copying the text to the clipboard, but not Safari. Possible Cause I suspect this issue might be related to WebKit's User Activation API. It seems like Safari is not correctly recognizing the input or change event on a <select> element as a valid user activation for the Clipboard API, even though it is initiated by a user gesture. Questions Is this behavior unexpected? Should Safari allow the Clipboard API to work in this context? (Technically, this might be expected as of now, as such events are not explicitly described in https://webkit.org/blog/13862/the-user-activation-api/.) Any insights or suggestions would be greatly appreciated. Thanks!
1
2
380
Jan ’25
Security - How to secure communication between app and safari extension
Hello. We are adding a Safari extension to our app and we have some questions about communication between the app and its extension. We have added the nativeMessaging permission to the extension so that it can communicate with the app and communication between both are doing very well. Our question is about the security of communications between the two. How can we be sure the native app communicates well with the correct extension? Can the Safari extension communicate with another native app or can the native app receive messages from another extension?
0
0
248
Jan ’25
How to set UserAgent on Safari web driver of selenium
Python version 3.9.1 Selenium version 4.25.0 Safari version 18.1.1 I want to operate Safari using Selenium. For this purpose, I would like to set the UserAgent to iOS and change the viewport. What should I do? The following is the content programmed with the Chrome driver. I would like to achieve this using the Safari driver. import time,os import chromedriver_binary from selenium import webdriver from selenium.webdriver import Safari from selenium.webdriver.safari.options import Options as SafariOptions from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.select import Select from selenium.webdriver.chrome import service # selenium 4 from selenium.webdriver.chrome.service import Service as ChromeService from selenium.webdriver.chrome.options import Options from webdriver_manager.chrome import ChromeDriverManager driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()),options = chrome_options) # iPhone 13 params viewport = { "width": 390, "height": 844, "deviceScaleFactor": 3, "mobile": True } #Chrome setting ua = "Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1" driver.execute_cdp_cmd("Emulation.setDeviceMetricsOverride", viewport) # change user agent driver.execute_cdp_cmd("Emulation.setUserAgentOverride", {"userAgent": ua}) # ページにアクセス driver.get("https://hogehoge")
0
0
199
Jan ’25
iOS 18 not able to clear the app safari browser cookie from local store cookie
We are getting the cookie from server side when user will do the login successful. Cookie store into app browser. This cookie need to clear when user will do the logout app. We are using the Cordova framework to create the iOS application. In Cordova i have used plugin to clear the cookie. But in iOS device not able to clear the app browser cookie. And in android device same Cordova plugin is working fine. Why the iOS device not able to clear the cookie using Cordova plugin? Plugin name - https://github.com/Cartegraph/cordova-cookie-master Kindly help me out with the solutions.
1
0
238
Jan ’25
MacのSafariをseleniumからiosのユーザーエージェントで起動したい
タイトルの通り,seleniumからsafariを起動して操作したいのですが,ユーザーエージェントの変更ができずにおります. ご存知の方は解決方法をご教示いただけますと幸いです. 以下はChromeで操作するためのコードですが,これと同等のことをSafariで行いたいです. 特にUserAgentとviewportの設定についてご教示いただけますと幸いです. import time,os import chromedriver_binary from selenium import webdriver from selenium.webdriver import Safari from selenium.webdriver.safari.options import Options as SafariOptions from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.select import Select from selenium.webdriver.chrome import service # selenium 4 from selenium.webdriver.chrome.service import Service as ChromeService from selenium.webdriver.chrome.options import Options from webdriver_manager.chrome import ChromeDriverManager #WEBブラウザの起動 chrome_options = Options() #chrome_options.add_argument("--headless") #chrome_options.add_argument("--disable-gpu") #chrome_options.add_argument("--no-sandbox") driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()),options = chrome_options) viewport = { "width": 390, "height": 844, "deviceScaleFactor": 3, "mobile": True } #Chromeの時の設定 ua = "Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1" driver.execute_cdp_cmd("Emulation.setDeviceMetricsOverride", viewport) # ユーザエージェントの変更 driver.execute_cdp_cmd("Emulation.setUserAgentOverride", {"userAgent": ua}) # ページにアクセス driver.get("https://...") #具体的なURLは省略
0
0
154
Jan ’25