I am currently publishing an application that uses WebView,
I am currently publishing an application that uses WebView, but I am having trouble with data in LocalStorage sometimes disappearing.
The website displayed in WebView is made with PHP,
By writing the following code in JavaScript,
When WKWebView is opened, localStorage is saved and retrieved.
window.localStorage.setItem('isAlreadyAgree', true);
window.localStorage.getItem('isAlreadyAgree');
The problem is that sometimes this getItem does not get the data.
・This is not reproducible and does not always occur when some process is performed.
・Is it possible that the storage of the application is cleared due to distribution using MDM?
・Is it possible to store too much data in UserDefault, which would cause the LocalStorage space to be overwhelmed and disappear?
I would appreciate any hints you can give me.
Thank you in advance.
General
RSS for tagExplore the integration of web technologies within your app. Discuss building web-based apps, leveraging Safari functionalities, and integrating with web services.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
When I open com. apple. developer. web browser, I am unable to inject JavaScript into the webview through methods such as addUserScript. The console will prompt 'ignoring user script injection for non app bound domain'
Hi,
I was implementing Apple pay button by checking active wallet and at least one cards active.
I am using applePayCapabilities as per DOCS but i am still getting the same type of response with apple pay wallet enabled and without apple pay wallet enabled on different devices as
Loading the Apple Pay SDK:
script.src = "https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js";
script.crossOrigin = "anonymous";
document.head.appendChild(script);
script.onload = function() {
console.log("Apple Pay SDK loaded successfully");
// Initialize Apple Pay or perform actions that require the SDK here
};
script.onerror = function() {
console.error("Error loading Apple Pay SDK");
};
Calling applePayCapabilities method:
window.ApplePaySession.applePayCapabilities("merchant.com.example").then(r => console.log(r))
Output:
{paymentCredentialStatus: "paymentCredentialsAvailable"}
Image attachments of applePayCapabilities:
Devices Config Used:-
Chip - Apple M3 Pro
macOs - Sequoia 15.0.1
memory - 36 GB
Safari Version - 18.0.1
I am working Web to App flow for my product.
Tolink to my app from web service, I define uri scheme from app and use it from my web site.
But, when I try to use this scheme from mobile safari web, It sometimes failed with message that uri is invalid.
That is weird It failed SOMETIMES not always Even I tried with same url.
In my device, there is current version app.
Why this happen? How can I resolve this issue?
I'm making a Safari extension for learning languages. I need speech synthesis for any language the user chooses to learn.
I initially tried to make this work within JavaScript, but Safari 18 doesn't reliably list voices for all languages on the web SpeechSynthesis API as described here: https://stackoverflow.com/questions/79179072/how-do-you-use-a-japanese-voice-with-speechsynthesis-in-safari-ios-18
As a workaround, I've had to use AVSpeechSynthesizer in SafariWebExtensionHandler (NSExtensionRequestHandling implementation for the extension). This works in the simulator but not on a real device. I've found this note from Apple in a StackOverflow reply:
"Safari extensions are very short-lived, hence not fit for audio playback or speech synthesis. Not being able to validate an app extension in Xcode with a manually-added plist entry for background audio is the designed behavior. The general recommendation is to synthesize speech using JavaScript in conjunction with the Web Speech API."
Unfortunately, the suggestion to use the Web Speech API is unsuitable as I just explained.
Is there a way to set up a background process in the host app that can do speech synthesis? The app extension would need a way to communicate with this process, and start it if it's not running. Is that possible?
We are currently running a lightweight server within our iOS mobile app to pass a unique device ID via localhost for device-based restrictions. The setup works by binding a user's email to their device ID upon login, and later, when they attempt to log in via a browser, we retrieve this ID by making a request to http://localhost:8086/device-info.
However, we're encountering an issue when making this request. Here’s the error message:
Error fetching device info: TypeError { }
r@webkit-masked-url://hidden/:27:166011
value@webkit-masked-url://hidden/:27:182883
@webkit-masked-url://hidden/:27:184904
We are making this request from an HTTPS website, and we suspect this could be related to mixed-content restrictions. Could you guide us on how to properly make localhost requests over HTTPS, especially in a production environment with the necessary security measures?
Any insights or best practices on resolving this issue would be greatly appreciated.
The app analytics tab for my account is empty. It doesn't show any bundle IDs or apps that have been launched. Is this normal for WatchOS apps?
Here's a screenshot of the tab: https://cloud.goodsmile.studio/hT5fL2HY
Hi there,
I have a problem that , after I add website at dock but unable to turn on the website from dock & pop up message also mention that app was damaged. This problem appears after I factory reset my iMac. Please kindly advise. Thank guys.
Topic:
Safari & Web
SubTopic:
General
Tags:
Safari Developer Tools
Safari Services
Safari
Safari and Web
This screen time is ruining the battery and always goes to dead while I re open. Any idea how to resolve it?
How can i add Authorization header to a wkwebview. I checked https://developer.apple.com/documentation/foundation/nsurlrequest#1776617 which says Authorization header is a reserved http header and shouldn’t be set. I want to set it when requesting a url to the server which will be used for verification. How can i do that?
I have been using the following python library to generate apple map snapshots. has worked fine until about ~12 hours ago - now all I'm getting is "bad request" for any snapshot with overlays. if it's just a snapshot with a defined center and no polyline overlays, it still works. perhaps something has changed with the api's way of parsing percent encoded parameters? it's super irritating that there's no changelog or source code to view.
what the heck???
https://pypi.org/project/mapsnap/
I'm currently experimenting to add 3d stereo images in HEIC format to my daily Mars Rover Images website https://areo.info/mars20 which can be opened on a Vision Pro. Only a few images are yet converted into that mode, those on the sol 1411 page.
As I'm currently only working in the Vision Pro Simulator from Xcode, no real 3d effect if of course visible and I'm curious if anyone using the real hardware can confirm that the images are working.
Especially the eye distance correction is important to know about as the Mars Rover camera has a much wider pupil distance than humans and while I entered that distance in the conversion tool, I'm not sure if it worked well. So feedback is welcome!
For those who like to try to create stereo images themselves: I used https://developer.apple.com/documentation/ImageIO/writing-spatial-photos to create a HEIC file from two JPEGs.
Hello!
I have a question about changes in default behavior of Safari related to cookie setting.
We had an issue - our Single Sign On login was not working, because of lost cookie on some step of the flow. Only changes in Safari cross-website tracking settings helped to fix the issue
So the question is - are there any official documentation about changes in cookie setting policy in Safari on iOS 18?
I've a apple pay integration on my website. The new sdk, that allows third party browsers.
My integration works well everywhere, except on third party when I read the QR code it results in a "payment incomplete".
I have gone through several threads in apple dev forums, and several guides on implementation steps and troubleshooting. But I'm still without solution.
When Debugging in iOS device I get: "Application failed to provide a valid merchant session. We can't proceed to authorize the transaction."
I've doublechecked, the values I send to create the payment Session are correct, the domain and merchantIds. (It works well with the same implementation on safari, what's the difference here?)
I've also doublechecked the values i'm sending to the completeMerchantValidation, and they are all in the right format and types.
What else can iIcheck?
hi anybody have issue about pwa and webpush notification using FCM? with latest webpush and ios 17.x or 18.x 1-2 notification arrived but if iphone will be standby or webapp closed the service worker not receive notification
Topic:
Safari & Web
SubTopic:
General
I’m encountering an issue with CSS not displaying when using WKURLSchemeHandler to load local HTML files.
When I package the app using Xcode 15.3 or above, the CSS styles do not display on iOS 17 or higher. However, on iOS 16.7.1, the CSS displays correctly.
• If I use Xcode 15.2 to package the app, the CSS loads and displays correctly on all iOS versions.
I am using WKURLSchemeHandler to intercept and load the local HTML files. Is there any known issue or workaround for this?
You can now post this in the “Safari & Web” section of the Apple Developer forums for further assistance!
//
// CustomURLSchemeHandler.m
// HTMLTest
//
// Created by lvxue on 2024/9/23.
//
// CustomURLSchemeHandler.m
#import "CustomURLSchemeHandler.h"
@implementation CustomURLSchemeHandler
- (void)webView:(WKWebView *)webView startURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask {
NSURL *url = urlSchemeTask.request.URL;
//NSString *filePath;
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"LoaclHtml.bundle/A4"];
if ([url.lastPathComponent hasSuffix:@".css"]) {
filePath = [[NSBundle mainBundle] pathForResource:@"style" ofType:@"css" inDirectory:@"LoaclHtml.bundle/A4/css"];
} else if ([url.lastPathComponent hasSuffix:@".js"]) {
filePath = [[NSBundle mainBundle] pathForResource:@"yourJSFileName" ofType:@"js" inDirectory:@"LoaclHtml.bundle/A4/js"];
}
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
NSString *mimeType = [self mimeTypeForPath:filePath];
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:url
MIMEType:mimeType
expectedContentLength:htmlData.length
textEncodingName:@"utf-8"];
[urlSchemeTask didReceiveResponse:response];
[urlSchemeTask didReceiveData:htmlData];
[urlSchemeTask didFinish];
}
- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask {
}
- (NSString *)mimeTypeForPath:(NSString *)path {
NSString *fileExtension = [path pathExtension];
if ([fileExtension isEqualToString:@"html"]) {
return @"text/html";
} else if ([fileExtension isEqualToString:@"css"]) {
return @"text/css";
} else if ([fileExtension isEqualToString:@"js"]) {
return @"application/javascript";
} else if ([fileExtension isEqualToString:@"png"]) {
return @"image/png";
} else if ([fileExtension isEqualToString:@"jpg"] || [fileExtension isEqualToString:@"jpeg"]) {
return @"image/jpeg";
} else if ([fileExtension isEqualToString:@"gif"]) {
return @"image/gif";
}
return @"application/octet-stream";
}
@end
code-block
Topic:
Safari & Web
SubTopic:
General
Hello, Team.
We used WKWebView for our project. We loaded the HTML file into the webview and added the following configuration.
weak var webView: WKWebView!
func configWebView() {
let webViewConfig = WKWebViewConfiguration()
let controller = WKUserContentController()
controller.add(self, name: "sometest")
webViewConfig.userContentController = controller
webViewConfig.processPool = WKProcessPool()
webViewConfig.setValue(true, forKey: "allowUniversalAccessFromFileURLs")
webViewConfig.mediaTypesRequiringUserActionForPlayback = []
let webpagePreferences = WKWebpagePreferences()
webpagePreferences.allowsContentJavaScript = true
webViewConfig.defaultWebpagePreferences = webpagePreferences
webViewConfig.websiteDataStore = WKWebsiteDataStore.default()
webView = WKWebView(frame: .zero, configuration: webViewConfig)
webView.navigationDelegate = self
webView.uiDelegate = self
webView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(webView)
NSLayoutConstraint.activate([
webView.topAnchor.constraint(equalTo: view.topAnchor),
webView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
webView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
webView.trailingAnchor.constraint(equalTo: view.trailingAnchor)
])
loadWebView()
}
func loadWebView() {
guard let documentsDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else {
return
}
let contentFolderURL = documentsDirectoryURL.appendingPathComponent("content")
let assetFolderURL = contentFolderURL.appendingPathComponent(interactiveGUID)
if FileManager.default.fileExists(atPath: assetFolderURL.path) {
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!
let documentsURL = URL(fileURLWithPath: documentsPath)
let fileToLoadPath = (documentsPath as NSString).appendingPathComponent("content/index_p.html")
let fileURL = URL(fileURLWithPath: fileToLoadPath)
autoreleasepool {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.webView.loadFileURL(fileURL, allowingReadAccessTo: documentsURL)
}
}
}
We are experiencing webview crashes when loading an HTML file. What happened when I loaded the video file? It automatically looped. Webview frequently crashes when the HTM/JS file is loaded.
When a webview crashes, the delegate method usually calls webViewWebContentProcessDidTerminate. This method calls webview.reload().
Also we are clear and cache/ deallocate eveything when i initialized those configuration mentioned as the above.
Can you suggest a solution to this? Why is webview crashing?
Thank you.
We seem to be having an issue with a webservice here which is used within our network and IOS Safari. For the service to work , we need to access it with an unencrypted HTTP API call, which acts as a trigger. The server does not respond to HTTPS requests. (the HTTP API call does not contain any data that is privacy sensitive or that can be abused)
Since recently the service does not seem to work anymore properly, but this only happens with Safari and IOS. With all other browsers the service is still working normally, only with Safarai it fails.
No matter what I do in the settings of the phone, the Safar browser seems to stop immediately after the HTTP request. What is going on here ??
The issue seems to occur only when you don't have an iCloud+ account. With an iCloud+ account I get the same issue when you switch Apple Private Relay on, but that make sense. When I have Apple Private Relay switched off, there is no issue.
Topic:
Safari & Web
SubTopic:
General
When our Safari Web Extension makes a api request from its background script (registered via "scripts" in manifest.json, e.g., "background": { "scripts": ["js/background.bundle.js"] }) to our authenticated API endpoint (https://api-domain/user), the Cookie header is not included in the request. This occurs only when the extension is running within a non-default Safari User Profile. This causes our API to treat the user as unauthenticated. The exact same extension code, manifest, and API call work correctly (Cookie header is present and user is authenticated) when the extension is running in the Default Safari User Profile.
hi anybody can help me with webpush fcm? after some hours and pwa closed the webpush notification doesn't arrive until i re-open webapp and recreate a new token