iOS 11 its not me its you (tags: iOS11, PWA, Camera)

Yes, I was trying to get the Camera working in iOS 11.2.6 without success:

...

public ngAfterViewInit() {

    const constraints = {
      audio: false,
      video: {
        width: { min: 1024, ideal: 1280, max: 1920 },
        height: { min: 776, ideal: 720, max: 1080 },
        facingMode: 'environment'
      }
    };

    if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {

      navigator.mediaDevices.getUserMedia(constraints).then(stream => {
        this.video.nativeElement.src = window.URL.createObjectURL(stream);
        this.stream = stream;
        this.video.nativeElement.play();
      }).catch(function(err) {
        this.logger.error(err.name + ': ' + err.message);
      });

    } else {
      this.logger.error('Your browser does not support the mediaDevices API');
    }
  }

}

...

E.g., navigator.mediaDevices.getUserMedia() is undefined :frowning:

So then I switched to using:

  <input type="file" ... >

Which allowed me to access the device’s photo library but not the camera (of a device running (iOS 11.2.6).

iOS 11.3 allows access the device’s camera and the photo library via the <input type="file"> element.

But, navigator.mediaDevices.getUserMedia() is still undefined.

See: https://medium.com/@firt/progressive-web-apps-on-ios-are-here-d00430dee3a7

1 Like