zoontek / react-native-permissions

An unified permissions API for React Native on iOS, Android and Windows.
MIT License
4.1k stars 836 forks source link

Invalid ios permission "location". Must be one of #400

Closed frtlec closed 4 years ago

frtlec commented 4 years ago

image

async konumAl(refresh = false) {
    try {
      const pastObservation = this.props.navigation.getParam("pastObservation");
      if (!pastObservation && !refresh) {

        const permission = await Permissions.request("location");
        if (permission !== "authorized") {
          alert("lütfen konum izinlerini verin.");
          return false;
        }

        const { coords } = await this.getCurrentPosition();
        if (coords.latitude == 0 || coords.longitude == 0) {
          await this.gpsAcMesaj();

        } else {

        }
        this.props.GozlemStore.lokasyonAdd(coords.latitude, coords.longitude);

      }

    } catch (error) {
      //console.log(error);
      alert(error);
    }

  }
  getCurrentPosition() {
    try {
      let x = new Promise((resolve, reject) => {
        navigator.geolocation.getCurrentPosition(
          position => {
            resolve(position);
          },
          error => {
            this.gpsAcMesaj();
          }
        ),
          reject,
          {
            enableHighAccuracy: true,
            timeout: 5000
          };
      });
      return x;
    } catch (error) {
      alert(error );
      this.gpsAcMesaj();
    }
  }

podfile

`# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'Trakus' do
  # Comment the next line if you don't want to use dynamic frameworks
  #use_frameworks!
  platform :ios, '9.0'
  # Pods for Trakus
  rn_path = '../node_modules/react-native'
# Pods for Trakus
use_modular_headers!
pod 'React', path: rn_path, subspecs: [
  'Core',
  'CxxBridge',
  'DevSupport',
  'RCTActionSheet',
  'RCTAnimation',
  'RCTGeolocation',
  'RCTImage',
  'RCTLinkingIOS',
  'RCTNetwork',
  'RCTSettings',
  'RCTText',
  'RCTVibration',
  'RCTWebSocket'
],:modular_headers => false
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga',:modular_headers => false
pod 'RNPermissions', :path => '../node_modules/react-native-permissions',:modular_headers => false

permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral.podspec"
pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars.podspec"
pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts.podspec"
pod 'Permission-FaceID', :path => "#{permissions_path}/FaceID.podspec"
pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec"
pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec"
pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
pod 'Permission-Motion', :path => "#{permissions_path}/Motion.podspec"
pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec"
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
pod 'Permission-Reminders', :path => "#{permissions_path}/Reminders.podspec"
pod 'Permission-Siri', :path => "#{permissions_path}/Siri.podspec"
pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition.podspec"
pod 'Permission-StoreKit', :path => "#{permissions_path}/StoreKit.podspec"
# Third party deps podspec link
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec',:modular_headers => false
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec',:modular_headers => false
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec',:modular_headers => false
post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

end
`

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>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>Trakus</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>NSAppleMusicUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSBluetoothAlwaysUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSBluetoothPeripheralUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSCalendarsUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSCameraUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSContactsUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSFaceIDUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSMotionUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSRemindersUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSSiriUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>NSSpeechRecognitionUsageDescription</key>
    <string>YOUR TEXT</string>
    <key>UIAppFonts</key>
    <array>
        <string>AntDesign.ttf</string>
        <string>Entypo.ttf</string>
        <string>EvilIcons.ttf</string>
        <string>Feather.ttf</string>
        <string>FontAwesome.ttf</string>
        <string>FontAwesome5_Brands.ttf</string>
        <string>FontAwesome5_Regular.ttf</string>
        <string>FontAwesome5_Solid.ttf</string>
        <string>Fontisto.ttf</string>
        <string>Foundation.ttf</string>
        <string>Ionicons.ttf</string>
        <string>MaterialCommunityIcons.ttf</string>
        <string>MaterialIcons.ttf</string>
        <string>Octicons.ttf</string>
        <string>SimpleLineIcons.ttf</string>
        <string>Zocial.ttf</string>
        <string>icomoon.ttf</string>
    </array>
    <key>UIBackgroundModes</key>
    <array>
        <string>audio</string>
        <string>bluetooth-central</string>
        <string>bluetooth-peripheral</string>
        <string>external-accessory</string>
        <string>fetch</string>
        <string>location</string>
        <string>processing</string>
        <string>remote-notification</string>
        <string>voip</string>
    </array>
    <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/>
</dict>
</plist>

info

nfo React Native Environment Info: System: OS: macOS 10.15.2 CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz Memory: 550.83 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 13.6.0 - /usr/local/bin/node npm: 6.13.4 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 IDEs: Xcode: 11.3/11C29 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.8 => 0.59.8 npmGlobalPackages: react-native-cli: 2.0.1

zoontek commented 4 years ago

Just follow the documentation please (read it entirely before submitting an issue)

https://github.com/react-native-community/react-native-permissions/blob/master/README.md