JavaScript

RSS for tag

Discuss the JavaScript programing language.

Posts under JavaScript tag

200 Posts

Post

Replies

Boosts

Views

Activity

React-native iOS crash on startup
Hi all, I need help with the following crash log. Been stuck on this for 2 days now and can't figure it out. It happend after upgrading from React-native 0.63.3 to 0.69.3. Crash log I've read about adding: import 'react-native-gesture-handler', but I've already done that. It's in my index.js file (first rendered file), at the top. Any help is appreciated!
1
1
2.1k
Mar ’23
evaluateJavascript not able to run script containing string interpolation
Hi Everyone, I am integrating ace editor in swift using WKWebview and injecting JS in WKWebview using evaluateJavascript function and its returning an error saying "A JavaScript exception occurred". This is only happening when my JS script contains string interpolation. Please find the code below. let script = "var content = String.raw` <script>\n// String Interpolation\nfunction myInfo(fname, lname, country) {\n return `My name is ${fname} ${lname}. ${country} is my favorite country`; \n}\nconsole.log(myInfo(\"john\", \"doe\", \"India\"));\n</script>`; editor.setValue(content);" webview.evaluateJavaScript(script) { (response, error) in } Thanks for help in advance!
0
0
882
Mar ’23
Service worker behavior (clients urls)
My SPA uses PWA technologies handling service workers with Workbox. While knocking to SW clients with self.clients.matchAll({ type: 'window' }).then(...) and then trying to do actions with clients urls found out a strange difference between SW behavior in Safari and Chrome. In Chrome the client.url field always contains the current url of every tab whenever and wherever you check it. In Safari client.url field contains the entry url for every tab and never changes wherever you navigate the page (mean - the client of the SW). The behavior in Chrome seems to be more proper, cause if you want, for example, to refresh all tabs you aren't able to ensure user's data safety and your app provides bad users experience dropping them to other url. Could you please consider this case. Thank you.
0
2
769
Mar ’23
Issues with video feed (getUserMedia)
I have an iPhone 11 Pro Max running iOS14.2 and find that getUserMedia does not work in all scenarios. I set up my video feed as follows: &#9;if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { &#9;&#9;throw new Error( &#9;&#9;&#9;'Browser API navigator.mediaDevices.getUserMedia not available'); &#9;} &#9;const video = document.getElementById('video'); &#9;const stream = await navigator.mediaDevices.getUserMedia({ &#9;&#9;'audio': false, &#9;&#9;'video': { &#9;&#9;&#9;facingMode: 'environment', &#9;&#9;&#9;// TODO: Currently set to window.innerWidth and innerHeight elsewhere? &#9;&#9;&#9;width: undefined, &#9;&#9;&#9;height: undefined &#9;&#9;}, &#9;}); &#9;// console.log(stream); &#9;video.srcObject = stream; &#9;return new Promise((resolve) => { &#9;&#9;video.onloadedmetadata = () => { &#9;&#9;&#9;resolve(video); &#9;&#9;}; &#9;}); } const loadVideo = async () => { &#9;const video = await setupCamera(); &#9;video.play(); &#9;return video; } My HTML is: <canvas id="videocanvas" width="100%" height="100%"> </canvas> <video id="video" &#9;&#9;&#9; autoplay &#9;&#9;&#9; playsinline &#9;&#9;&#9; muted &#9;&#9;&#9; style="display:none" &#9;&#9;&#9; width='100%'> </video> I'm using three.js to render a video texture, but also find this problem is demonstrable without this (see the Tensorflow PoseNet demo here https://github.com/tensorflow/tfjs-models/tree/master/posenet). The error displayed in the Javascript console for all of these is: [Error] A MediaStreamTrack ended due to a capture failure [Error] Unhandled Promise Rejection: Error: The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element. However, the BlazeFace demo works (see https://github.com/tensorflow/tfjs-models/tree/master/blazeface) yet appears to function in exactly the same way as the PoseNet code. I've tested this on 2 different iPhone 11s and an iPhone 12 mini with the same issues. All of the above code works on iOS 13.5 on an iPhone X without any issues. What has changed here between iOS 13.5 and iOS 14?
1
0
3.4k
Mar ’23
Web Speech Synthesis API: not all voices installed listed
I'm developing an application using the Web Speech API for speech synthesis. According to the API specification SpeechSynthesis.getVoices() should retrieve the voices available on the system. On my iPad Pro, 12,9 inch, 3rd generation, iOS 16 however this doesn't return all voices installed on the system. In system settings (Accessibility -> Spoken content -> Voices -> German) e.g. I see these voices: Anna Eloquence Markus Petra Siri Viktor Yannick However if for SpeechSynthesis.getVoices() I only get the voices within the group "Eloquence": Eddy Flo Grandma Grandpa Reed Rocko Sandy Shelley All other voices (Anna, Markus, etc.) are missing. Is this a bug or is it intended by Apple that it's impossible to use all voices? This is independent of the browser, it's the same for Safari, Chrome or Firefox. Use this in order to test which voices are available using the WebSpeech API: https://plnkr.co/edit/E2etsrUZVOVfrDwG
7
6
3.6k
Jan ’23
Swift to JavaScript communication
Hey, I would like to monitor whether my app is going to the background or comes back to the foreground. Then everytime when it stays in the background for more than 1min I would like to sent an information to my JS code and trigger some function there. I tried to set an observer through NotificationCenter to check app position (background/foreground) but then in the selector I am not able to make a connection between my Swift and JS code. I also tried with userContentController. Firstly send a message from JS and handle it using replyHandler but this is a one-time action and I couldn't call replyHandler every time the timer on the swift side will expire. Is there any way I can notify my JS about app being in the background for more than 1min without the need of constantly sending messeges from JS code?
0
0
917
Jan ’23
Iphone App written with Cordova and standard web technologies.
Can anyone give me a definitive answer to the following. I know a number of web technologies but not Swift or Xcode. I wish to write an app that makes use of Cordova and standard web technologies that will be accepted when submitted to the App Store. The one thing that I don't wish to do is spend the next four plus weeks developing it only to find it will be rejected. I don't really have time to expand my knowledge of Swift at this juncture. I have read so many contradicting rules so any guidance would be really appreciated. Many thanks.
2
0
2.5k
Jan ’23
Cant use node js
I am getting this issue while trying to load my application with node js. I think it's got to do with some some settings but im not sure. This is running under M1 chip imac. Feeling frustrated hope someone can help me out! architecture (have 'x86_64', need 'arm64e')), mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
3
0
1.6k
Dec ’22
onKeyDown/onKeyUp keyboard event doesn't fire on iOS 16.1 when tab/arrow key is pressed on external keyboard
I have an onKeyDown event handler in button but that doesn't get fired when any key is pressed on the external keyboard. When I press tab/shift+tab focus moves to the button. But any key press on the button is not triggering keyboard events. This is my code <button onKeyDown={(e) => {console.log(e);}}>Click here</button> Keyboard events are not getting fired for any of the html elements even with tabIndex=0.
0
0
1.1k
Dec ’22
Missing required column 'label' in json. at "HandPoseAssests.json"
I have created the .json file according to the https://developer.apple.com/documentation/createml/building-an-object-detector-data-source here is my .json file below     {         "imagefilename":"Five Fingers.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "Five Fingers"             }         ]     },     {         "imagefilename": "One Finger.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "One Finger"             }         ]     },     {         "imagefilename": "Two Finger.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "Two Finger"             }         ]     },     {         "imagefilename": "Four Finger.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "Four Finger"             }         ]     }     ] but it shows error as Missing required column 'label' in json. at "NameOfJsonFile.json" Were am I Wrong
2
0
1.6k
Dec ’22
Does Apple convert HEIC images to JPEG automatically when uploading
Hello, I'm web developer and I'm trying to place uploaded images on a map with the EXIF data (GPS coordinnates). The problem is that on iPhone, HEIC/HEIF images are directly converted to JPEG on upload and EXIF metadata are not retrieved. There is a workaround to this ? Thanks in advance.
Replies
0
Boosts
0
Views
719
Activity
Apr ’23
React-native iOS crash on startup
Hi all, I need help with the following crash log. Been stuck on this for 2 days now and can't figure it out. It happend after upgrading from React-native 0.63.3 to 0.69.3. Crash log I've read about adding: import 'react-native-gesture-handler', but I've already done that. It's in my index.js file (first rendered file), at the top. Any help is appreciated!
Replies
1
Boosts
1
Views
2.1k
Activity
Mar ’23
evaluateJavascript not able to run script containing string interpolation
Hi Everyone, I am integrating ace editor in swift using WKWebview and injecting JS in WKWebview using evaluateJavascript function and its returning an error saying "A JavaScript exception occurred". This is only happening when my JS script contains string interpolation. Please find the code below. let script = "var content = String.raw` <script>\n// String Interpolation\nfunction myInfo(fname, lname, country) {\n return `My name is ${fname} ${lname}. ${country} is my favorite country`; \n}\nconsole.log(myInfo(\"john\", \"doe\", \"India\"));\n</script>`; editor.setValue(content);" webview.evaluateJavaScript(script) { (response, error) in } Thanks for help in advance!
Replies
0
Boosts
0
Views
882
Activity
Mar ’23
Service worker behavior (clients urls)
My SPA uses PWA technologies handling service workers with Workbox. While knocking to SW clients with self.clients.matchAll({ type: 'window' }).then(...) and then trying to do actions with clients urls found out a strange difference between SW behavior in Safari and Chrome. In Chrome the client.url field always contains the current url of every tab whenever and wherever you check it. In Safari client.url field contains the entry url for every tab and never changes wherever you navigate the page (mean - the client of the SW). The behavior in Chrome seems to be more proper, cause if you want, for example, to refresh all tabs you aren't able to ensure user's data safety and your app provides bad users experience dropping them to other url. Could you please consider this case. Thank you.
Replies
0
Boosts
2
Views
769
Activity
Mar ’23
Issues with video feed (getUserMedia)
I have an iPhone 11 Pro Max running iOS14.2 and find that getUserMedia does not work in all scenarios. I set up my video feed as follows: &#9;if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { &#9;&#9;throw new Error( &#9;&#9;&#9;'Browser API navigator.mediaDevices.getUserMedia not available'); &#9;} &#9;const video = document.getElementById('video'); &#9;const stream = await navigator.mediaDevices.getUserMedia({ &#9;&#9;'audio': false, &#9;&#9;'video': { &#9;&#9;&#9;facingMode: 'environment', &#9;&#9;&#9;// TODO: Currently set to window.innerWidth and innerHeight elsewhere? &#9;&#9;&#9;width: undefined, &#9;&#9;&#9;height: undefined &#9;&#9;}, &#9;}); &#9;// console.log(stream); &#9;video.srcObject = stream; &#9;return new Promise((resolve) => { &#9;&#9;video.onloadedmetadata = () => { &#9;&#9;&#9;resolve(video); &#9;&#9;}; &#9;}); } const loadVideo = async () => { &#9;const video = await setupCamera(); &#9;video.play(); &#9;return video; } My HTML is: <canvas id="videocanvas" width="100%" height="100%"> </canvas> <video id="video" &#9;&#9;&#9; autoplay &#9;&#9;&#9; playsinline &#9;&#9;&#9; muted &#9;&#9;&#9; style="display:none" &#9;&#9;&#9; width='100%'> </video> I'm using three.js to render a video texture, but also find this problem is demonstrable without this (see the Tensorflow PoseNet demo here https://github.com/tensorflow/tfjs-models/tree/master/posenet). The error displayed in the Javascript console for all of these is: [Error] A MediaStreamTrack ended due to a capture failure [Error] Unhandled Promise Rejection: Error: The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element. However, the BlazeFace demo works (see https://github.com/tensorflow/tfjs-models/tree/master/blazeface) yet appears to function in exactly the same way as the PoseNet code. I've tested this on 2 different iPhone 11s and an iPhone 12 mini with the same issues. All of the above code works on iOS 13.5 on an iPhone X without any issues. What has changed here between iOS 13.5 and iOS 14?
Replies
1
Boosts
0
Views
3.4k
Activity
Mar ’23
Java on Xcode
I need a step by step how to use Java on Xcode and if I can't how can I use it on other platforms
Replies
1
Boosts
0
Views
718
Activity
Mar ’23
HCE on the new IOS
Hi I am developing an iOS app where I want the iPhone to act as an NFC tag from where the NFC reader can obtain the users information which is stored on the tag (Like an access card). Does the new iOS support HCE? How can I achieve this?
Replies
4
Boosts
0
Views
2.1k
Activity
Feb ’23
Is supportedNetworks on creating_an_apple_pay_session
Hi Team, Is the supportedNetworks on Create apple pay session a ordered list of networks to show to the user ? Ref : Creating an Apple Pay Session | Apple Developer Documentation Thanks Manish
Replies
0
Boosts
0
Views
560
Activity
Feb ’23
I can’t open logism on my Mac book air
I deleted and reinstalled Java and logism multiple times. I contacted apple support and they recommended the safe mode, that still did not work. Please help I’ve been fighting with this for over a week and I have an assignment due this week with it.
Replies
0
Boosts
0
Views
730
Activity
Feb ’23
WKWebView: how to display a big HTML5 canvas?
Hello, Viewport is 1180x820 on iPad, even if screen resolution is 2360x1640. If I set up a canvas of 2360x1640, only a quarter is displayed on my WKWebView. And I have to display a 2360x1640 canvas. So I'm not able to display it in my WKWebView on my iPad. I'm sure I do something wrong. Could you please help me? Regards, Alex
Replies
0
Boosts
0
Views
795
Activity
Feb ’23
Web Speech Synthesis API: not all voices installed listed
I'm developing an application using the Web Speech API for speech synthesis. According to the API specification SpeechSynthesis.getVoices() should retrieve the voices available on the system. On my iPad Pro, 12,9 inch, 3rd generation, iOS 16 however this doesn't return all voices installed on the system. In system settings (Accessibility -> Spoken content -> Voices -> German) e.g. I see these voices: Anna Eloquence Markus Petra Siri Viktor Yannick However if for SpeechSynthesis.getVoices() I only get the voices within the group "Eloquence": Eddy Flo Grandma Grandpa Reed Rocko Sandy Shelley All other voices (Anna, Markus, etc.) are missing. Is this a bug or is it intended by Apple that it's impossible to use all voices? This is independent of the browser, it's the same for Safari, Chrome or Firefox. Use this in order to test which voices are available using the WebSpeech API: https://plnkr.co/edit/E2etsrUZVOVfrDwG
Replies
7
Boosts
6
Views
3.6k
Activity
Jan ’23
Electron Builder
is possible to send in apple store a software created with electron-builder? thanks
Replies
1
Boosts
0
Views
985
Activity
Jan ’23
Swift to JavaScript communication
Hey, I would like to monitor whether my app is going to the background or comes back to the foreground. Then everytime when it stays in the background for more than 1min I would like to sent an information to my JS code and trigger some function there. I tried to set an observer through NotificationCenter to check app position (background/foreground) but then in the selector I am not able to make a connection between my Swift and JS code. I also tried with userContentController. Firstly send a message from JS and handle it using replyHandler but this is a one-time action and I couldn't call replyHandler every time the timer on the swift side will expire. Is there any way I can notify my JS about app being in the background for more than 1min without the need of constantly sending messeges from JS code?
Replies
0
Boosts
0
Views
917
Activity
Jan ’23
Iphone App written with Cordova and standard web technologies.
Can anyone give me a definitive answer to the following. I know a number of web technologies but not Swift or Xcode. I wish to write an app that makes use of Cordova and standard web technologies that will be accepted when submitted to the App Store. The one thing that I don't wish to do is spend the next four plus weeks developing it only to find it will be rejected. I don't really have time to expand my knowledge of Swift at this juncture. I have read so many contradicting rules so any guidance would be really appreciated. Many thanks.
Replies
2
Boosts
0
Views
2.5k
Activity
Jan ’23
iOS 15.0 and iOS 16.0 - Focus doesn't move to links (<a> element) when pressing tab/shift+tab in external keyboard
While pressing tab/shift+tab using external keyboard focus doesn't move to tag elements even with tabIndex=0. This is my javascript code <a href="https://discussions.apple.com/" tabIndex={0}>Click here</a> Focus moves to all other html elements except link element.
Replies
1
Boosts
1
Views
1.6k
Activity
Jan ’23
Availability of letterSpacing <canvas> in Safari?
Do you have any idea when the "letterSpacing" property of CanvasRenderingContext2D API will be implemented in Safari? This feature is really useful for those who, like me, work with fonts on canvas. https://caniuse.com/mdn-api_canvasrenderingcontext2d_letterspacing
Replies
0
Boosts
0
Views
1k
Activity
Jan ’23
Cant use node js
I am getting this issue while trying to load my application with node js. I think it's got to do with some some settings but im not sure. This is running under M1 chip imac. Feeling frustrated hope someone can help me out! architecture (have 'x86_64', need 'arm64e')), mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
Replies
3
Boosts
0
Views
1.6k
Activity
Dec ’22
Access iOS triple camera and micro camera in Javascript web application
I have a JavaScript web application which scans ID image using back camera. In iPhone 14, the image capture is always blurred because the camera is not focusing the object close to camera. Is there a way to access micro camera feed or to adjust focus? Or to get a camera feed that adjust focus automatically depending upon the object position?
Replies
0
Boosts
0
Views
724
Activity
Dec ’22
onKeyDown/onKeyUp keyboard event doesn't fire on iOS 16.1 when tab/arrow key is pressed on external keyboard
I have an onKeyDown event handler in button but that doesn't get fired when any key is pressed on the external keyboard. When I press tab/shift+tab focus moves to the button. But any key press on the button is not triggering keyboard events. This is my code <button onKeyDown={(e) => {console.log(e);}}>Click here</button> Keyboard events are not getting fired for any of the html elements even with tabIndex=0.
Replies
0
Boosts
0
Views
1.1k
Activity
Dec ’22
Missing required column 'label' in json. at "HandPoseAssests.json"
I have created the .json file according to the https://developer.apple.com/documentation/createml/building-an-object-detector-data-source here is my .json file below     {         "imagefilename":"Five Fingers.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "Five Fingers"             }         ]     },     {         "imagefilename": "One Finger.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "One Finger"             }         ]     },     {         "imagefilename": "Two Finger.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "Two Finger"             }         ]     },     {         "imagefilename": "Four Finger.HEIC",         "annotation": [             {                 "coordinates": {                     "y": 156.062,                     "x": 195.122,                     "height": 148.872,                     "width": 148.03                 },                 "label": "Four Finger"             }         ]     }     ] but it shows error as Missing required column 'label' in json. at "NameOfJsonFile.json" Were am I Wrong
Replies
2
Boosts
0
Views
1.6k
Activity
Dec ’22