5

Edit: Duplicate of How to access camera on iOS11 home screen web app?

I'm running into a problem with using a apple web-app together with camera access through the getUserMedia API.

I have some application that is working fine when accessed through safari, it asks for persmission to use the camera and upon approval I can see the camera feed. But if I save this same page to the home screen as an web-app this does not work anymore. There is no prompt for camera access, which seems to be the problem as it is not enabled by default.

The line that gives the problems is a meta tag which enables full screen for a web application on iOS.

<meta name="apple-mobile-web-app-capable" content="yes">

Anyone know what is going on here and why this fails? Do I need to set camera permission somehow through a meta tag also?

Thanks in advance!

Evertvdw
  • 827
  • 10
  • 17
  • Having the same problem with my mobile web app when it runs from the home screen bookmark mode. Still works in regular iOS safari though. Also, noticed that localStorage and using desktop Safari Develop menu inspector for bookmarked web apps will not even show up as 'inspectable'. Was this an oversight by Apple? Or are they trying to lock things down? – tonejac Sep 21 '17 at 05:06

2 Answers2

5

Apple has removed the ability to use getUserMedia inside a UIWebView, WKWebView, SFSafariViewController, or a webpage that has been "added to the home screen".

The reasoning is not clear, however I do not believe this to be a bug.

An Apple staff member wrote this about WebRTC in iOS 11:

...right now, WebRTC is only supported in Safari. No WKWebView, not even SFSafariViewController.

And I can confirm that this includes the UIWebView as well (through personal tesing).

Klathmon
  • 273
  • 1
  • 11
  • Can you provide some official links please? It will be easy to explain my lead. – Rakesh Oct 14 '17 at 04:36
  • 1
    An Apple staff member has confirmed that WebRTC is only supported in Safari, no WKWebView, No UIWebView, no SFSafariViewController. https://forums.developer.apple.com/thread/88052 – Klathmon Oct 16 '17 at 17:51
0

The navigator.mediaDevices.getUserMedia function is back in iOS 14.3 which got out yesterday. (Make sure you are not using the navigator.getUserMedia which is deprecated).

We'll be using it in Cordova, I'll update this post if we find some instabilities.

Don't forget to use the playinline attribute in your <video> element if you don't want the video to start in fullscreen.

cadesalaberry
  • 612
  • 1
  • 8
  • 17