JavaScript

RSS for tag

Discuss the JavaScript programing language.

Posts under JavaScript tag

200 Posts

Post

Replies

Boosts

Views

Activity

Issue with Safari PWA and Push Notifications: clients.openWindow Not Functioning
Hello everyone, I've been working on implementing push notifications for the web PWA using JavaScript, and I've encountered an issue specifically with Safari on Mac and iOS devices. While my code snippet works perfectly fine in Chrome, I'm facing a problem with the clients.openWindow function. It doesn't seem to perform any actions or provide any errors. Here's the code snippet for reference: self.addEventListener('push', (event) => { const notification = JSON.parse(event.data.text()); console.log(notification); const title = notification?.notification?.title; const body = notification?.notification?.body; const data = notification?.data; const options = { body, data, icon: '/favicon.ico', badge: '/favicon.ico', vibrate: [100, 50, 100], actions: [ { action: onNotificationAction(notification['data']), title: notification.notification.title, }, ], }; event.waitUntil(self.registration.showNotification(title, options)); }); self.addEventListener('notificationclick', (event) => { console.log(event, 'event'); const notification = event?.notification; event.notification.close(); event.waitUntil( clients .matchAll({ type: 'window', }) .then((clientList) => { for (const client of clientList) { if (client.url === '/' && 'focus' in client) return client.focus(); } if (clients.openWindow) return clients.openWindow('/messages'); }), ); }); After thorough testing, I've determined that the issue lies specifically with the clients.openWindow function. Unfortunately, I haven't been able to identify any errors or determine why it isn't functioning as expected. The goal is to open a new window or focus on an existing one when a notification is clicked. I would greatly appreciate any assistance or insights into resolving this issue. Has anyone else encountered a similar problem with Safari and iOS? Are there any alternative approaches or workarounds that could achieve the desired functionality? Thank you in advance for your help and suggestions!
0
2
1.4k
Jul ’23
Safari extension background page unable to fetch web accessible resource
I have a chrome extension that was converted to Safari extension using xcode safari-web-extension-converter utility. With that, everything except one thing seems to be fine. In the background script, I am loading some data from a web accessible resource like so: export const fetchConfig = async () => { let dataURL = ''; if (!checkBrowser(BROWSERS.Chrome, true)) { dataURL = chrome.runtime.getURL('config.json'); } else { dataURL = browser.runtime.getURL('config.json'); } const res = await fetch(dataURL); return await res.json(); } This works for all browsers except Safari. Where I am getting the runtime URL as: safari-web-extension://E522689D-94A6-4561-90F3-BF22C7848965/config.json but the fetch call fails with the error: Failed to load resource: unsupported URL I have not been able to find anything on this in the documentation, but can we not access the web accessible resources in background in Safari? My manifest file looks like this: { "manifest_version": 3, "name": "Ext Dev", "author": "Test", "description": "Test", "version": "1.1.0", "icons": { "16": "assets/icon/icon16.png", "32": "assets/icon/icon32.png", "48": "assets/icon/icon48.png", "128": "assets/icon/icon128.png" }, "host_permissions": [ ... host addresses here ... ], "permissions": ["storage", "tabs"], "content_security_policy": { "extension_pages": "script-src 'self'; object-src 'self';" }, "web_accessible_resources": [{ "resources": ["config.json"], "matches": ["<all_urls>"] }], "content_scripts": [ { "matches": ["<all_urls>"], "js": ["content.js"], "css": ["commonstyles.css"], "run_at": "document_end", "all_frames": true } ], "background": { "service_worker": "background.js" }, "action": { "default_title": "Ext Client", "default_icon": { "20": "assets/icon/icon20.png", "40": "assets/icon/icon40.png" } }
2
2
2.8k
Jun ’23
Web Components specifications in 2023 - Custom Elements
Hello, I would reply to this post but the reply button is broken in Chrome and Firefox on Linux..... If I am out of date or have misunderstood then please accept my apologies in advance. I want to do make the following custom element in Safari but it is apparently not currently supported for "ideological" reasons ? class my_special_element extends HTMLInputElement { myCustomFunction(){ self.value="Oh look, I have extended the element class with a new method"; } } //Then in HTML <input is="my-special-element"> I can already, easily extend web components in Safari right now by doing the following - as I have been doing for the past 15 years in all browsers. function my_special_element_pretend_class(element) { self=element; self.myCustomFunction=function(){ self.value="Oh look, I have extended the element class with a new method"; } return self; } //In this case myElement is an "input" element. var myElement = document.getElementById('myElement'); myElement=my_special_element_pretend_class(myElement); myElement.myCustomFunction(); Given that this is so unbelievably easy to do, why is Apple adopting a stance at odds with the W3C over Web Components ? If you're HONESTLY worried about namespace collisions then surely just throw an exception ? Don't we already have to stay on top of bugs caused by new features etc ? Security ? Really ? Please read the code above again ! Surely you'd have to fundamentally alter the core extensibility of Javascript to keep yourself safe from that ? We all breathed a massive sigh of relief when Microsoft killed IE11. Is Safari going to become the hated reason for another zillion bloated, resource consuming polyfills that slow down the UI ONLY on YOUR devices ? Best wishes Chris
0
3
1.3k
Jun ’23
chrome on iOS: How to disable microphone access popup when mic is turned on?
Whenever the mic is turned on on an iOS device using Chrome browser, a popup saying "Microphone Access Allowed" appears. Chrome does not have any documentation/blog regarding the popup. All it has is the support page at https://support.google.com/chrome/answer/2693767?hl=en&co=GENIE.Platform%3DiOS&oco=1 that says: ... When prompted, tap Allow or Don't Allow. To immediately edit your preference, tap Edit. I have a web app that turns microphone on/off frequently which results in the said popup appearing constantly ruining the UX. Is there any way to fix this? Say, for example, make it appear only once, better, disable it altogether? I understand that Chrome is doing it to catch user's attention that an app is accessing the microphone. But in my case, the UX suffers greatly when the core of my app involves using microphone. This happens only on iOS. Has anyone have had similar experience before?
0
0
952
Jun ’23
MusicKitJS | Cannot play explicit songs | CONTENT_RESTRICTED
[Ticket on Feedback Assistant FB12353357] Hi there, We’re experiencing issues playing explicit songs using MusicKitJS for the Web (tested on both stable v1 and beta v3). Upon calling the SDK’s “play()” function, the following error gets logged in the console “CONTENT_RESTRICTED: Content restricted” and playback doesn’t begin. The Storefront we’ve tested in is “it”, but very likely all of them are impacted with the issue, here’s a few Adam IDs of affected tracks: 1681182396, 1683117248, 1669607876. A quick check with the REST APIs reveals indeed that the relevant thing all 3 of them have in common is "contentRating" being "explicit”. The bug isn’t however easy or predictable to replicate because it seems that it can be somewhat solved by fiddling with both the “Screen Time” restrictions settings within an iOS/iPadOS device (of course logged in with the same Apple account), as well as with the “Parental Controls” dashboard located in the Web version of the Apple Music’s settings page. We’re still not 100% sure what exactly “triggers” the fix, but both mentioned dashboards above are essential in attempting to solve it by trial and error. Specifically: in the “Parental Controls” dashboard what helps is actually turning ON the restrictions with the toggle, and then easing them up the most by specifically setting the less restricted available option in all 3 dropdown menus (pretty baffling); in the “Screen time” dashboard what helps is simply enabling/disabling the feature itself altogether, as well as the “Content & Privacy restrictions” toggle, and changing the level of allowed content between “Clean” and “Explicit”; I also want to highlight the fact that during the entire process, for the issue to be actually solved, users every time had to to restart their iPhone/iPad multiple times after changing a setting in “Screen time”, along with deauthorizing/authorizing (logging out and back in) their Apple Music account from the MusicKitJS SDK. The issue seems to always affect freshly created Apple accounts right from the start, we’re not aware of methods that can lead to the bug “coming back” and starting to happen again after being solved manually with the process above (meddling “randomly” with dashboards). It’s a pretty serious one because many of our users do not posses an Apple device and only use their Apple Music subscription on the Web and/or their Android device, meaning that the “Screen time” dashboard isn’t available for them. We’ve never been able to solve the problem on an Apple ID account solely by fiddling with the “Parental Controls” dashboard located in the Web version of the Apple Music’s settings page: tinkering with the “Screen time” settings was essential every single time, meaning owning an Apple device is essential to solve it. Last thing I’m adding is that the issue doesn’t seem to also affect listening to these explicit songs directly with the various first-party Apple Music clients (tested on the iOS native app, Android native app, and on the Apple Music WebApp). Steps to reproduce: on the Web, create a new Apple ID account and activate an Apple Music subscription (do not login with said account on an Apple device); go to the Apple Music WebApp settings page at music.apple.com/account/settings and make sure that the “Parental Controls” restrictions are turned OFF; open any explicit song in the Apple Music WebApp and confirm that playback is allowed; login and authorize the newly created account using any website/application integrated with the MusicKitJS SDK (v1 or v3, doesn’t matter); open the same explicit song as before (or any other) in said third-party client that uses the SDK and verify that playback doesn’t begin and an error “CONTENT_RESTRICTED: Content restricted” is logged in the console upon playing. Additional infos: Apple ID account region and language: Italy - Italian; Storefront affected: IT but possibly all of them; MusicKitJS versions affected: both v1 and v3; Browser where the issue was reproduced: Chrome v114. Attached you’ll find some informational screenshots. Thanks!
2
0
1.4k
Jun ’23
Uncaught (in promise) DOMException: Not supported (Screensharing Using The WebRTC)
I have electronjs app for the MAC Catalyst. I have implemented audio/video calling functionalities. Those works well. I have also implemented functionality to share the screen by using below code. navigator.mediaDevices.getDisplayMedia(options).then((streams) => { var peer_connection = session.sessionDescriptionHandler.peerConnection; var video_track = streams.getVideoTracks()[0]; var sender_kind = peer_connection.getSenders().find((sender) => { return sender.track.kind == video_track.kind; }); sender_kind.replaceTrack(video_track); video_track.onended = () => { }; }, () => { console.log("Error occurred while sharing screen"); } ); But when I hit the button to share the screen by using above code, I am getting below error. Uncaught (in promise) DOMException: Not supported I have also tried navigator.getUserMedia(options,success,error). It's supported by the Mac Catalyst desktop apps. But it's only giving the streams of the webcam. I have also checked online if navigator.mediaDevices.getDisplayMedia(options) is supported in the Mac Catalyst or not. It's supports in the Mac Catalyst. But still I am facing this issue. I have also tried with the desktopCapturer API of the electronjs. But I don't know how can I get the streams from it. //CODE OF 'main.js' ipcMain.on("ask_permission", () => { desktopCapturer .getSources({ types: ["window", "screen"] }) .then(async (sources) => { for (const source of sources) { // console.log(source); if (source.name === "Entire screen") { win.webContents.send("SET_SOURCE", source.id); return; } } }); }); I have tried to get streams by using the below code in the preload.js. But I was getting the error Cannot read property 'srcObject' of undefined. window.addEventListener("DOMContentLoaded", (event) => { ipcRenderer.on("SET_SOURCE", async (event, sourceId) => { try { const stream = await navigator.mediaDevices.getUserMedia({ audio: false, video: { mandatory: { chromeMediaSource: "desktop", chromeMediaSourceId: sourceId, minWidth: 1280, maxWidth: 1280, minHeight: 720, maxHeight: 720, }, }, }); handleStream(stream); } catch (e) { handleError(e); } }); let btn = document.getElementById("btnStartShareOutgoingScreens"); btn.addEventListener("click", () => { if (isSharing == false) { ipcRenderer.send("ask_permission"); } else { console.error("USer is already sharing the screen.............."); } }); }); function handleStream(stream) { const video = document.createElement("video"); video.srcObject = stream; video.muted = true; video.id = "screenShareVideo"; video.style.display = "none"; const box = document.getElementById("app"); box.appendChild(video); isSharing = true; } How can I resolve it. If this is not supported in the MAC Catalyst, Is there is any other way to share the screen from the MAC Catalyst app by using WebRTC.
0
1
1.4k
Jun ’23
Is There Any Way To Share The Screen On The MAC Catalyst App
I am new in the MAC Catalyst development. I have one application that is developed by using electronjs. This app is having the functionality of SIP/VoIP. Audio/Video calling works well. But I want to implement the screen sharing functionality. I have tried to implement it but I was not able to do it. I have tried the below stuff: navigator.mediaDevices.getUserMedia(options) : It was giving error "Uncaught (in promise) DOMException: Not supported". desktopCapturer.getSources : Not able to get streams. I have written the logic to get streams in the preload.js file. I am not able to get streams and suppose in case, I have got the streams, How can I load that on the video element that is not rendered yet? Because the preload file is executed before the loading of the window. So It's giving the error 'Cant read property 'srcObject' of undefined''. ipcRenderer & ipcMain : Giving the same result as above. AVFoundation : Only working for the mobile apps. So my question is, Is there any way to share the screen in the MAC Catalyst apps by using electronjs or by using any other way? If so, Please refer.
0
1
879
Jun ’23
Location Alert does not open in PWA
Hi guys, I have built a PWA that calls the javascript API navigator.geolocation.getCurrentPosition which prompts the user for location access when the Safari permission is set to Ask. This is the correct behavior and works as expected when open in Safari. However when added to the Home Screen and running with a display mode of "standalone", the location alert does not open on my phone (iPhone 13 mini / iOS 15.1.1). And the call never times out. Then if I switch from the PWA to Safari the location alert / prompt is suddenly showing in Safari. So it seems that the alert is targeting the wrong "tab". This does not happen if the PWA display mode is "browser" or "mimimal-ui" with either of those it behaves normally. I can only replicate this on my phone (iPhone 13 mini / iOS 15.1.1). I have also tested on various older phones (15.1.1 and 14.7) as well as several emulators and they all behave as expected. It is possible this is a obscure setting on my phone but it does feel a lot like an iOS Safari bug.
4
3
3.6k
Jun ’23
How do I receive APNS silent push message payload in a web page on safari
I am trying to implement Safari Web Push using the document to setup APNS and receive silent push messages on a react app on Safari browser. At this point, I have added an endpoint to get push packages on calling window.safari.requestPermission. This prompts the user to enable notification and grants the permission and returns with a device token. I have a server-side node script implemented using node-apn to send a silent push message to the client using a device token. The send function resolves with a successful response. Sample message packet that I am sending via APNS: { "aps": { "content-available": 1 }, "customData": "custom data", "topic": "web.push.ID" } I am expecting the payload to be delivered to the client through an event. I am trying this with the below function on the web page. window.addEventListener('push', function (event) { if (event && event.push) { const payload = event.push; console.log('safari received payload in window.addEventListener:', payload); } }); However, I do not see any message coming to the client. Can someone please point me to what I am missing here? Thanks a lot for your help in advance.
0
0
873
May ’23
In safari on IOS16 or later, simultaneous presses of "a" and "meta" are not caught when a keydown type event listener is set in JavaScript.
We have confirmed the title issue on iPads with at least IOS16 or later. window.addEventListener('keydown', e => { e.preventDefault(); e.stopPropagation(); console.log(JSON.stringify(e, ['key', 'altKey', 'ctrlKey', 'shiftKey', 'metaKey'])); }) When a key is pressed in the above code, the console outputs what is being pressed now. However, when the meta key is pressed, "a" does not respond. In addition to this, all other key pairs in the shortcut list displayed by long-pressing "command" do not respond. Is there any way to work around this problem?
1
0
821
May ’23
Emojis corrupted on iOS when using negation with unicode character class escapes
I'm using regular expressions to remove non-latin and non-emoji characters from strings. As Unicode character class escapes (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape) are now widely supported, I used them to simplify my expressions. const regex = new RegExp('[^(\\d\\s\\p{Script=Latin}\\p{gc=Punctuation}\\p{Extended_Pictographic})]+', 'gui'); function removeUnsupportedChars(txt: string) { return txt.replace(this.characterEx, ''); } This works on PC and on Android. However, on iOS, when using this regular expression, emojis get corrupted and shown as squares. I created a minimal CodePen https://codepen.io/lizozom-the-sans/pen/GRYxOzp where the scenario is reproduced with a simplified regex and it seems like on iOS any usage of negation on the Extended_Pictographic class (or any of the other emoji classes) leads to their corruption. Is this a known issue on iOS? Any known workarounds (other than using explicit emoji lists)?
0
0
941
May ’23
App crashing on initial load
My iOS app is crashing on the initial load. It's happening both in my Testflight build and also in the production version of the app on the App Store. It was working fine a few days ago; this just started happening all of a sudden. What's strange is that after doing a fresh install, it doesn't happen the first time I open the app. It only happens after I force close the app and open it again (and every time afterward). I'm using Expo and React Native to build the app. I've attached a crash log. crash log - https://developer.apple.com/forums/content/attachment/6a5962a1-56ac-44b0-8ec4-4e8dee0daee8
3
0
5.8k
Apr ’23
IOS 16.4 beta 2 PWA Push notifications
Hello everyone! I'm trying to test push notifications for PWA, but when I request permission via JS I catch 'Permissions denied'. Notification.requestPermission(result => { console.log(result) if (result === 'granted') { alert('Permissions granted') } else { alert('Permissions denied') } }); Is it available to get permissions for IOS? It works properly with android and mac. Does anyone know what am I missing, or what is wrong?
4
4
7.9k
Apr ’23
Safari: ajax call to localhost blocked
We have a web application that needs to interact with local hardware (a smartcard). We have developed an app running on localhost that interact with hardware and exposes some services. The web application is exposed in https and calls services on lcalhost in http (we can't have a valid certificate for localhost). Safari blocks the call with this error in the console: XMLHttpRequest cannot load http://127.0.0.1:58666/status due to access control checks. All other major browsers (Chrome, FireFox, Edge) work without problems. Some references: https://stackoverflow.com/questions/66689081/localhost-http-accessed-from-https-webpage-why-no-mixed-content-error https://bugs.webkit.org/show_bug.cgi?id=171934 Is there a workaround to let Safari do the call? Do you have an alternative solution?
0
0
1.7k
Apr ’23
browser.tabs.onRemoved.addListener not functioning correctly
I'm creating a safari extension where if a tab/window is closed, I need it to do some background cleaning, for example removing the local storage data. I tried the following lines in my background.js: browser.tabs.onRemoved.addListener((tabId, removeInfo) => { console.log("tab closed"); }); browser.windows.onRemoved.addListener(function(windowid) { console.log("window closed") }) windows.onRemoved seems to work fine, but tabs.onRemoved seems to be working exactly like windows.onRemoved. I've tested it multiple times and every time without any hesitation, I don't get any "tab closed" in my console logs. But when I close the window, I get both messages above. Is this a bug? Is there something I'm missing? I'm using Safari v16.3
3
0
1.7k
Apr ’23
Issue with Safari PWA and Push Notifications: clients.openWindow Not Functioning
Hello everyone, I've been working on implementing push notifications for the web PWA using JavaScript, and I've encountered an issue specifically with Safari on Mac and iOS devices. While my code snippet works perfectly fine in Chrome, I'm facing a problem with the clients.openWindow function. It doesn't seem to perform any actions or provide any errors. Here's the code snippet for reference: self.addEventListener('push', (event) => { const notification = JSON.parse(event.data.text()); console.log(notification); const title = notification?.notification?.title; const body = notification?.notification?.body; const data = notification?.data; const options = { body, data, icon: '/favicon.ico', badge: '/favicon.ico', vibrate: [100, 50, 100], actions: [ { action: onNotificationAction(notification['data']), title: notification.notification.title, }, ], }; event.waitUntil(self.registration.showNotification(title, options)); }); self.addEventListener('notificationclick', (event) => { console.log(event, 'event'); const notification = event?.notification; event.notification.close(); event.waitUntil( clients .matchAll({ type: 'window', }) .then((clientList) => { for (const client of clientList) { if (client.url === '/' && 'focus' in client) return client.focus(); } if (clients.openWindow) return clients.openWindow('/messages'); }), ); }); After thorough testing, I've determined that the issue lies specifically with the clients.openWindow function. Unfortunately, I haven't been able to identify any errors or determine why it isn't functioning as expected. The goal is to open a new window or focus on an existing one when a notification is clicked. I would greatly appreciate any assistance or insights into resolving this issue. Has anyone else encountered a similar problem with Safari and iOS? Are there any alternative approaches or workarounds that could achieve the desired functionality? Thank you in advance for your help and suggestions!
Replies
0
Boosts
2
Views
1.4k
Activity
Jul ’23
Safari extension background page unable to fetch web accessible resource
I have a chrome extension that was converted to Safari extension using xcode safari-web-extension-converter utility. With that, everything except one thing seems to be fine. In the background script, I am loading some data from a web accessible resource like so: export const fetchConfig = async () => { let dataURL = ''; if (!checkBrowser(BROWSERS.Chrome, true)) { dataURL = chrome.runtime.getURL('config.json'); } else { dataURL = browser.runtime.getURL('config.json'); } const res = await fetch(dataURL); return await res.json(); } This works for all browsers except Safari. Where I am getting the runtime URL as: safari-web-extension://E522689D-94A6-4561-90F3-BF22C7848965/config.json but the fetch call fails with the error: Failed to load resource: unsupported URL I have not been able to find anything on this in the documentation, but can we not access the web accessible resources in background in Safari? My manifest file looks like this: { "manifest_version": 3, "name": "Ext Dev", "author": "Test", "description": "Test", "version": "1.1.0", "icons": { "16": "assets/icon/icon16.png", "32": "assets/icon/icon32.png", "48": "assets/icon/icon48.png", "128": "assets/icon/icon128.png" }, "host_permissions": [ ... host addresses here ... ], "permissions": ["storage", "tabs"], "content_security_policy": { "extension_pages": "script-src 'self'; object-src 'self';" }, "web_accessible_resources": [{ "resources": ["config.json"], "matches": ["<all_urls>"] }], "content_scripts": [ { "matches": ["<all_urls>"], "js": ["content.js"], "css": ["commonstyles.css"], "run_at": "document_end", "all_frames": true } ], "background": { "service_worker": "background.js" }, "action": { "default_title": "Ext Client", "default_icon": { "20": "assets/icon/icon20.png", "40": "assets/icon/icon40.png" } }
Replies
2
Boosts
2
Views
2.8k
Activity
Jun ’23
Web Components specifications in 2023 - Custom Elements
Hello, I would reply to this post but the reply button is broken in Chrome and Firefox on Linux..... If I am out of date or have misunderstood then please accept my apologies in advance. I want to do make the following custom element in Safari but it is apparently not currently supported for "ideological" reasons ? class my_special_element extends HTMLInputElement { myCustomFunction(){ self.value="Oh look, I have extended the element class with a new method"; } } //Then in HTML <input is="my-special-element"> I can already, easily extend web components in Safari right now by doing the following - as I have been doing for the past 15 years in all browsers. function my_special_element_pretend_class(element) { self=element; self.myCustomFunction=function(){ self.value="Oh look, I have extended the element class with a new method"; } return self; } //In this case myElement is an "input" element. var myElement = document.getElementById('myElement'); myElement=my_special_element_pretend_class(myElement); myElement.myCustomFunction(); Given that this is so unbelievably easy to do, why is Apple adopting a stance at odds with the W3C over Web Components ? If you're HONESTLY worried about namespace collisions then surely just throw an exception ? Don't we already have to stay on top of bugs caused by new features etc ? Security ? Really ? Please read the code above again ! Surely you'd have to fundamentally alter the core extensibility of Javascript to keep yourself safe from that ? We all breathed a massive sigh of relief when Microsoft killed IE11. Is Safari going to become the hated reason for another zillion bloated, resource consuming polyfills that slow down the UI ONLY on YOUR devices ? Best wishes Chris
Replies
0
Boosts
3
Views
1.3k
Activity
Jun ’23
chrome on iOS: How to disable microphone access popup when mic is turned on?
Whenever the mic is turned on on an iOS device using Chrome browser, a popup saying "Microphone Access Allowed" appears. Chrome does not have any documentation/blog regarding the popup. All it has is the support page at https://support.google.com/chrome/answer/2693767?hl=en&co=GENIE.Platform%3DiOS&oco=1 that says: ... When prompted, tap Allow or Don't Allow. To immediately edit your preference, tap Edit. I have a web app that turns microphone on/off frequently which results in the said popup appearing constantly ruining the UX. Is there any way to fix this? Say, for example, make it appear only once, better, disable it altogether? I understand that Chrome is doing it to catch user's attention that an app is accessing the microphone. But in my case, the UX suffers greatly when the core of my app involves using microphone. This happens only on iOS. Has anyone have had similar experience before?
Replies
0
Boosts
0
Views
952
Activity
Jun ’23
MusicKitJS | Cannot play explicit songs | CONTENT_RESTRICTED
[Ticket on Feedback Assistant FB12353357] Hi there, We’re experiencing issues playing explicit songs using MusicKitJS for the Web (tested on both stable v1 and beta v3). Upon calling the SDK’s “play()” function, the following error gets logged in the console “CONTENT_RESTRICTED: Content restricted” and playback doesn’t begin. The Storefront we’ve tested in is “it”, but very likely all of them are impacted with the issue, here’s a few Adam IDs of affected tracks: 1681182396, 1683117248, 1669607876. A quick check with the REST APIs reveals indeed that the relevant thing all 3 of them have in common is "contentRating" being "explicit”. The bug isn’t however easy or predictable to replicate because it seems that it can be somewhat solved by fiddling with both the “Screen Time” restrictions settings within an iOS/iPadOS device (of course logged in with the same Apple account), as well as with the “Parental Controls” dashboard located in the Web version of the Apple Music’s settings page. We’re still not 100% sure what exactly “triggers” the fix, but both mentioned dashboards above are essential in attempting to solve it by trial and error. Specifically: in the “Parental Controls” dashboard what helps is actually turning ON the restrictions with the toggle, and then easing them up the most by specifically setting the less restricted available option in all 3 dropdown menus (pretty baffling); in the “Screen time” dashboard what helps is simply enabling/disabling the feature itself altogether, as well as the “Content & Privacy restrictions” toggle, and changing the level of allowed content between “Clean” and “Explicit”; I also want to highlight the fact that during the entire process, for the issue to be actually solved, users every time had to to restart their iPhone/iPad multiple times after changing a setting in “Screen time”, along with deauthorizing/authorizing (logging out and back in) their Apple Music account from the MusicKitJS SDK. The issue seems to always affect freshly created Apple accounts right from the start, we’re not aware of methods that can lead to the bug “coming back” and starting to happen again after being solved manually with the process above (meddling “randomly” with dashboards). It’s a pretty serious one because many of our users do not posses an Apple device and only use their Apple Music subscription on the Web and/or their Android device, meaning that the “Screen time” dashboard isn’t available for them. We’ve never been able to solve the problem on an Apple ID account solely by fiddling with the “Parental Controls” dashboard located in the Web version of the Apple Music’s settings page: tinkering with the “Screen time” settings was essential every single time, meaning owning an Apple device is essential to solve it. Last thing I’m adding is that the issue doesn’t seem to also affect listening to these explicit songs directly with the various first-party Apple Music clients (tested on the iOS native app, Android native app, and on the Apple Music WebApp). Steps to reproduce: on the Web, create a new Apple ID account and activate an Apple Music subscription (do not login with said account on an Apple device); go to the Apple Music WebApp settings page at music.apple.com/account/settings and make sure that the “Parental Controls” restrictions are turned OFF; open any explicit song in the Apple Music WebApp and confirm that playback is allowed; login and authorize the newly created account using any website/application integrated with the MusicKitJS SDK (v1 or v3, doesn’t matter); open the same explicit song as before (or any other) in said third-party client that uses the SDK and verify that playback doesn’t begin and an error “CONTENT_RESTRICTED: Content restricted” is logged in the console upon playing. Additional infos: Apple ID account region and language: Italy - Italian; Storefront affected: IT but possibly all of them; MusicKitJS versions affected: both v1 and v3; Browser where the issue was reproduced: Chrome v114. Attached you’ll find some informational screenshots. Thanks!
Replies
2
Boosts
0
Views
1.4k
Activity
Jun ’23
Uncaught (in promise) DOMException: Not supported (Screensharing Using The WebRTC)
I have electronjs app for the MAC Catalyst. I have implemented audio/video calling functionalities. Those works well. I have also implemented functionality to share the screen by using below code. navigator.mediaDevices.getDisplayMedia(options).then((streams) => { var peer_connection = session.sessionDescriptionHandler.peerConnection; var video_track = streams.getVideoTracks()[0]; var sender_kind = peer_connection.getSenders().find((sender) => { return sender.track.kind == video_track.kind; }); sender_kind.replaceTrack(video_track); video_track.onended = () => { }; }, () => { console.log("Error occurred while sharing screen"); } ); But when I hit the button to share the screen by using above code, I am getting below error. Uncaught (in promise) DOMException: Not supported I have also tried navigator.getUserMedia(options,success,error). It's supported by the Mac Catalyst desktop apps. But it's only giving the streams of the webcam. I have also checked online if navigator.mediaDevices.getDisplayMedia(options) is supported in the Mac Catalyst or not. It's supports in the Mac Catalyst. But still I am facing this issue. I have also tried with the desktopCapturer API of the electronjs. But I don't know how can I get the streams from it. //CODE OF 'main.js' ipcMain.on("ask_permission", () => { desktopCapturer .getSources({ types: ["window", "screen"] }) .then(async (sources) => { for (const source of sources) { // console.log(source); if (source.name === "Entire screen") { win.webContents.send("SET_SOURCE", source.id); return; } } }); }); I have tried to get streams by using the below code in the preload.js. But I was getting the error Cannot read property 'srcObject' of undefined. window.addEventListener("DOMContentLoaded", (event) => { ipcRenderer.on("SET_SOURCE", async (event, sourceId) => { try { const stream = await navigator.mediaDevices.getUserMedia({ audio: false, video: { mandatory: { chromeMediaSource: "desktop", chromeMediaSourceId: sourceId, minWidth: 1280, maxWidth: 1280, minHeight: 720, maxHeight: 720, }, }, }); handleStream(stream); } catch (e) { handleError(e); } }); let btn = document.getElementById("btnStartShareOutgoingScreens"); btn.addEventListener("click", () => { if (isSharing == false) { ipcRenderer.send("ask_permission"); } else { console.error("USer is already sharing the screen.............."); } }); }); function handleStream(stream) { const video = document.createElement("video"); video.srcObject = stream; video.muted = true; video.id = "screenShareVideo"; video.style.display = "none"; const box = document.getElementById("app"); box.appendChild(video); isSharing = true; } How can I resolve it. If this is not supported in the MAC Catalyst, Is there is any other way to share the screen from the MAC Catalyst app by using WebRTC.
Replies
0
Boosts
1
Views
1.4k
Activity
Jun ’23
Is There Any Way To Share The Screen On The MAC Catalyst App
I am new in the MAC Catalyst development. I have one application that is developed by using electronjs. This app is having the functionality of SIP/VoIP. Audio/Video calling works well. But I want to implement the screen sharing functionality. I have tried to implement it but I was not able to do it. I have tried the below stuff: navigator.mediaDevices.getUserMedia(options) : It was giving error "Uncaught (in promise) DOMException: Not supported". desktopCapturer.getSources : Not able to get streams. I have written the logic to get streams in the preload.js file. I am not able to get streams and suppose in case, I have got the streams, How can I load that on the video element that is not rendered yet? Because the preload file is executed before the loading of the window. So It's giving the error 'Cant read property 'srcObject' of undefined''. ipcRenderer & ipcMain : Giving the same result as above. AVFoundation : Only working for the mobile apps. So my question is, Is there any way to share the screen in the MAC Catalyst apps by using electronjs or by using any other way? If so, Please refer.
Replies
0
Boosts
1
Views
879
Activity
Jun ’23
Add card to Apple Wallet on web
Is there a way to implement the functionality of adding a credit card to an Apple Wallet when the development is in web using JavaScript, either through an API or SDK solution?
Replies
0
Boosts
1
Views
1.2k
Activity
Jun ’23
PWA vs Ionic Application vs Wrapped website in Ionic application
Hey, I read the guidelines of the App Store and saw that repackaged website will be declined. Buts, an ionic application is basically a wrapped website and PWA as well. So I don't really understand the guidelines. Is there someone or somewhere I cam message to ask and get a formal answer? Thanks in a advance.
Replies
1
Boosts
0
Views
1.1k
Activity
Jun ’23
Location Alert does not open in PWA
I'm facing the same issue posted here however there is no feedback/outcome on this issue.. can some one confirm if it is a bug or not? https://developer.apple.com/forums/thread/694999
Replies
0
Boosts
0
Views
649
Activity
Jun ’23
Location Alert does not open in PWA
Hi guys, I have built a PWA that calls the javascript API navigator.geolocation.getCurrentPosition which prompts the user for location access when the Safari permission is set to Ask. This is the correct behavior and works as expected when open in Safari. However when added to the Home Screen and running with a display mode of "standalone", the location alert does not open on my phone (iPhone 13 mini / iOS 15.1.1). And the call never times out. Then if I switch from the PWA to Safari the location alert / prompt is suddenly showing in Safari. So it seems that the alert is targeting the wrong "tab". This does not happen if the PWA display mode is "browser" or "mimimal-ui" with either of those it behaves normally. I can only replicate this on my phone (iPhone 13 mini / iOS 15.1.1). I have also tested on various older phones (15.1.1 and 14.7) as well as several emulators and they all behave as expected. It is possible this is a obscure setting on my phone but it does feel a lot like an iOS Safari bug.
Replies
4
Boosts
3
Views
3.6k
Activity
Jun ’23
localhost not working only on safari browser
We use a custom local host url like "localapplications.example.com:8080". When we run the server on local, it is not working in safari. Working fine on chrome. Any reason why this could be happening?
Replies
0
Boosts
0
Views
1.1k
Activity
May ’23
How do I receive APNS silent push message payload in a web page on safari
I am trying to implement Safari Web Push using the document to setup APNS and receive silent push messages on a react app on Safari browser. At this point, I have added an endpoint to get push packages on calling window.safari.requestPermission. This prompts the user to enable notification and grants the permission and returns with a device token. I have a server-side node script implemented using node-apn to send a silent push message to the client using a device token. The send function resolves with a successful response. Sample message packet that I am sending via APNS: { "aps": { "content-available": 1 }, "customData": "custom data", "topic": "web.push.ID" } I am expecting the payload to be delivered to the client through an event. I am trying this with the below function on the web page. window.addEventListener('push', function (event) { if (event && event.push) { const payload = event.push; console.log('safari received payload in window.addEventListener:', payload); } }); However, I do not see any message coming to the client. Can someone please point me to what I am missing here? Thanks a lot for your help in advance.
Replies
0
Boosts
0
Views
873
Activity
May ’23
In safari on IOS16 or later, simultaneous presses of "a" and "meta" are not caught when a keydown type event listener is set in JavaScript.
We have confirmed the title issue on iPads with at least IOS16 or later. window.addEventListener('keydown', e => { e.preventDefault(); e.stopPropagation(); console.log(JSON.stringify(e, ['key', 'altKey', 'ctrlKey', 'shiftKey', 'metaKey'])); }) When a key is pressed in the above code, the console outputs what is being pressed now. However, when the meta key is pressed, "a" does not respond. In addition to this, all other key pairs in the shortcut list displayed by long-pressing "command" do not respond. Is there any way to work around this problem?
Replies
1
Boosts
0
Views
821
Activity
May ’23
Emojis corrupted on iOS when using negation with unicode character class escapes
I'm using regular expressions to remove non-latin and non-emoji characters from strings. As Unicode character class escapes (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape) are now widely supported, I used them to simplify my expressions. const regex = new RegExp('[^(\\d\\s\\p{Script=Latin}\\p{gc=Punctuation}\\p{Extended_Pictographic})]+', 'gui'); function removeUnsupportedChars(txt: string) { return txt.replace(this.characterEx, ''); } This works on PC and on Android. However, on iOS, when using this regular expression, emojis get corrupted and shown as squares. I created a minimal CodePen https://codepen.io/lizozom-the-sans/pen/GRYxOzp where the scenario is reproduced with a simplified regex and it seems like on iOS any usage of negation on the Extended_Pictographic class (or any of the other emoji classes) leads to their corruption. Is this a known issue on iOS? Any known workarounds (other than using explicit emoji lists)?
Replies
0
Boosts
0
Views
941
Activity
May ’23
App crashing on initial load
My iOS app is crashing on the initial load. It's happening both in my Testflight build and also in the production version of the app on the App Store. It was working fine a few days ago; this just started happening all of a sudden. What's strange is that after doing a fresh install, it doesn't happen the first time I open the app. It only happens after I force close the app and open it again (and every time afterward). I'm using Expo and React Native to build the app. I've attached a crash log. crash log - https://developer.apple.com/forums/content/attachment/6a5962a1-56ac-44b0-8ec4-4e8dee0daee8
Replies
3
Boosts
0
Views
5.8k
Activity
Apr ’23
Help to integrate in app purchase to webtonative
I need you to add Java script code to my Wordpress website so it will integrate with in app purchase of apple developer tool. I send you instructions https://docs.webtonative.com/javascript-apis/in-app-purchase-ios-integration
Replies
1
Boosts
0
Views
1k
Activity
Apr ’23
IOS 16.4 beta 2 PWA Push notifications
Hello everyone! I'm trying to test push notifications for PWA, but when I request permission via JS I catch 'Permissions denied'. Notification.requestPermission(result => { console.log(result) if (result === 'granted') { alert('Permissions granted') } else { alert('Permissions denied') } }); Is it available to get permissions for IOS? It works properly with android and mac. Does anyone know what am I missing, or what is wrong?
Replies
4
Boosts
4
Views
7.9k
Activity
Apr ’23
Safari: ajax call to localhost blocked
We have a web application that needs to interact with local hardware (a smartcard). We have developed an app running on localhost that interact with hardware and exposes some services. The web application is exposed in https and calls services on lcalhost in http (we can't have a valid certificate for localhost). Safari blocks the call with this error in the console: XMLHttpRequest cannot load http://127.0.0.1:58666/status due to access control checks. All other major browsers (Chrome, FireFox, Edge) work without problems. Some references: https://stackoverflow.com/questions/66689081/localhost-http-accessed-from-https-webpage-why-no-mixed-content-error https://bugs.webkit.org/show_bug.cgi?id=171934 Is there a workaround to let Safari do the call? Do you have an alternative solution?
Replies
0
Boosts
0
Views
1.7k
Activity
Apr ’23
browser.tabs.onRemoved.addListener not functioning correctly
I'm creating a safari extension where if a tab/window is closed, I need it to do some background cleaning, for example removing the local storage data. I tried the following lines in my background.js: browser.tabs.onRemoved.addListener((tabId, removeInfo) => { console.log("tab closed"); }); browser.windows.onRemoved.addListener(function(windowid) { console.log("window closed") }) windows.onRemoved seems to work fine, but tabs.onRemoved seems to be working exactly like windows.onRemoved. I've tested it multiple times and every time without any hesitation, I don't get any "tab closed" in my console logs. But when I close the window, I get both messages above. Is this a bug? Is there something I'm missing? I'm using Safari v16.3
Replies
3
Boosts
0
Views
1.7k
Activity
Apr ’23