Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

277
Views
Flashlight funciona en la web pero no en PWA

Usé el código de la respuesta de Nikolay https://jsfiddle.net/makhalin/nzw5tv1q/ en mi Ionic - Angular PWA (lo puse en un archivo custom.js y lo importé en angular.json). Funciona muy bien si lo abro en Chrome o Edge en Android, pero si lo instalo como PWA, funciona la primera vez y luego deja de funcionar.

¿Hay algo que deba hacer para que funcione como PWA?

 //have a console on mobile const consoleOutput = document.getElementById("console"); const log = function (msg) { consoleOutput.innerText = `${consoleOutput.innerText}\n${msg}`; console.log(msg); } //Test browser support const SUPPORTS_MEDIA_DEVICES = 'mediaDevices' in navigator; if (SUPPORTS_MEDIA_DEVICES) { //Get the environment camera (usually the second one) navigator.mediaDevices.enumerateDevices().then(devices => { const cameras = devices.filter((device) => device.kind === 'videoinput'); if (cameras.length === 0) { log('No camera found on this device.'); } // Create stream and get video track navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment', } }).then(stream => { const track = stream.getVideoTracks()[0]; //Create image capture object and get camera capabilities const imageCapture = new ImageCapture(track) imageCapture.getPhotoCapabilities().then(capabilities => { //let there be light! const btn = document.querySelector('.switch'); const torchSupported = !!capabilities.torch || ( 'fillLightMode' in capabilities && capabilities.fillLightMode.length != 0 && capabilities.fillLightMode != 'none' ); if (torchSupported) { let torch = false; btn.addEventListener('click', function (e) { try { track.applyConstraints({ advanced: [{ torch: (torch = !torch) }] }); } catch (err) { log(err); } }); } else { log("No torch found"); } }).catch(log); }).catch(log); }).catch(log); //The light will be on as long the track exists }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!