Input type file in webview - Xcode

Asked

Viewed 325 times

0

I created a webview of a page that contains an input type file to upload photos, however, in Iphone webview, when I click the button to upload the photo, it opens a menu only with the option of "Gallery Photos", and does not give the camera option. Searching the internet I saw that I need to free access to camera and photo gallery through the file info.plist. Inserting the Keys to release the camera and gallery

<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library.</string>
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera.</string>

When I click on the button it works the same way. Give me only the gallery option and not the camera option. When I click on the gallery option it closes the app, then that gallery release also did not work.

Maybe it’s the Keys' order, I’ve tried to keep changing their order, but I can’t either. The info.plist is so:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>NSCameraUsageDescription</key>
    <string>Para tirar a foto precisamos de acesso a camera</string>
</dict>
</plist>

I am using Xcode 9.2 and running Iphone 8 emulator.

Could someone help me?

Grateful

1 answer

0


You need to add permissions to the file Info.plist..

Camera:

Key       :  Privacy - Camera Usage Description   
Value     :  $(PRODUCT_NAME) camera use

Photo:

Key       :  Privacy - Photo Library Usage Description    
Value     :  $(PRODUCT_NAME) photo use
  • I was doing this but it didn’t work, so I tried to test it through an iphone instead of the iphone emulator and it worked. It just doesn’t work on the emulator here for me.

  • @Open which version of Swift and iOS you are using ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.