本文介绍了iOS相机离开PWA后返回黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用html文件输入来打开相机并为我的PWA拍照.

I'm using html file input to open camera and take photos for my PWA.

<input type="file" accept="image/*" capture="camera" name="photo" id="photo-input-js" data-project-id="<?php echo $projectId ?>">

// this element triggers the input
<li class="menu-item <?php echo $current_page == 'camera' ? 'is-active' : '' ?>" id="camera-tab">
   <a href="<?php echo site_url("photos/openCamera/". $projectId) ?>" id="open-camera-js">
            <div class="icon icon-camera"></div>
    <span class="d-none d-md-block ">Camera</span>
   </a>
</li>

JavaScript:

Javascript:

// open camera
$(document).on('click', '#open-camera-js', function(e) {
  e.preventDefault();

  $(".menu-item").removeClass('is-active');
  $("#camera-tab").addClass('is-active');

  // check support for geolocation/ask for permissions
  if (!navigator.geolocation) {
      throw new Error('Unsupproted device');
   }

  // open the file input
  $("#photo-input-js").click();
});

// save image
$(document).on('change', '#photo-input-js', function(e) {
     e.preventDefault();
     let photo = $(this).prop('files')[0] ? $(this).prop('files')[0] : false;
     if (photo) {
        // handle captured photo
     }

将pwa下载到主屏幕后,相机可以正常工作,直到我离开应用程序并返回,而无需从打开的应用程序中刷掉该应用程序.

After I download the pwa to my homescreen, camera works perfectly until I leave the app and come back without swiping out the app from open apps.

如果按下主屏幕按钮并离开应用程序,然后再返回,我将得到黑屏,而不是像这样的摄像机镜头:

If press the home button and leave the app, and then come back, I get a black screen instead of camera footage like this:

此后,我必须离开该应用程序,然后从打开的应用程序中刷出我的pwa,然后再次打开该应用程序,以使相机正常工作.

After that I have to leave the app and swipe out my pwa from open apps and open the app again to make camera work again normally.

相机在我的pwa的android版本上工作正常

Camera works fine on android version of my pwa

推荐答案

这是由iOS 13.2和13.3中的错误引起的.

This was caused by a bug in iOS 13.2 and 13.3.

您可以在此处找到错误报告

它已在iOS 13.4和更高版本中解决.我可以亲自确认是否可以在13.3中重现此问题,但在更新至13.5.1之后不能.

It has been resolved in iOS 13.4 and later. I can personally confirm I could reproduce this issue in 13.3, but not after updating to 13.5.1

这篇关于iOS相机离开PWA后返回黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 12:01