session.onvalidatemerchant = function(event) {
const validationURL = event.validationURL;
console.log("Validation URL:", validationURL);
document.getElementById('methodapplepay').value = "validate";
document.getElementById('validationURL').value = validationURL;
$.ajax({
url: 'ajax/processInternalDonate.php',
type: 'POST',
data: $("#payment_form").serialize(),
success: function(dataValidate) {
dataValidate = JSON.parse(dataValidate);
session.completeMerchantValidation(dataValidate);
},
error: function(xhr, status, error) {
console.error('Merchant validation failed:', error);
session.abort();
}
});
};
session.onpaymentauthorized = function(event) {
var payment = event.payment;
$.ajax({
url: 'ajax/processInternalDonate.php',
type: 'POST',
data: {pay_mode:"pay_mode",method:"process_payment",payment:JSON.stringify(payment)},
success: function(dataprocess) {
if (dataprocess.success) {
session.completePayment(ApplePaySession.STATUS_SUCCESS);
} else {
session.completePayment(ApplePaySession.STATUS_FAILURE);
}
},
error: function(xhr, status, error) {
console.error('Payment processing failed:', error);
session.completePayment(ApplePaySession.STATUS_FAILURE);
}
});
};
from this above two session methods for the first method I got the merchant validation response from the API calling from that method but for the session.onpaymentauthorized when the second API is calling then I got the message payment not processed on my apple pay popup upon autorisation from my phone so I want that you provide me the correct backend flow for this API calling so we get the amount charged and I also got the payment object from event.object on logging in my console.
Explore the integration of web technologies within your app. Discuss building web-based apps, leveraging Safari functionalities, and integrating with web services.
Post
Replies
Boosts
Views
Activity
As shown in the image, after the 18.1 update, the “Preview” pane in network requests disappeared. I can only view the response by right-clicking and selecting “Reveal in Sources tab”.
BEFORE:
AFTER:
Hey,
when I try to run my project on an iOS Simulator, I get the following message:
JournalingSuggestions is not available when building for iOS Simulator.
and
Linker command failed with exit code 1 (use -v to see invocation)
Steps to reproduce this behavior:
Create a new Xcode project
Add the Journaling Suggestions Capability
Add the Journaling Suggestions Framework
Under "Target > Build Phases > Link Binary with Libraries", select “optional“ for JournalingSuggestions.framework
Under "Target > Build Settings > Other Linker Flags > Debug" select „Plus“ and add „iOS or iOS Simulator“ and paste this -Xlinker -weak_framework -Xlinker JournalingSuggestions into the editable field.
Do the same for "Target > Build Settings > Other Linker Flags > Release"
This tread is about the same problem, but is already checked as answered.
That's why I'm creating this new tread.
The last two bullet points are results from advice from the other thread.
MacBook Air, M1, 2020, macOS: 14.6.1, Xcode: 16.0
Thanks for your help!
Got the wrong keywords, trying to create a new thread...
Since probably the late iOS 17.4.x, 17.5.1 and still now in 17.6 beta our extension has been experiencing issues with the accompanying background script or service worker being permanently killed with no warning after about 30-45 seconds after initial installation (installation, not page load!).
In all other browsers (including Safari on MacOS) unloading the service worker is part of the normal lifecycle to save memory and CPU if it is idle. In our extension the service worker is used only during the first 5-10 seconds of every page visit, so we are used to seeing it unload after that and consider this a good thing. However, normally, the service worker is able to wake back up when needed - which is no longer the case in iOS.
Once dead, nothing a normal user would do can wake the service worker back up:
No events like webNavigation or similar will trigger anymore
Any attempt to call sendMessage to it from a content-script also does not wake up the service worker and instead returns undefined to the content script immediately
Closing and opening Safari does not start it again
The only two things that will give the service worker another 30-40 seconds of life is a reboot of the device or disabling and then re-enabling the extension. During those few second the extension is working perfectly.
There are no errors or indications in the logs of what is going on and the extension works just fine in Chrome, Firefox, Edge as well as Safari on MacOS and Safari in the Mobile simulator. Only actual iOS devices fail.
It seems like a temporary workaround is to change the manifest to not load the service worker as a service worker by changing
"background": {
"service_worker": "service.js"
}
to
"background": {
"scripts": ["service.js"],
"persistent": false
}
With this change (courtesy of https://forums.developer.apple.com/forums/thread/721222) the service worker is still unloaded but correctly starts up again when needed. Having to make this change does not seem to be consistent with manifest v3 specs though (see this part in Chrome’s migration guide as an example: https://developer.chrome.com/docs/extensions/develop/migrate/to-service-workers#update-bg-field).
According to the release notes of 17.6 beta this bug was supposedly fixed:
“Fixed an issue where Safari Web Extension background pages would stop responding after about 30 seconds. (127681420)”
However, this bug is not fixed - or at least not entirely fixed. It seems to work better for super simple tests doing nothing but pinging the service worker from the content script, but for the full blown extension there is no difference at all between 17.5.1 and 17.6.
Has there been a change in policy about service workers and background scripts for Safari in iOS?
Are anyone else seeing this issue?
Also seemingly related:
https://forums.developer.apple.com/forums/thread/756309
https://forums.developer.apple.com/forums/thread/750330
https://developer.apple.com/forums/thread/757926
https://forums.developer.apple.com/forums/thread/735307
We are encountering an issue where the Safari extension we are developing stops working while in use on relatively new iOS versions (confirmed on 17.5.1, 17.6.1, and 18). Upon checking the Safari console, the content script is displayed in the extension script, so the background script or Service Worker must be stopping. The time until it stops is about 1 minute on 17.5.1 and about one day on 17.6.1 or 18.
When it stops, we would like to find a way to restart the Service Worker from the extension side, but we have not found a method to do so yet. To restart the extension, the user needs to turn off the corresponding extension in the iPhone settings and then turn it back on.
As mentioned in the following thread, it is written that the above bug was fixed in 17.6, but we recognize that it has not been fixed. https://forums.developer.apple.com/forums/thread/758346
On 17.5.1, adding the following process to the background script prevents it from stopping for about the same time as on 17.6 and above.
// Will be passed into runtime.onConnect for processes that are listening for the connection event
const INTERNAL_STAYALIVE_PORT = "port.connect";
// Try wake up every 9S
const INTERVAL_WAKE_UP = 9000;
// Alive port
var alivePort = null;
// Call the function at SW(service worker) start
StayAlive();
async function StayAlive() {
var wakeup = setInterval(() => {
if (alivePort == null) {
alivePort = browser.runtime.connect({ name: INTERNAL_STAYALIVE_PORT });
alivePort.onDisconnect.addListener((p) => {
alivePort = null;
});
}
if (alivePort) {
alivePort.postMessage({ content: "ping" });
}
}, INTERVAL_WAKE_UP);
}
Additionally, we considered methods to revive the Service Worker when it stops, which are listed below. None of the methods listed below resolved the issue.
①
Implemented a process to create a connection again if the return value of sendMessage is null. The determination of whether the Service Worker has stopped is made by sending a message from the content script to the background script and checking whether the message return value is null as follows.
sendMessageToBackground.js
let infoFromBackground = await browser.runtime.sendMessage(sendParam);
if (!infoFromBackground) {
// If infoFromBackground is null, Service Worker should have stopped.
browser.runtime.connect({name: 'reconnect'}); // ← reconnection process
// Sending message again
infoFromBackground = await browser.runtime.sendMessage(sendParam);
}
return infoFromBackground.message;
Background script
browser.runtime.onConnect.addListener((port) => {
if (port.name !== 'reconnect') return;
port.onMessage.addListener(async (request, sender, sendResponse) => {
sendResponse({
response: "response form background",
message: "reconnect.",
});
});
②
Verified whether the service worker could be restarted by regenerating Background.js and content.js.
sendMessageToBackground.js
export async function sendMessageToBackground(sendParam) {
let infoFromBackground = await browser.runtime.sendMessage(sendParam);
if (!infoFromBackground) {
executeContentScript(); // ← executeScript
infoFromBackground = await browser.runtime.sendMessage(sendParam);
}
return infoFromBackground.message;
}
async function executeContentScript() {
browser.webNavigation.onDOMContentLoaded.addListener((details) => {
browser.scripting.executeScript({
target: { tabId: details.tabId },
files: ["./content.js"]
});
});
}
However, browser.webNavigation.onDOMContentLoaded.addListener was not executed due to the following error.
@webkit-masked-url://hidden/:2:58295
@webkit-masked-url://hidden/:2:58539
@webkit-masked-url://hidden/:2:58539
③
Verify that ServiceWorker restarts by updating ContentScripts
async function updateContentScripts() {
try {
const scripts = await browser.scripting.getRegisteredContentScripts();
const scriptIds = scripts.map(script => script.id);
await browser.scripting.updateContentScripts(scriptIds);//update content
} catch (e) {
await errorLogger(e.stack);
}
}
However, scripting.getRegisteredContentScripts was not executed due to the same error as in 2.
@webkit-masked-url://hidden/:2:58359
@webkit-masked-url://hidden/:2:58456
@webkit-masked-url://hidden/:2:58456
@webkit-masked-url://hidden/:2:58549
@webkit-masked-url://hidden/:2:58549
These are the methods we have considered. If anyone knows a solution, please let us know.
Safari cannot open the page due to the error 'WebKit encountered an internal error.' We are using https://github.com/stleamist/BetterSafariView.git, and it was working fine before we updated to Xcode 16.
Hi everyone,
I’m working on an app that uses WKWebView. Due to security concerns, our customers want the app to disable copy-paste functionality and similar options (such as Lookup and Share, allowing users to extract text from the app or save it as a file.
I was able to disable copy-paste and remove UIMenu options like Lookup and Share.
Everything worked fine until the iOS 18.1 beta, which introduced a new menu called Writing Tools (Apple Intelligence) that has its own copy and share buttons
I've tried several ways to remove it
Remove all UIMenu items using canPerformAction, and it works for all menus but Writing Tools, which still remains
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return false
}
Remove it from UIMenuBuilder
override func buildMenu(with builder: UIMenuBuilder) {
builder.remove(menu: .lookup)
builder.remove(menu: .share)
}
But unfortunately, UIMenuBuilder does not have an identifier for Writing Tools, and it seems like there are no API changes from Xcode 15 to Xcode 16 (https://developer.apple.com/documentation/uikit/uimenu/identifier)
It seems like the only way to disable it through MDM configuration (key: allowWritingTools), but we don't use MDM
https://developer.apple.com/documentation/devicemanagement/restrictions
Environment
iOS Version: iOS 18.1 beta4
Device: iPhone 15 Pro
App platform: iOS
Xcode version: 16.0
MacOS: 15.0
Thank you
This screen time is ruining the battery and always goes to dead while I re open. Any idea how to resolve it?
We currently are using private web security certificates for our URLs. Our users download, install, and enable a Root Certificate on their devices to reach our website (trusted). The web security certificates have expirations that are less than 13 months from expiration.
Since the deployment of iOS 18, our users are now getting a "This Connection is not Private" warning in the web browser on both Mac and iOS devices.
What change was implemented in iOS 18 that is causing this issue? Other than changing our web security certificates to Public ones, what solutions should be implemented to prevent this from occurring?
I'm working on a school project to build a webpage for Vision Pro users. I'm using Xcode to build this webpage because it has .reality files. This webpage only works on Safari because I took a spatial image with my Vision Pro, and it's .heic file type.
I put the .png version below the .heic file that is supposed to have the spatial effect. I deployed this project on Vercel, please use Safari to check out the link: https://spatial-design-project.vercel.app
There's another issue in this project, I downloaded the Cosmonaut .reality file on Apple Quick Look Gallery to test on my webpage. However, when I open it on Vision Pro, the file won't load, it says "Failed to load layers". Does it have something to do with the server for serving this file type? Should I use an actual web hosting company for this website?
Here is my GitHub repo
<div class="hero">
<div class="hero-text">
<h1>La Sal Peak</h1>
<p>The Do-It-All Enduro Bike</p>
</div>
</div>
<div class="hero2">
<div class="hero-text">
<h1>La Sal Peak</h1>
<p>The Do-It-All Enduro Bike</p>
</div>
</div>
.hero {
position: relative;
display: flex;
align-items: flex-end;
justify-content: flex-start;
height: 100vh;
background: url("assets/heroImage.heic") no-repeat center center/cover;
color: white;
}
.hero2 {
position: relative;
display: flex;
align-items: flex-end;
justify-content: flex-start;
height: 100vh;
background: url("assets/hero.png") no-repeat center center/cover;
color: white;
}
Hi, we developed a web app based on the iPhone Safari browser and would like to apply to see if it is possible to use JavaScript capabilities to prevent the iPhone system from taking screenshots of web pages.
Hi, We developed a web app based on the iPhone Safari browser, and we would like to ask if it's possible to use JavaScript to prevent the iPhone's screenshot function from capturing screenshots of the web page?
We are trying to retrieve merchant tokens from ApplePay. We used the javascript codes from Apple Pay demo site to request for a recurring payment from the frontend.
"recurringPaymentRequest": {
"paymentDescription": "A description of the recurring payment to display to the user in the payment sheet.",
"regularBilling": {
"label": "Recurring",
"amount": "4.99",
"paymentTiming": "recurring",
"recurringPaymentStartDate": "2023-08-11T11:20:32.369Z"
},
"trialBilling": {
"label": "7 Day Trial",
"amount": "0.00",
"paymentTiming": "recurring",
"recurringPaymentEndDate": "2023-08-11T11:20:32.369Z"
},
"billingAgreement": "A localized billing agreement displayed to the user in the payment sheet prior to the payment authorization.",
"managementURL": "https://applepaydemo.apple.com",
"tokenNotificationURL": "https://applepaydemo.apple.com"
}
Payment was successful, but merchantTokenIdentifier is not shown in the in decrypted ApplePay token, regardless of test card used. We tried Visa and MasterCard.
I have a macOS safari web extension and It can read the cookies of my website, but when I fully close safari and open it again the extension can't read the cookies anymore. When I try to inspect the cause in the console (safari > develop > web extension background content) everything starts to work again.
My safari version is 18.1 (19619.2.8.111.1, 19619)
Hello everyone,
in my website I need to give users the ability to choose a color via input type=“color”.
I don't understand why it works fine on desktop (even on Safari for Mac) but doesn't open the color picker on iPhone.
How can I solve this?
Thank you,
Andrea
So I know I can request for an email in the paymentRequest requiredShippingContactFields and could also access minimal information with onshippingcontactselected, but how can I actually get the full shippingContact AFTER a transaction. The documentation doesn't say what API call this is returned with or anything, so please help!
Relevant doc: https://developer.apple.com/documentation/apple_pay_on_the_web/applepaypayment/1916097-shippingcontact
In Safari Web Extensions on iOS 18, declarativeNetRequest Rulesets and Dynamic Rules take over twice as long to apply -- which causes rulesets to often fail to apply before sites load. In a boilerplate Xcode project you can note the time difference toggling the OISD (https://oisd.nl) ruleset on iOS 17 and iOS 18 simulators. Additionally, if you force quit Safari and reopen to a site with ads blocked by OISD list (e.g. espn.com) the content will be blocked in that initial state on iOS 17, but not in iOS 18 due to the latency.
Based on the boilerplate extension, this bug is impacting all Mobile Safari Extensions using declarativeNetRequest Rulesets and Dynamic Rules. We know several other extension developers dealing with this issue.
Our team wrote detailed reproduction steps in our Feedback Assistant ticket: https://feedbackassistant.apple.com/feedback/15196130 but have received no responses. I would attach a screen recording here but it won't allow me.
I'm building a share extension for my app when I noticed something weird.
When I open a mobile URL (URLs with "m." like m.randomsite.org) on iOS using a browser (I'm using Safari & Chrome) and then try to share it, what will be share is the URL without the "m." (i.e. randomsite.org)
This messes up with my app since I'm not getting the real URL that I'm viewing using the browser.
I don't think it has something to do with my app since even selecting "Copy" when sharing will result in the altered URL too.
So far this is happening on both iOS 17 and 18. Does someone know whether this is a bug from iOS or not? I don't think this is a Safari bug since I noticed the same thing on Chrome as well
I've observed a discrepancy in cookie consent options between iOS 18.0 and 18.1 on some websites, such as www2.hm.com. On iOS 18.0, I see "Accept All Cookies" and "Only Required Cookies" options, whereas on iOS 18.1, the options change to "Accept All Cookies" and "Cookie Settings."
I would like to understand if this behavior is related to differences in how websites detect the operating system version (iOS 18.0 vs. 18.1) or browser changes within the iOS update. Has anyone else experienced similar variations in cookie consent banners, and could this be tied to differences in the user agent or website A/B testing for different OS versions?
Any insights or technical clarifications would be appreciated!
Hello everyone,
I am currently facing an issue with a Cordova-based app using WKWebView. In our app, we handle page navigation within the WebView. We’ve implemented a back button at the top of the page, which successfully triggers history.goBack() when clicked. However, we also want to support the native left edge pan gesture (swipe back) to trigger history.back().
The issue is that, while the swipe back gesture works most of the time, there are cases where instead of navigating to the immediate previous page, it behaves as if it’s going back to the first page (or initial page). This only occurs on iOS versions 17.5.1 and above. I’ve already set allowsBackForwardNavigationGestures to true, and the back button itself works perfectly.
Has anyone experienced a similar issue, where the swipe back gesture sometimes skips pages and seems to return to the first page on iOS 17.5.1 or later? Any suggestions on how to fix or troubleshoot this would be greatly appreciated.
Thank you!