JavaScript

RSS for tag

Discuss the JavaScript programing language.

Posts under JavaScript tag

200 Posts

Post

Replies

Boosts

Views

Activity

Detect a SFSafariViewController vs Safari Browser with Javascript
Hello! We are looking for a way to detect if the user is in a SFSafariViewController or Safari Browser using Javascript. I was hoping for something in the window object, but there's nothing. I know some people have used window.innerHeight to do this for iOS versions up to iOS 14... but this does not work for iOS 15 & 16. And the only thing I could find on any forums are people saying that it cannot be done. I'm hoping that we could get a developer from Apple working on this ASAP, as we need to be able to do this.
1
3
1.1k
Oct ’22
On-Hold Wifi Login Feature
I have noticed when trying to configure a Wifi login via QR code (html/js) that although iOS prompts the user to 'Join Network', it fails to actually join the network. If testing the same QR via the camera, it approves the login. I'm sure this was working in the iOS 15 beta and stopped working at public release, and hasn't worked in iOS16 either. Has anybody else encountered this? Is this a known issue, or a bug? or am i missing something? Thanks
0
0
689
Sep ’22
Microphone is disabled when trying to record (using getUserMedia)
I built a simple recorder on my website for users to record and playback audio. It works on ALL desktop browsers (including Safari) but when I use any browser on my iPhone, the mic is active at the opposite time. The flow is: ask permission > user allows mic access > user presses record > records audio > saves and plays back On iPhone what's happening is after the user allows permission, the mic goes active (visualized by the mic icon in safari browser) and then once the user presses record, it disables the mic. I am using getUserMedia within a React.js app Why is it doing this?
1
0
1.5k
Sep ’22
Unable to use ALL cookies from webpage in my background script - [Safari App Extension]
Hi All. I am building a safari app extension which needs to make several HTTP requests from the background script. The HTTP requests need to use the Cookies that exist on my webpage. When I make the requests from my background script, I see 3 of my 4 cookies are added to the request cookie header, but the 4th cookie is not there. The 4th cookie has SameSite=Lax which seems to be the issue. When I manually change Lax to none, in my webpage's cookie storage, then the request goes through successfully from my background script. Does anyone know if there is a way to get/use cookies labeled as SameSite=Lax in my background script? I tried the broswer.cookies API, but it seems that the API will only retrieve non HttpOnly cookies, and my cookie has HttpOnly enabled as well, so this does not work. How can I make requests from my background script that need to use cookies from my webpage? P.S. This works in my chrome extension just fine, but it seems Safari has some restrictions Thanks in Advance :)
3
1
2k
Sep ’22
is there's a bug with evaluateJavaScript with WKWebView ?
I've created a simple projet, the purpose is to load a javascript webpage (https://www.myidtravel.com) and to programatically click a button. Basically I'm able to do all this stuff but not the click, the wkwebview is unchanged after the call of evaluateJavaScript (the completion Handler is ok with no error) With Safari or Chrome and the developer tools the click is working correctly: document.getElementById('button-1029').click(); I'm pretty new with JavaScript and I'm curious to see if it's a bug, or a bad implementation... Bellow you will see my implementation: import UIKit import WebKit class ViewController: UIViewController , WKNavigationDelegate{ var webView : WKWebView! override func loadView() { webView = WKWebView() webView.navigationDelegate = self view = webView } override func viewDidLoad() { super.viewDidLoad() let url = URL(string: "https://www.myidtravel.com/")! webView.load(URLRequest(url: url)) webView.customUserAgent = "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36" } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } //MARK:- WKNavigationDelegate func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { print(error.localizedDescription) } func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { print("Strat to load") } func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { print("finish to load") DispatchQueue.main.asyncAfter(deadline: .now() + 4) { webView.evaluateJavaScript("document.getElementById('button-1029').click();", completionHandler: { (value, err) in print(">>>>>>>>>>>>>>>>>>>> click click") if let error = err { print("Error click") print(error.localizedDescription) } }) } } }
1
1
2.5k
Sep ’22
Safari low performance on special js web content.
When view some special web content with js, as mentioned below(with right corner on "Continue",which showed in Chinese, you can refer the arrow, let it auto scroll will show the problem). Cause P-core to increase to more 100% cpu usage. The page is test under windows; under chrome on same OS environments, no problem. But on safari 15.6(macOS 12.5, m1 Mac mini), 16beta and tech preview always have the same issue. https://www.baidu.com/s?rsv_idx=1&wd=%E9%87%8D%E5%BA%86%E5%9F%8E%E5%8F%A3%E5%8E%BF%E5%9F%8E%E4%BE%9B%E6%B0%B4%E6%B0%B4%E6%BA%90%E4%BB%85%E5%A4%9F%E6%94%AF%E6%92%91%E5%8D%81%E5%A4%A9&fenlei=256&ie=utf-8&rsv_pq=c3e520bf0006d8d0&oq=%E5%9B%9B%E5%B7%9D%E5%B0%8F%E4%BC%99%E9%AB%98%E6%B8%A9%E5%A4%A9%E5%8D%96%E5%86%B0%E5%9D%97%E6%97%A5%E5%85%A5%E8%BF%87%E4%B8%87&rsv_t=1b91DUeCY7TbON4DYyf9mO8Ujl1zg9wmPQ0O%2BRUbRNO%2F3g42IBRjUsYmELE&rqid=c3e520bf0006d8d0&rsf=526d5fb04211f1d3aefdb673067d9d32_1_15_7&rsv_dl=0_right_fyb_pchot_20811&sa=0_right_fyb_pchot_20811
2
0
825
Sep ’22
401 Error after 20 Minutes
I´ve build an app that gets metrics (amount of downloads) from Appstore Connect, every time a website is opened (this will happen every hour when own build endpoint /metrics is opened). Everything is working, except one thing. The Token has an max duration of 20 Minutes. Which is no problem because my app is creating a new one every time the site is called. But I get an 401 Error not authorized, even though a new token is generated after 20 minutes when the app is running and is calling for data again. I am assuming the app is using the old token to verify and ends up in a loop. how to force the app to use the new token when the function is called again (/metrics is opened) instead of the old token?
3
0
1.7k
Sep ’22
Not working https call on Capacitor Nuxtjs App using axios under Xcode 13.4.1 on Monterey 12.5.1
Hi. I have one issue on my ios app. (connecting carers) All login and signup work on android and web app correctly well. And firebase login by email, google and apple work correctly well on ios app. But signup by email, google and apple doesn't work only on ios app First it creates new account from firebase. It works well. After that, when the user add new account in wordpress database, it calls wp api endpoints by https methods(get, post) using axios to create new account in wordpress database. But when we create new account in wp database via wp api by https call on ios app, it doesn't work only on ios app It works on web and android app well. I attached the screenshots here. Could you tell me what is the issue and why happended it? How can I fix the issue so that it can call the https by axios on ios app?
0
0
733
Aug ’22
Call Swift functions from JS
I have a VIewController with WKWebView to display HTML content to my users. What I need is to get some information from my project side(swift codes) such as app version, data reports to javascrtript side. On the side of js, I'll be able to generate html codes or display elements based on swift function calls. Here are some codes in my ViewController: class AboutViewController: UIViewController { @IBOutlet weak var webView: WKWebView! { didSet { setJS() } } private let jsCtx = JSContext() private func setJS() { let obj = MyVersionClass() jsCtx.ctx.setObject(             obj,             forKeyedSubscript: "versionObj") } override func viewDidLoad() {         super.viewDidLoad() // build url webView.loadFileURL(             url,             allowingReadAccessTo: url) let request = URLRequest(url: url)         webView.load(request) } MyVersionClass is defined as: import JavaScriptCore @objc protocol JSAppVersionProtocol: JSExport {     func getAppVersion() -> String     static func createObj() -> MyVersionClass } class MyVersionClass: NSObject, JSAppVersionProtocol {     static func createObj() -> MyVersionClass {         let obj = MyVersionClass()         return obj     }     func getAppVersion() -> String {        ...     } } The class AboutViewController will load an html file with js defined in script section <head> <script type="text/javascript" src="../version.js"></script> </head> <body onload="updateVersion()"> ... <span id="appVersion">To be updated with my app version      </span> .... JS code: function updateVersion() {     let e = document.getElementById("appVersion");     var ver =versionObj.getAppVersion(); // another try, see following codes // var ver =versionObj.createObj().getAppVersion();     e.innerHTML = ver; } I tested the js function call in my AbountViewController class right after I setObject like this: let result = jsCtx.evaluateScript("versionObj") print("\(result)" I got the result in console like this: <MyApp.JSAppVersion: 0x282aa0af0> I also tried to setObject like this: jsCtx.ctx.setObject(             MyVersionClass.self,             forKeyedSubscript: "versionType") // My test of script function let result = jsCtx.evaluateScript("versionType") print("\(result)" // result is <MyApp.MyVersionClass> However, it seems that my js does not know what my swift function code is. It fails to get the app version. Not sure what is missing or wrong? How can I set up mu swift function available in js side?
2
0
4.6k
Aug ’22
On the ios i see this player video when i scan the qr-code
var addDrawsight = $parameters.DrawSight; ZXing.TemplateBuilder.buildInterface(addDrawsight, document.getElementById($parameters.Canvas_WidgetId)); codeReader = new ZXing.BrowserMultiFormatReader(); /* document.getElementById('close-button').addEventListener('click', function() {     codeReader.reset();     document.getElementById('plugin-overlay').style.display = 'none';     document.getElementById('video').pause();     $parameters.ErrorMessage = "Failure during scan. Scan was cancelled";     $parameters.Success = false; }, true); */ var menuBackHandler = function() {     codeReader.reset();     document.getElementById('plugin-overlay').style.display = 'none';     document.getElementById('video').pause();    // $parameters.ErrorMessage = "Failure during scan. Scan was cancelled";    // $parameters.Success = true;     $parameters.IsBack = true;     history.back(); }; $public.Navigation.registerBackNavigationHandler(menuBackHandler); var selectedDeviceId = null; if(codeReader !== null){     if(!codeReader.canEnumerateDevices){                 var divOverlay = document.getElementById('plugin-overlay');         var video = document.getElementById('video');         if (divOverlay !== null && video !== null) {             video.parentNode.removeChild(video);             divOverlay.parentNode.removeChild(divOverlay);         }                 var input = document.createElement("input");         input.id = 'image-input'         input.type = "file";         input.accept = "image/* capture='camera'";         input.style.display = 'none';         document.body.appendChild(input);         var outImg = document.createElement("img");         outImg.id = 'outImage';         //outImg.style.display = 'none';         outImg.style.width = '320';         outImg.style.height = '320';         var cont = document.getElementById('reactContainer');         cont.appendChild(outImg);         input.click();         input.addEventListener("change", function (evt) {             var tgt = evt.target || window.event.srcElement,                 files = tgt.files;             // FileReader support             if (FileReader && files && files.length) {                 var fr = new FileReader();                 fr.onload = function () {                     var outImg = document.getElementById('outImage');                     outImg.src = fr.result;                     codeReader.decodeFromImageElement('outImage')                     .then(function (result) {                         $parameters.Value = result.text;                         $parameters.Success = true;                         $resolve();                     })                     .catch(function (err) {                         $parameters.ErrorMessage = "Could not find a barcode. Please try with a different image";                         $parameters.Success = false;                         $resolve();                     })                     .finally( function (){                         var input = document.getElementById('image-input');                         var outImg = document.getElementById('outImage');                         if (input !== null && outImage !== null) {                             outImg.parentNode.removeChild(outImage);                             input.parentNode.removeChild(input);                         }                                             });                 }             fr.readAsDataURL(files[0]);             }         });         return;     }     codeReader.getVideoInputDevices()     .then(function(videoInputDevices) {         var availableDevices = videoInputDevices.length;         if (availableDevices === 0) {             $parameters.ErrorMessage = "There are no available cameras. Verify your devices or permissions";             $parameters.Success = false;             return;         }         else if (availableDevices > 1){             for(var i=0; i<availableDevices; i++){                 console.log("videoInput" + videoInputDevices[i].label);                 $parameters.VideoInput +=  "-" + videoInputDevices[i].label;                 if((videoInputDevices[i].label.toLowerCase()).includes(camera)) {                     selectedDeviceId = videoInputDevices[i].deviceId;                     break;                 }             }             if(selectedDeviceId === null) {                 console.log("videoInput2" + videoInputDevices[availableDevices-1].label);                 selectedDeviceId = videoInputDevices[availableDevices-1].deviceId;             }         }         else {             console.log("videoInput3" + videoInputDevices[0].label);             selectedDeviceId = videoInputDevices[0].deviceId;         }         codeReader.decodeFromInputVideoDevice(selectedDeviceId, 'video')             .then(function (result) {                 codeReader.reset();                 $parameters.Value = result.text;                 $parameters.Success = true;                                 $resolve();             })             .catch(function (err) {                 $parameters.ErrorMessage = "Scan was cancelled";                 $parameters.Success = false;                 $resolve();             })             .finally( function (){                 var divOverlay = document.getElementById('plugin-overlay');                 var video = document.getElementById('video');                 if (divOverlay !== null && video !== null) {                     video.parentNode.removeChild(video);                     divOverlay.parentNode.removeChild(divOverlay);                 }             });     })     .catch(function(err) {         $parameters.ErrorMessage = "Failure during scan.";         $parameters.Success = false;         $resolve();     }); }
0
0
884
Aug ’22
When touchend and touchstart occur at the same time, only touchstart not fired
There seems to be a bug that when touchstart and touchend events are set and they occur at the same time, only touchstart does not fire. For example, when touchstart occurs on the right hand and touchend occurs on the left hand at the same time. Does anyone know the details of this or a workaround? This occurs with Safari and Chrome on iOS 15.6 and not on Android devices. The following codepen demo will help you understand. https://codepen.io/arisaito/pen/WNzymjv In this demo, when touchstart is detected a box of each color appears at the top, and when touchend is detected the box disappears. However when touchstart and touchend are repeated with both hands on an iOS device, there are frequent cases where the box does not appear even if touchstart is occured.
2
1
855
Aug ’22
javascript Audio visualisation in Safari not working
Can anybody help me to check why this code is not working in Safari (osx)? The audio is is playing, but no visualisation. I tried all the hints I found, but still no luck. Need to mention it's working fine in Chrome (osx) Thanks a lot for help function getDataFromAudio() { var freqByteData = new Uint8Array(analyser.fftSize / 2); var timeByteData = new Uint8Array(analyser.fftSize / 2); analyser.getByteFrequencyData(freqByteData); analyser.getByteTimeDomainData(timeByteData); return { f: freqByteData, t: timeByteData }; // array of all 1024 levels } I see CodePen links are not enabled here. I posted on stackoverflow
0
0
1.2k
Aug ’22
Unable to get image data from canvas
DrawImage video source data to canvas and then getImageData from canvas. The safari throws the error "Unable to get image data from canvas. Requested size was 1080 x 1920 ". // videoElement.readyState = 4 ctx.drawImage(videoElement,0,0,1080,1920,0,0,1080,1920); const imageData = ctx.getImageData(0,0,1080,1920);" iphone 11, ios 15.5 The step to reproduce this issue is not clear to me. When the issue has been triggered before, it is more easily reproduced until the safari is restart
0
1
937
Aug ’22
HTML video showing black screen but sound is playing on iOS 15
My website shows a video using video tag which worked perfectly until not long ago. The video is working but when pressing on full screen, the video is playing but the screen is black while the sound is still playing. The issue occurs only on iPhones with iOS 15 (using Safari and Chrome also). Things I've tried: I've tried playing the video directly with a URL to the actual file(to check its not codec issue) and it worked properly. My video tag has 'position: absolute;' on it and I tried removing it(even though it breaks my layout) and that didn't work either. Tried pausing the video immediately and playing it after the video loads. Tried applying a background: white; or any non-transparent color to the video tag. Tried removing auto play. Tried to disable 'GPU process: Media' on safari settings just to check if that affects anything and it didnt. This is the html: <video data-test-id="long-video" #longVideo muted controls playsinline [class.d-none]="!isShortVideoHidden" *ngIf="isPageLoaded" src="https://cdn1.someurl.com/videos/commercial_1.mp4" type="video/mp4"> </video> and the css(with the parent): @media only screen and(min-width:992px) { .fixed-video { position: fixed; z-index: 10000; margin: auto; width: 100vw; height: 100vh; left: 0; top: 0; bottom: 0; right: 0; background: rgba(0, 0, 0, 0.5); transition: 0.4s; video { width: 80%; left: 0; right: 0; top: 0; bottom: 0; margin: auto; } } } Please tell me if you have struggled with this and know how to solve it. Thank you :)
3
1
5.1k
Aug ’22
Google Translator Javascript not working in iOS
I have one web viewer in React Native for my app, and the function of translate with Google works perfectly in the Safari browser, in my Android App, and on the desktop, but not in the iOS app This is my Google Translate code: function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'pt', includedLanguages: 'pt,en,es', layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL }, 'google_translate_element'); comboTranslate = document.querySelector("#google_translate_element .goog-te-combo"); } function changeEvent(el) { if (el.fireEvent) { el.fireEvent('onchange'); } else { // var evObj = document.createEvent("HTMLEvents"); var event = new Event('change'); comboTranslate.dispatchEvent(event); // evObj.initEvent("change", false, true); // el.dispatchEvent(evObj); } } function changeLang(lang) { if (comboTranslate) { comboTranslate.value = lang; changeEvent(comboTranslate); } } function clickChange(){ btn_translate = document.querySelectorAll('.language'); // o que faz os menus acender; btn_translate.forEach(btn =&gt; { btn.addEventListener('click', function (e) { var lang = e.srcElement.getAttribute('data-language'); changeLang(lang) }) }) } clickChange(); setTimeout(() =&gt; { googleTranslateElementInit() // comboTranslate.addEventListener('change', function (e) {alert('a');}) }, 500); and on the app.json I have: { "expo": { "name": "MyApp ", "slug": "MyApp", "version": "1.2.0", "orientation": "portrait", "icon": "./assets/icon.png", "locales": { "en": "./locales/ios/en.json", "pt": "./locales/ios/pt.json", "es": "./locales/ios/es.json" }, "platforms": [ "ios", "android" ], "splash": { "image": "./assets/splash.png", "resizeMode": "contain", "backgroundColor": "#ffffff" }, "plugins": [ [ "expo-notifications", { "icon": "./assets/icon.png", "color": "#ffffff" } ] ], "updates": { "fallbackToCacheTimeout": 0 }, "assetBundlePatterns": [ "**/*" ], "ios": { "buildNumber": "8", "supportsTablet": true, "bundleIdentifier": "com.myapp", "infoPlist": { "CFBundleAllowMixedLocalizations": true } }, "android": { "package": "com.myapp", "versionCode": 9, "googleServicesFile": "./google-services.json", "config": { "googleMaps": { "apiKey": "AIzaSyDQjE4F3chI8Jy4FA8h45LqA7bMfngoH7Y" } }, "permissions": ["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION", "CAMERA", "RECORD_AUDIO"], "blockedPermissions": ["ACCESS_BACKGROUND_LOCATION"], "adaptiveIcon": { "foregroundImage": "./assets/adaptive-icon.png", "backgroundColor": "#FFFFFF" } }, "notification": { "icon": "./assets/icon.png" } } } I put console.log and alerts to see if the change in the select element of languages is being triggered by the JS, and it's all ok, I really don't know why it is not translating.
3
0
3k
Aug ’22
Detect a SFSafariViewController vs Safari Browser with Javascript
Hello! We are looking for a way to detect if the user is in a SFSafariViewController or Safari Browser using Javascript. I was hoping for something in the window object, but there's nothing. I know some people have used window.innerHeight to do this for iOS versions up to iOS 14... but this does not work for iOS 15 & 16. And the only thing I could find on any forums are people saying that it cannot be done. I'm hoping that we could get a developer from Apple working on this ASAP, as we need to be able to do this.
Replies
1
Boosts
3
Views
1.1k
Activity
Oct ’22
our product website is not publishing on iPhone.
https://documentation.mindsphere.io/MindSphere/apps/asset-manager/introduction.html This above website is not supported in iPhone with latest OS(iOS &gt;= 15). What is the issues ??? Why it is getting blocked on browser ??? Need some urgent help on this.
Replies
1
Boosts
0
Views
635
Activity
Sep ’22
On-Hold Wifi Login Feature
I have noticed when trying to configure a Wifi login via QR code (html/js) that although iOS prompts the user to 'Join Network', it fails to actually join the network. If testing the same QR via the camera, it approves the login. I'm sure this was working in the iOS 15 beta and stopped working at public release, and hasn't worked in iOS16 either. Has anybody else encountered this? Is this a known issue, or a bug? or am i missing something? Thanks
Replies
0
Boosts
0
Views
689
Activity
Sep ’22
Microphone is disabled when trying to record (using getUserMedia)
I built a simple recorder on my website for users to record and playback audio. It works on ALL desktop browsers (including Safari) but when I use any browser on my iPhone, the mic is active at the opposite time. The flow is: ask permission > user allows mic access > user presses record > records audio > saves and plays back On iPhone what's happening is after the user allows permission, the mic goes active (visualized by the mic icon in safari browser) and then once the user presses record, it disables the mic. I am using getUserMedia within a React.js app Why is it doing this?
Replies
1
Boosts
0
Views
1.5k
Activity
Sep ’22
Web extension development in safari with JS framework
Hey, I'm looking for a way to develop safari web extension with any JS frameworks like AngularJS / ReactJS. Can someone help me to understand if it's possible, or it can be done only with plain JS. Can I get any links/pages to refer for the same ?
Replies
0
Boosts
0
Views
860
Activity
Sep ’22
Unable to use ALL cookies from webpage in my background script - [Safari App Extension]
Hi All. I am building a safari app extension which needs to make several HTTP requests from the background script. The HTTP requests need to use the Cookies that exist on my webpage. When I make the requests from my background script, I see 3 of my 4 cookies are added to the request cookie header, but the 4th cookie is not there. The 4th cookie has SameSite=Lax which seems to be the issue. When I manually change Lax to none, in my webpage's cookie storage, then the request goes through successfully from my background script. Does anyone know if there is a way to get/use cookies labeled as SameSite=Lax in my background script? I tried the broswer.cookies API, but it seems that the API will only retrieve non HttpOnly cookies, and my cookie has HttpOnly enabled as well, so this does not work. How can I make requests from my background script that need to use cookies from my webpage? P.S. This works in my chrome extension just fine, but it seems Safari has some restrictions Thanks in Advance :)
Replies
3
Boosts
1
Views
2k
Activity
Sep ’22
is there's a bug with evaluateJavaScript with WKWebView ?
I've created a simple projet, the purpose is to load a javascript webpage (https://www.myidtravel.com) and to programatically click a button. Basically I'm able to do all this stuff but not the click, the wkwebview is unchanged after the call of evaluateJavaScript (the completion Handler is ok with no error) With Safari or Chrome and the developer tools the click is working correctly: document.getElementById('button-1029').click(); I'm pretty new with JavaScript and I'm curious to see if it's a bug, or a bad implementation... Bellow you will see my implementation: import UIKit import WebKit class ViewController: UIViewController , WKNavigationDelegate{ var webView : WKWebView! override func loadView() { webView = WKWebView() webView.navigationDelegate = self view = webView } override func viewDidLoad() { super.viewDidLoad() let url = URL(string: "https://www.myidtravel.com/")! webView.load(URLRequest(url: url)) webView.customUserAgent = "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36" } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } //MARK:- WKNavigationDelegate func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { print(error.localizedDescription) } func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) { print("Strat to load") } func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { print("finish to load") DispatchQueue.main.asyncAfter(deadline: .now() + 4) { webView.evaluateJavaScript("document.getElementById('button-1029').click();", completionHandler: { (value, err) in print(">>>>>>>>>>>>>>>>>>>> click click") if let error = err { print("Error click") print(error.localizedDescription) } }) } } }
Replies
1
Boosts
1
Views
2.5k
Activity
Sep ’22
Safari low performance on special js web content.
When view some special web content with js, as mentioned below(with right corner on "Continue",which showed in Chinese, you can refer the arrow, let it auto scroll will show the problem). Cause P-core to increase to more 100% cpu usage. The page is test under windows; under chrome on same OS environments, no problem. But on safari 15.6(macOS 12.5, m1 Mac mini), 16beta and tech preview always have the same issue. https://www.baidu.com/s?rsv_idx=1&amp;wd=%E9%87%8D%E5%BA%86%E5%9F%8E%E5%8F%A3%E5%8E%BF%E5%9F%8E%E4%BE%9B%E6%B0%B4%E6%B0%B4%E6%BA%90%E4%BB%85%E5%A4%9F%E6%94%AF%E6%92%91%E5%8D%81%E5%A4%A9&amp;fenlei=256&amp;ie=utf-8&amp;rsv_pq=c3e520bf0006d8d0&amp;oq=%E5%9B%9B%E5%B7%9D%E5%B0%8F%E4%BC%99%E9%AB%98%E6%B8%A9%E5%A4%A9%E5%8D%96%E5%86%B0%E5%9D%97%E6%97%A5%E5%85%A5%E8%BF%87%E4%B8%87&amp;rsv_t=1b91DUeCY7TbON4DYyf9mO8Ujl1zg9wmPQ0O%2BRUbRNO%2F3g42IBRjUsYmELE&amp;rqid=c3e520bf0006d8d0&amp;rsf=526d5fb04211f1d3aefdb673067d9d32_1_15_7&amp;rsv_dl=0_right_fyb_pchot_20811&amp;sa=0_right_fyb_pchot_20811
Replies
2
Boosts
0
Views
825
Activity
Sep ’22
401 Error after 20 Minutes
I´ve build an app that gets metrics (amount of downloads) from Appstore Connect, every time a website is opened (this will happen every hour when own build endpoint /metrics is opened). Everything is working, except one thing. The Token has an max duration of 20 Minutes. Which is no problem because my app is creating a new one every time the site is called. But I get an 401 Error not authorized, even though a new token is generated after 20 minutes when the app is running and is calling for data again. I am assuming the app is using the old token to verify and ends up in a loop. how to force the app to use the new token when the function is called again (/metrics is opened) instead of the old token?
Replies
3
Boosts
0
Views
1.7k
Activity
Sep ’22
How many gigabytes of RAM do you need for development?
How many gigabytes of RAM do you need for development? please provide me with an honest answer.
Replies
4
Boosts
0
Views
1.5k
Activity
Aug ’22
Not working https call on Capacitor Nuxtjs App using axios under Xcode 13.4.1 on Monterey 12.5.1
Hi. I have one issue on my ios app. (connecting carers) All login and signup work on android and web app correctly well. And firebase login by email, google and apple work correctly well on ios app. But signup by email, google and apple doesn't work only on ios app First it creates new account from firebase. It works well. After that, when the user add new account in wordpress database, it calls wp api endpoints by https methods(get, post) using axios to create new account in wordpress database. But when we create new account in wp database via wp api by https call on ios app, it doesn't work only on ios app It works on web and android app well. I attached the screenshots here. Could you tell me what is the issue and why happended it? How can I fix the issue so that it can call the https by axios on ios app?
Replies
0
Boosts
0
Views
733
Activity
Aug ’22
xcode build succeed but doesn't run
Cant find a solution to this error.
Replies
0
Boosts
0
Views
709
Activity
Aug ’22
Call Swift functions from JS
I have a VIewController with WKWebView to display HTML content to my users. What I need is to get some information from my project side(swift codes) such as app version, data reports to javascrtript side. On the side of js, I'll be able to generate html codes or display elements based on swift function calls. Here are some codes in my ViewController: class AboutViewController: UIViewController { @IBOutlet weak var webView: WKWebView! { didSet { setJS() } } private let jsCtx = JSContext() private func setJS() { let obj = MyVersionClass() jsCtx.ctx.setObject(             obj,             forKeyedSubscript: "versionObj") } override func viewDidLoad() {         super.viewDidLoad() // build url webView.loadFileURL(             url,             allowingReadAccessTo: url) let request = URLRequest(url: url)         webView.load(request) } MyVersionClass is defined as: import JavaScriptCore @objc protocol JSAppVersionProtocol: JSExport {     func getAppVersion() -> String     static func createObj() -> MyVersionClass } class MyVersionClass: NSObject, JSAppVersionProtocol {     static func createObj() -> MyVersionClass {         let obj = MyVersionClass()         return obj     }     func getAppVersion() -> String {        ...     } } The class AboutViewController will load an html file with js defined in script section <head> <script type="text/javascript" src="../version.js"></script> </head> <body onload="updateVersion()"> ... <span id="appVersion">To be updated with my app version      </span> .... JS code: function updateVersion() {     let e = document.getElementById("appVersion");     var ver =versionObj.getAppVersion(); // another try, see following codes // var ver =versionObj.createObj().getAppVersion();     e.innerHTML = ver; } I tested the js function call in my AbountViewController class right after I setObject like this: let result = jsCtx.evaluateScript("versionObj") print("\(result)" I got the result in console like this: <MyApp.JSAppVersion: 0x282aa0af0> I also tried to setObject like this: jsCtx.ctx.setObject(             MyVersionClass.self,             forKeyedSubscript: "versionType") // My test of script function let result = jsCtx.evaluateScript("versionType") print("\(result)" // result is <MyApp.MyVersionClass> However, it seems that my js does not know what my swift function code is. It fails to get the app version. Not sure what is missing or wrong? How can I set up mu swift function available in js side?
Replies
2
Boosts
0
Views
4.6k
Activity
Aug ’22
On the ios i see this player video when i scan the qr-code
var addDrawsight = $parameters.DrawSight; ZXing.TemplateBuilder.buildInterface(addDrawsight, document.getElementById($parameters.Canvas_WidgetId)); codeReader = new ZXing.BrowserMultiFormatReader(); /* document.getElementById('close-button').addEventListener('click', function() {     codeReader.reset();     document.getElementById('plugin-overlay').style.display = 'none';     document.getElementById('video').pause();     $parameters.ErrorMessage = "Failure during scan. Scan was cancelled";     $parameters.Success = false; }, true); */ var menuBackHandler = function() {     codeReader.reset();     document.getElementById('plugin-overlay').style.display = 'none';     document.getElementById('video').pause();    // $parameters.ErrorMessage = "Failure during scan. Scan was cancelled";    // $parameters.Success = true;     $parameters.IsBack = true;     history.back(); }; $public.Navigation.registerBackNavigationHandler(menuBackHandler); var selectedDeviceId = null; if(codeReader !== null){     if(!codeReader.canEnumerateDevices){                 var divOverlay = document.getElementById('plugin-overlay');         var video = document.getElementById('video');         if (divOverlay !== null && video !== null) {             video.parentNode.removeChild(video);             divOverlay.parentNode.removeChild(divOverlay);         }                 var input = document.createElement("input");         input.id = 'image-input'         input.type = "file";         input.accept = "image/* capture='camera'";         input.style.display = 'none';         document.body.appendChild(input);         var outImg = document.createElement("img");         outImg.id = 'outImage';         //outImg.style.display = 'none';         outImg.style.width = '320';         outImg.style.height = '320';         var cont = document.getElementById('reactContainer');         cont.appendChild(outImg);         input.click();         input.addEventListener("change", function (evt) {             var tgt = evt.target || window.event.srcElement,                 files = tgt.files;             // FileReader support             if (FileReader && files && files.length) {                 var fr = new FileReader();                 fr.onload = function () {                     var outImg = document.getElementById('outImage');                     outImg.src = fr.result;                     codeReader.decodeFromImageElement('outImage')                     .then(function (result) {                         $parameters.Value = result.text;                         $parameters.Success = true;                         $resolve();                     })                     .catch(function (err) {                         $parameters.ErrorMessage = "Could not find a barcode. Please try with a different image";                         $parameters.Success = false;                         $resolve();                     })                     .finally( function (){                         var input = document.getElementById('image-input');                         var outImg = document.getElementById('outImage');                         if (input !== null && outImage !== null) {                             outImg.parentNode.removeChild(outImage);                             input.parentNode.removeChild(input);                         }                                             });                 }             fr.readAsDataURL(files[0]);             }         });         return;     }     codeReader.getVideoInputDevices()     .then(function(videoInputDevices) {         var availableDevices = videoInputDevices.length;         if (availableDevices === 0) {             $parameters.ErrorMessage = "There are no available cameras. Verify your devices or permissions";             $parameters.Success = false;             return;         }         else if (availableDevices > 1){             for(var i=0; i<availableDevices; i++){                 console.log("videoInput" + videoInputDevices[i].label);                 $parameters.VideoInput +=  "-" + videoInputDevices[i].label;                 if((videoInputDevices[i].label.toLowerCase()).includes(camera)) {                     selectedDeviceId = videoInputDevices[i].deviceId;                     break;                 }             }             if(selectedDeviceId === null) {                 console.log("videoInput2" + videoInputDevices[availableDevices-1].label);                 selectedDeviceId = videoInputDevices[availableDevices-1].deviceId;             }         }         else {             console.log("videoInput3" + videoInputDevices[0].label);             selectedDeviceId = videoInputDevices[0].deviceId;         }         codeReader.decodeFromInputVideoDevice(selectedDeviceId, 'video')             .then(function (result) {                 codeReader.reset();                 $parameters.Value = result.text;                 $parameters.Success = true;                                 $resolve();             })             .catch(function (err) {                 $parameters.ErrorMessage = "Scan was cancelled";                 $parameters.Success = false;                 $resolve();             })             .finally( function (){                 var divOverlay = document.getElementById('plugin-overlay');                 var video = document.getElementById('video');                 if (divOverlay !== null && video !== null) {                     video.parentNode.removeChild(video);                     divOverlay.parentNode.removeChild(divOverlay);                 }             });     })     .catch(function(err) {         $parameters.ErrorMessage = "Failure during scan.";         $parameters.Success = false;         $resolve();     }); }
Replies
0
Boosts
0
Views
884
Activity
Aug ’22
When touchend and touchstart occur at the same time, only touchstart not fired
There seems to be a bug that when touchstart and touchend events are set and they occur at the same time, only touchstart does not fire. For example, when touchstart occurs on the right hand and touchend occurs on the left hand at the same time. Does anyone know the details of this or a workaround? This occurs with Safari and Chrome on iOS 15.6 and not on Android devices. The following codepen demo will help you understand. https://codepen.io/arisaito/pen/WNzymjv In this demo, when touchstart is detected a box of each color appears at the top, and when touchend is detected the box disappears. However when touchstart and touchend are repeated with both hands on an iOS device, there are frequent cases where the box does not appear even if touchstart is occured.
Replies
2
Boosts
1
Views
855
Activity
Aug ’22
javascript Audio visualisation in Safari not working
Can anybody help me to check why this code is not working in Safari (osx)? The audio is is playing, but no visualisation. I tried all the hints I found, but still no luck. Need to mention it's working fine in Chrome (osx) Thanks a lot for help function getDataFromAudio() { var freqByteData = new Uint8Array(analyser.fftSize / 2); var timeByteData = new Uint8Array(analyser.fftSize / 2); analyser.getByteFrequencyData(freqByteData); analyser.getByteTimeDomainData(timeByteData); return { f: freqByteData, t: timeByteData }; // array of all 1024 levels } I see CodePen links are not enabled here. I posted on stackoverflow
Replies
0
Boosts
0
Views
1.2k
Activity
Aug ’22
Unable to get image data from canvas
DrawImage video source data to canvas and then getImageData from canvas. The safari throws the error "Unable to get image data from canvas. Requested size was 1080 x 1920 ". // videoElement.readyState = 4 ctx.drawImage(videoElement,0,0,1080,1920,0,0,1080,1920); const imageData = ctx.getImageData(0,0,1080,1920);" iphone 11, ios 15.5 The step to reproduce this issue is not clear to me. When the issue has been triggered before, it is more easily reproduced until the safari is restart
Replies
0
Boosts
1
Views
937
Activity
Aug ’22
HTML video showing black screen but sound is playing on iOS 15
My website shows a video using video tag which worked perfectly until not long ago. The video is working but when pressing on full screen, the video is playing but the screen is black while the sound is still playing. The issue occurs only on iPhones with iOS 15 (using Safari and Chrome also). Things I've tried: I've tried playing the video directly with a URL to the actual file(to check its not codec issue) and it worked properly. My video tag has 'position: absolute;' on it and I tried removing it(even though it breaks my layout) and that didn't work either. Tried pausing the video immediately and playing it after the video loads. Tried applying a background: white; or any non-transparent color to the video tag. Tried removing auto play. Tried to disable 'GPU process: Media' on safari settings just to check if that affects anything and it didnt. This is the html: <video data-test-id="long-video" #longVideo muted controls playsinline [class.d-none]="!isShortVideoHidden" *ngIf="isPageLoaded" src="https://cdn1.someurl.com/videos/commercial_1.mp4" type="video/mp4"> </video> and the css(with the parent): @media only screen and(min-width:992px) { .fixed-video { position: fixed; z-index: 10000; margin: auto; width: 100vw; height: 100vh; left: 0; top: 0; bottom: 0; right: 0; background: rgba(0, 0, 0, 0.5); transition: 0.4s; video { width: 80%; left: 0; right: 0; top: 0; bottom: 0; margin: auto; } } } Please tell me if you have struggled with this and know how to solve it. Thank you :)
Replies
3
Boosts
1
Views
5.1k
Activity
Aug ’22
Cookie is not inserted for XMLHttpRequest
Hi, I have the below scenario, 1.While accessing Index.html, server inserts a cookie and a JS file (request.js) 2 . request.js file collects some safari properties and posting it to the same web server like below, but during this call my cookie is missing. Can you please help? I want to retain my cookie value for the JS initiated request.
Replies
0
Boosts
0
Views
445
Activity
Aug ’22
Google Translator Javascript not working in iOS
I have one web viewer in React Native for my app, and the function of translate with Google works perfectly in the Safari browser, in my Android App, and on the desktop, but not in the iOS app This is my Google Translate code: function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'pt', includedLanguages: 'pt,en,es', layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL }, 'google_translate_element'); comboTranslate = document.querySelector("#google_translate_element .goog-te-combo"); } function changeEvent(el) { if (el.fireEvent) { el.fireEvent('onchange'); } else { // var evObj = document.createEvent("HTMLEvents"); var event = new Event('change'); comboTranslate.dispatchEvent(event); // evObj.initEvent("change", false, true); // el.dispatchEvent(evObj); } } function changeLang(lang) { if (comboTranslate) { comboTranslate.value = lang; changeEvent(comboTranslate); } } function clickChange(){ btn_translate = document.querySelectorAll('.language'); // o que faz os menus acender; btn_translate.forEach(btn =&gt; { btn.addEventListener('click', function (e) { var lang = e.srcElement.getAttribute('data-language'); changeLang(lang) }) }) } clickChange(); setTimeout(() =&gt; { googleTranslateElementInit() // comboTranslate.addEventListener('change', function (e) {alert('a');}) }, 500); and on the app.json I have: { "expo": { "name": "MyApp ", "slug": "MyApp", "version": "1.2.0", "orientation": "portrait", "icon": "./assets/icon.png", "locales": { "en": "./locales/ios/en.json", "pt": "./locales/ios/pt.json", "es": "./locales/ios/es.json" }, "platforms": [ "ios", "android" ], "splash": { "image": "./assets/splash.png", "resizeMode": "contain", "backgroundColor": "#ffffff" }, "plugins": [ [ "expo-notifications", { "icon": "./assets/icon.png", "color": "#ffffff" } ] ], "updates": { "fallbackToCacheTimeout": 0 }, "assetBundlePatterns": [ "**/*" ], "ios": { "buildNumber": "8", "supportsTablet": true, "bundleIdentifier": "com.myapp", "infoPlist": { "CFBundleAllowMixedLocalizations": true } }, "android": { "package": "com.myapp", "versionCode": 9, "googleServicesFile": "./google-services.json", "config": { "googleMaps": { "apiKey": "AIzaSyDQjE4F3chI8Jy4FA8h45LqA7bMfngoH7Y" } }, "permissions": ["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION", "CAMERA", "RECORD_AUDIO"], "blockedPermissions": ["ACCESS_BACKGROUND_LOCATION"], "adaptiveIcon": { "foregroundImage": "./assets/adaptive-icon.png", "backgroundColor": "#FFFFFF" } }, "notification": { "icon": "./assets/icon.png" } } } I put console.log and alerts to see if the change in the select element of languages is being triggered by the JS, and it's all ok, I really don't know why it is not translating.
Replies
3
Boosts
0
Views
3k
Activity
Aug ’22