Hello !
Very interesting article. I implemented it in a PWA I'm doing. I can see your stackblitz is showing the AmbientLightSensor class is undefined. The same was happening in my VSCode IDE I can say.
I could solve it by adding the following source code above the service class:
declare global {
interface Window {
AmbientLightSensor: any;
}
}
And injecting the window: Window object in the constructor, I then could do:
const sensor: any = new this.window.AmbientLightSensor();
Kind Regards,
Stephane Eybert
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello !
Very interesting article. I implemented it in a PWA I'm doing. I can see your stackblitz is showing the AmbientLightSensor class is undefined. The same was happening in my VSCode IDE I can say.
I could solve it by adding the following source code above the service class:
declare global {
interface Window {
AmbientLightSensor: any;
}
}
And injecting the window: Window object in the constructor, I then could do:
const sensor: any = new this.window.AmbientLightSensor();
Kind Regards,
Stephane Eybert