React-native-permissions: Invalid ios permission "photo"

Created on 8 Oct 2019  路  7Comments  路  Source: zoontek/react-native-permissions

"react": "16.9.0",
"react-native": "0.61.2",

Screen Shot 2019-10-08 at 5 42 05 PM

Info.plist

<?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>NSMicrophoneUsageDescription</key>
    <string>$(PRODUCT_NAME) would like to use your microphone (for videos)</string>
    <key>NSAppleMusicUsageDescription</key>
    <string>$(PRODUCT_NAME) would like to save photos to your photo gallery</string>
    <key>NSPhotoLibraryAddUsageDescription</key>
    <string>$(PRODUCT_NAME) would like to save photos to your photo gallery</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>$(PRODUCT_NAME) would like to save photos to your photo gallery</string>
    <key>NSCameraUsageDescription</key>
    <string>$(PRODUCT_NAME) would like to use your camera</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>bloomhigh</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>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>localhost</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string></string>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>UIAppFonts</key>
    <array>
        <string>OpenSans-Bold.ttf</string>
        <string>OpenSans-BoldItalic.ttf</string>
        <string>OpenSans-ExtraBold.ttf</string>
        <string>OpenSans-ExtraBoldItalic.ttf</string>
        <string>OpenSans-Italic.ttf</string>
        <string>OpenSans-Light.ttf</string>
        <string>OpenSans-LightItalic.ttf</string>
        <string>OpenSans-Regular.ttf</string>
        <string>OpenSans-SemiBold.ttf</string>
        <string>OpenSans-SemiBoldItalic.ttf</string>
        <string>proximanova-bold.otf</string>
        <string>proximanova-medium.otf</string>
        <string>proximanova-regular.otf</string>
        <string>proximanova-semibold.otf</string>
    </array>
</dict>
</plist>

Most helpful comment

Sorry. It was my fault. I had PERMISSION.IOS.PHOTO_LIBRARY instead PERMISSIONS.IOS.PHOTO_LIBRARY

Thanks

All 7 comments

So what's the code look like, that throws this error?
What version of the library are you?

(in other words - pretend you are troubleshooting this for a colleague, what info would you need?)

How's it work when you use react-native-permissions::PERMISSION.IOS.PHOTO_LIBRARY symbol

https://github.com/react-native-community/react-native-permissions/blob/master/ios/PhotoLibrary/RNPermissionHandlerPhotoLibrary.m#L12

I am using: "react-native-permissions": "^2.0.0"
I am getting error on this line: let permResult = await Permissions.request('photo');
same error on: PERMISSION.IOS.PHOTO_LIBRARY

I have followed all the steps in docs.

thanks

This rolls through the permissions constant type: https://github.com/react-native-community/react-native-permissions/blob/master/example/App.tsx#L87

That is pulled from here https://github.com/react-native-community/react-native-permissions/blob/master/example/App.tsx#L28 / https://github.com/react-native-community/react-native-permissions/blob/master/example/App.tsx#L23

which is coming from here https://github.com/react-native-community/react-native-permissions/blob/master/src/constants.ts#L44

So, something you are doing is wrong - it definitely all works.

I suppose you could try the raw string (but the correct one for the platform - not 'photo') if you wanted - but I'd figure out why your javascript isn't hooking things up?

also just running the example confirms it works - I'd also do that as a local proof-of-function before attempting to integrate

@givik Do you import PERMISSIONS from the module?

Sorry. It was my fault. I had PERMISSION.IOS.PHOTO_LIBRARY instead PERMISSIONS.IOS.PHOTO_LIBRARY

Thanks

This is one of those totally understandable mistakes, but also - you will love Typescript :-)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

al-shivani picture al-shivani  路  25Comments

vvsevolodovich picture vvsevolodovich  路  24Comments

ppdbxdawj picture ppdbxdawj  路  18Comments

note89 picture note89  路  35Comments

ozturkilgim picture ozturkilgim  路  31Comments