Post not yet marked as solved
we need to play songs auto play but
const music = MusicKit.getInstance();
return undefined
try {
MusicKit.configure({
developerToken: DEVELOPER_TOKEN,
app: {
name: 'ReflexRadioDev',
build: '1978.4.1',
},
});
} catch (err) {
console.log("my : " + err);
}
// MusicKit instance is available
const music = MusicKit.getInstance();
console.log(music);
we use version 3 from apple music kit
"https://js-cdn.music.apple.com/musickit/v3/musickit.js"
browser console error :-
Uncaught (in promise) TypeError: music is undefined
https://dev2.api.app.reflex-radio.com/index.html:78
dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44
setTimeout handler*dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44
https://js-cdn.music.apple.com/musickit/v3/musickit.js:44
https://js-cdn.music.apple.com/musickit/v3/musickit.js:1
https://js-cdn.music.apple.com/musickit/v3/musickit.js:1
index.html:78:7
https://dev2.api.app.reflex-radio.com/index.html:185
dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44
(Async: setTimeout handler)
dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44
https://js-cdn.music.apple.com/musickit/v3/musickit.js:44
https://js-cdn.music.apple.com/musickit/v3/musickit.js:1
https://js-cdn.music.apple.com/musickit/v3/musickit.js:1
Post not yet marked as solved
Hello,
I have used WKWebview inside my tableview cell and given constraint inside my xib file.
I am loading html text in webview which i get from server side in api and i have taken webview height constraint property for update height on did finish delegate method.
It's not working proper and not giving proper height and on scroll every-time it's rendering with different height.
My requirement is i want to display math equations and html content on webview with dynamic height of cell.
I have done research and tried everything but it's not working.
I am using below code for update webview height.
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
webView.evaluateJavaScript("document.readyState", completionHandler: { (ready, error) in
if ready != nil {
DispatchQueue.main.asyncAfter(deadline: .now()) {
webView.evaluateJavaScript("document.body.scrollHeight") { [weak self] (result, _) in
guard let self = self, let result = result as? Double else { return }
self.webViewHeightConstraint.constant = CGFloat(result)
self.webView.updateConstraints()
}
}
}
})
}
Please help me to solve this issue.
Thank you
Post not yet marked as solved
Hi,
I'm trying to implement the async handler of WKScriptMessageHandlerWithReply -> see yellow box in this reference.
This is the method signature:
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) async -> (Any?, String?)
But I end up with a Segmentation fault: 11 compilation error.
I'm compiling with Xcode 13.4.1 (13F100).
Did anybody successfully use this API or now a solution to fix it?
Post not yet marked as solved
I am creating a react app and am making use of Webauthn to use TouchID or FaceID for user authentication.
I have built my app so that when the button is clicked, navigator.credentials.create is the only call made.
With attestation set to none, there are no issues however as soon as I set attestation to direct I get an alert saying 'The operation can't be completed' and 'NotAllowedError: This request has been cancelled by the user.' is logged to console.
The issue only presents itself on Safari and iOS devices however works perfectly on other browsers like Chrome.
Has anyone encountered a similar issue and possibly know how to resolve it?
Thanks
Shay
Post not yet marked as solved
When triggering a webkitRequestFullscreen event in response to a pointerdown event, the result is a fullscreen error.
Using a pointerup event instead of pointerdown works fine.
I'm using a <button> element to receive the event and in the event listener callback I'm attempting to call webkitRequestFullscreen() on a div.
Is this expected behavior?
note: this was observed using MacOS Simulator: iPad 9th Generation - iOS 15.4
Post not yet marked as solved
hello.
Switch the app to background when loading a webpage in webview,
webpage's JavaScript will stop working.
Resume the app webpage fails to load and the screen is not drawn.
Any solution?
Post not yet marked as solved
unload, pagehide event works in wkwebview. However, when i try to add beforeunload event listener, it won't get called in wkwebview.
Post not yet marked as solved
When I learned to use webview in my app, just added a webview and detected a memory leak,
import SwiftUI
import WebKit
struct SWKWebView: UIViewRepresentable {
@Binding var url: String?
func makeUIView(context: Context) -> WKWebView {
let webview = WKWebView()
webview.navigationDelegate = context.coordinator
return webview
}
func updateUIView(_ uiView: WKWebView, context: Context) {
if let url = url, let requetURL = URL(string: url) {
uiView.load(URLRequest(url: requetURL))
}
}
func makeCoordinator() -> Coordinator {
Coordinator()
}
class Coordinator: NSObject,WKNavigationDelegate {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
webView.evaluateJavaScript("document.title") { (result, error) in
print("didFinish:\(String(describing: result ?? ""))")
}
}
}
}
struct TTTest: View {
@State var url: String? = "https://www.google.com"
var body: some View {
SWKW

ebView(url: $url)
}
}
Post not yet marked as solved
I have the websocket server which enables permessage-deflate to compress massive data. The problem is when I try to use it in webview, the connection was closed.
I learned from other discussion that it can be solved by disabling Setting safari =>Advanced=>Experimental Features=>NSURLSession WebSocket, but only for Safari.
How can I solve the problem in WKWebview? Or when will the problem be solved?
Post not yet marked as solved
I have a web app it broken after las update ios release. The sound was played with Web audio context stop when the application change to run over background
Post not yet marked as solved
My app loads a webview using WKWebView class, so it uses safari to render the web content. However, the content is quite complex and Chrome does perform considerably better than Safari. So i wonder if would be possible to use Chrome engine in WKWebview, instead of Safari.
Post not yet marked as solved
Hi I would like to ask if the webassembly technology is supported by wkwebview or if there are particular limitations.
The second question is once an app has been developed where I have some sections inside that make use of web assembly modules, is it possible to publish them on the appstore or are there limitations?
thanks for the replies.
Post not yet marked as solved
In my app I use WKWebView and the user can go to different websites like google, wikipedia, vimeo, etc. The issue is if the user decides to go to https://www.youtube.com, when the user taps a thumbnail to play it, it doesn't autoplay because I don't have the videoId (eg. "https://youtu.be/MpvshzR6tNk"), I just have the the youtube website url
For example:
func loadRequest() {
let strThatUserEntered = "https://youtube.com"
let urlStr = "strThatUserEntered"
guard let url = URL(string: urlStr), let request = URLRequest(url: url) else { return }
wkWebView.load(request)
wkWebView.allowsBackForwardNavigationGestures = true
}
Now when the user selects a random thumbnail, the video loads, the youtube play button appears, and when it's pressed, I get: An error occurred, please try again later (this video definitely works)
How can I enable autoplay on any selected youtube thumbnail , if I don't have the videoID?
code:
override func viewDidLoad()
super.viewDidLoad()
let webConfiguration = WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback = true
webConfiguration.mediaTypesRequiringUserActionForPlayback = []
wkWebView = WKWebView(frame: .zero, configuration: webConfiguration)
wkWebView.navigationDelegate = self
wkWebView.uiDelegate = self
// pin wkWebView anchors to screen
loadRequest()
}
Post not yet marked as solved
My app has HTML pages for content, and I have a button-triggered action to change the size of the text by using a set of functions that stepwise increases the WebKit webview text by changing the class of the document body (i.e."smallestText" = CSS webkit-text-size-adjust:80%) using the code below as the last step.
On the iPhone simulator, this works perfectly but on the iPad simulator the text size does not change even though the functions are called, the javascriptString is correct, and the _webview contains the web content.
I thought this might be a doctype version issue (most of the pages are HTML 4.01 strict) but changed it to HTML5 (!DOCTYPE html) with no change.
Any ideas?
(void)refreshWebview {
NSString *javaScriptString = [NSString stringWithFormat:@"document.body.className = '%@'", self.fontSizeName];
[_webview evaluateJavaScript:javaScriptString completionHandler:nil];
}
Post not yet marked as solved
I have a mobile app which is uses Web authentication PublickKeyCredential api provided by WebKit to authenticate users and use oauth token from the response to login to the app.
Since iOS 15.4 released this following snippet is returning false
window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable
Please provide a workaround or let me know when this will get fix in WebKit
Post not yet marked as solved
Hi all,
Need help !!!!!!!!!!!
We have a desktop application which runs on OSX, but currently on Mac OS Monterey, the console UI part of the application is not showing up. It was showing up fine on MacOS Big Sur and earlier versions of OSX.
The console UI of the application is written using WebKit and JavaScript (jQuery), which internally makes use of NPAPI plugin to call native code from JavaScript. The WebKit tries to load the NPAPI plugin module, which is registered to the OSX and is placed under /Library/Internet Plug-Ins.
Until MacOS Big Sur, the application console UI was showing up since WebKit was able to load the registered plugin module successfully. Now on MacOS Monterey, the console UI is not showing up.
We are assuming that this issue is due to the fact that registered plugin loading by WebKit in MacOS Monterey is failing.
Can somebody please tell, if NPAPI plugins are deprecated from MacOS Monterey and is there any workaround for this issue ?
Post not yet marked as solved
I'm getting a "Storage Quota Exceeded" error when adding to the extension's sync storage area. getBytesInUse returns 88824, but trying to add {test: 'test'} gives the error. See attached screen shot.
Safari version is 15.1, macOS version is 12.0.1.
My available disk space is 523GB, so that's not the problem.
Post not yet marked as solved
I have a Safari App Extension that uses an instance of WkWebView to run JavaScript code. This app extension runs flawlessly with Safari 13 & 14, but Safari 15 occasionally kills the WkWebView instance for no apparent reason. The only thing logged to the console is this message:
(JavaScriptCore) Received an invalid message "<unknown message receiver>.<unknown message>" from the web process.
SafariExtension: (WebKit) [com.apple.WebKit:Process] 0x10c2e9300 - WebProcessProxy didClose (web process crash)
SafariExtension: (WebKit) [com.apple.WebKit:Process] 0x7ff1e7048020 - [pageProxyID=5, webPageID=6, PID=22131] WebPageProxy::processDidTerminate: (pid 22131), reason 3
I can't find any correlation between the JavaScript that's running and that error. The error seemingly occurs at random.
Has anyone else experienced such a problem?
Thanks
Post not yet marked as solved
The javascript code below fails when the xsl transformation passed to the importStylesheet contains xsl:include href= references. No exception is thrown and the transformToFragment function simply returns null. This works on all other browsers except Safari. For Safari all xsl:include href references must be manually resolved and inserted into the XSL transformation document prior to calling transformToFragment.
Is this a known bug? Is there a workaround aside from retrieving all xsl:include href manually?
//Opera, Firefox, Chrome, Safari ...
processor = new XSLTProcessor();
processor.importStylesheet(settings.xslDocument);
if(settings.param) {
for(var param = settings.param.length; param--;) {
processor.setParameter(null, settings.param[param].name,
settings.param[param].value);
}
}
transformedXML =
processor.transformToFragment(settings.xmlDocument, document);
Post not yet marked as solved
On the payment screen of my website, I executed the canMakePayments method to check if the user has an ApplePay-enabled device.
The process worked fine, but when I executed the window.webkit.messageHandlers.xxxx.postMessage method in JS to do the following, the process stopped.
window.webkit.messageHandlers.***.postMessage
is it not possible to use it when using ApplePayJS?
Or is there some problem such as a restriction on the JS window object?