Why does upload image via camera work on mobile-safari but not as iOS PWA?

馋奶兔 提交于 2019-12-21 02:55:17

问题


I have a webpage with PWA capabilities.

On iOS safari I do get the usual OS dialog asking me if I want to take a photo or upload a picture from the photo library:

After "installing" it as an PWA via the menu "Add to Homescreen" button and starting it via homescreen, I still get the same options, "choose from library" still works, but when choosing "take a photo", the iOS camera app opens, as expected, but stays completely black.

html:

<head>

  <meta charset="utf-8">
  <title>dingsda user interface 2</title>

  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="mobile-web-app-capable" content="yes">
  <link rel="manifest" href="manifest.json">

  (...)

  <label class="fileContainer ui-btn">
    <input type="file" accept="image/jpeg" id="photo_upload" multiple data-role="none"/>
   </label>

only javascript connected:

document.getElementById("photo_upload").addEventListener("change",
function(){
  console.log("got pic, will resize now:");
  resizeBase64image(document.getElementById("photo_upload"),
  function(base64img){
    console.log("resized pic. will add it to src");
    document.getElementById("addPhoto").src = base64img;
  });
});

I have no ideas, nor did I find any clues about limitations. Also: it seems like it should not prompt the dialog nor the photo app anyhow. I am happy for any suggestions. either to fix it with HTML file-input or (if possible) alternatives.


回答1:


Strange effectively , i saw the same issue on PWA sites on Safari with the last update IOS 12.2. Camera doesn't record video now on PWA.

Apparently it does not work that also told me a Dev expert on PWA that I questioned.

There are not really any answers from Apple's devs who made the Safari IOS Last update on discussions.

They avoid the subject a little, I feel...

It is very important and very sensitive part in period where Big tech leaders they speak to us about augmented reality and artificial intelligence.

I think they neglect this aspect too much. More for questions of interests (For my advice). They have the means to fix it quickly and there is no real reason for a AR Key feature. Free App need also to could view not necessarily to spy users like other Tech Companies who playing on Apple Store now.

We talk about using the video input on the mobile web part (Free) on Ios Native it works very well so why not on the PWA ??

I think this issue of access to the camera should be better explained to customers.

These are decisions that involve a lot of things indeed.

There are not many people working on the same topics, but it's not centralized enough

I think every Developer who encounters the problem should report here because it is important

There are two App markets Store on mobile Duopoly :

Apple Store / Google Play Store

Microsoft started to eat on cloud computing market and abandoned Internet explorer for Chrome.Now Internet explorer it's replaced by Chrome.

Google it's default search engine on IOS Safari. Some medias talk to $9.5 billion for 2018.

We could also play & subscribe streaming Videos & musics services with your mobile.(Spotify, Netflix). Apple need to eat Apple will fight more against Facebook if they progress fast in mobile payment and App ecosystem(about securities issues that they have long tolerated) . There are important financial goals behind especially that it is more difficult to sell phones with Chinese concurrency and if Facebook want to eat market for VR and AR Apps in their own store.

Apple is trying to protect itself above all because the market is changing but they can not block such important features for the devs without explications. It's not serious. On Android, there are no more securities issues. Users have enough social indicators to check if a site is reliable or not.

Camera support must work properly as well as other communicating phone features.




回答2:


It did not work till iOS 11.3 but all Versions from 11.3 upwards might be okay:

More Details to that can be also found here: How to access camera on iOS11 home screen web app?

I could test with different devices with iOS Versions 11.4+ and confirm: works on those. Not tested with 12 and above though.




回答3:


Actually when i try to record video




回答4:


Add capture (camera, camcorder or filesystem) to input file

<label class="fileContainer ui-btn"> <input type="file" accept="image/jpeg" id="photo_upload" multiple data- role="none" capture="camera"/> </label>



来源:https://stackoverflow.com/questions/54844616/why-does-upload-image-via-camera-work-on-mobile-safari-but-not-as-ios-pwa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!