OGeek|极客世界-中国程序员成长平台

标题: javascript - 为什么通过相机上传图像可以在移动设备上工作,但不能作为 iOS PWA? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 22:16
标题: javascript - 为什么通过相机上传图像可以在移动设备上工作,但不能作为 iOS PWA?

我有一个具有 PWA 功能的网页。

在 iOS safari 上,我确实收到了通常的操作系统对话框,询问我是否要拍照或从照片库上传图片:

enter image description here

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", iOS 相机应用按预期打开,但完全黑屏。

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>

仅连接 javascript:

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;
  });
});

我没有任何想法,也没有找到任何关于限制的线索。另外:它似乎不应该提示对话框或照片应用程序。 我很高兴有任何建议。要么用 HTML 文件输入或(如果可能的话)替代方案来修复它。



Best Answer-推荐答案


直到 iOS 11.3 才有效,但从 11.3 开始的所有版本可能都可以:

更多细节也可以在这里找到:How to access camera on iOS11 home screen web app?

我可以使用 iOS 版本 11.4+ 的不同设备进行测试,并确认:适用于这些设备。但未使用 12 及更高版本进行测试。

关于javascript - 为什么通过相机上传图像可以在移动设备上工作,但不能作为 iOS PWA?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54844616/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4