flutter – Tips on how to ask person for location permission with Geolocator in iOS?

0
19
flutter – Tips on how to ask person for location permission with Geolocator in iOS?


as seen in plenty of different questions, I am unable to make the Geolocator package deal return a permission.granted when working with iOS. With android every part works fantastic however with iOS it at all times returns permission.permanentlyDenied, and it does not even present the immediate to permit location. I’m utilizing permission_handler: ^11.3.1 and geolocator: ^13.0.1.

I’m requesting the situation within the following approach:

Future requestLocationAccess() async {
    remaining standing = await Permission.location.request();

    if (standing == PermissionStatus.permanentlyDenied) {
      Permission.location.onPermanentlyDeniedCallback(() {});
    }
    state = state.copyWith(location: standing);

    _checkPermissionState(standing); // this features sends person to openSettingsScreen 
  }

this is my Information.plist





    CFBundleDevelopmentRegion
    $(DEVELOPMENT_LANGUAGE)
    CFBundleDisplayName
    SAGA
    CFBundleExecutable
    $(EXECUTABLE_NAME)
    CFBundleIdentifier
    $(PRODUCT_BUNDLE_IDENTIFIER)
    CFBundleInfoDictionaryVersion
    6.0
    CFBundleName
    pjecz_saga_app
    CFBundlePackageType
    APPL
    CFBundleShortVersionString
    $(FLUTTER_BUILD_NAME)
    CFBundleSignature
    ????
    CFBundleVersion
    $(FLUTTER_BUILD_NUMBER)
    LSRequiresIPhoneOS
    
    UILaunchStoryboardName
    LaunchScreen
    UIMainStoryboardFile
    Principal
    UISupportedInterfaceOrientations
    
        UIInterfaceOrientationPortrait
        UIInterfaceOrientationLandscapeLeft
        UIInterfaceOrientationLandscapeRight
    
    UISupportedInterfaceOrientations~ipad
    
        UIInterfaceOrientationPortrait
        UIInterfaceOrientationPortraitUpsideDown
        UIInterfaceOrientationLandscapeLeft
        UIInterfaceOrientationLandscapeRight
    
    CADisableMinimumFrameDurationOnPhone
    
    UIApplicationSupportsIndirectInputEvents
    
    NSCameraUsageDescription
    Necesitamos acceso a la camara para tomar fotografías.
    NSPhotoLibraryUsageDescription
    Necesitamos acceso a la galería para seleccionar fotografías.
    NSAppleMusicUsageDescription
    Necesitamos acceso a la biblioteca multimedia
    NSLocationUsageDescription
    Necesitamos acceso a su ubicación para agregarlas a las fotografías.
    NSLocationAlwaysUsageDescription
    Necesitamos acceso a su ubicación para agregarlas a las fotografías.
    NSLocationWhenInUseUsageDescription
    Necesitamos acceso a su ubicación para agregarlas a las fotografías.
    NSLocationAlwaysAndWhenInUseUsageDescription
    Necesitamos acceso a su ubicación para agregarlas a las fotografías.
    NSLocationTemporaryUsageDescriptionDictionary
    
        TemporaryPreciseAccuracy
        La aplicación requiere acceso a la ubicación precisa para vincularla con la fotografía.
    
    LSApplicationQueriesSchemes
    
    sms
    tel
    


this is my Podfile, you’ll be able to see there’s plenty of code commented as a result of I’ve tried plenty of stuff and may’t get it to work.

# Uncomment this line to outline a worldwide platform on your venture
platform :ios, '14.0'

# CocoaPods analytics sends community stats synchronously affecting flutter construct latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

venture 'Runner', {
  'Debug' => :debug,
  'Profile' => :launch,
  'Launch' => :launch,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.be a part of('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  until File.exist?(generated_xcode_build_settings_path)
    elevate "#{generated_xcode_build_settings_path} should exist. For those who're operating pod set up manually, be sure that flutter pub get is executed first"
  finish

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT=(.*)/)
    return matches[1].strip if matches
  finish
  elevate "FLUTTER_ROOT not present in #{generated_xcode_build_settings_path}. Attempt deleting Generated.xcconfig, then run flutter pub get"
finish

require File.expand_path(File.be a part of('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

goal 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  goal 'RunnerTests' do
    inherit! :search_paths
  finish
finish

# post_install do |installer|
#   installer.pods_project.targets.every do |goal|
#     flutter_additional_ios_build_settings(goal)
#     goal.build_configurations.every do |config|
#       config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
#     finish
#   finish
# finish



# post_install do |installer|
#   installer.pods_project.targets.every do |goal|
#     if goal.title == "geolocator_apple"
#       goal.build_configurations.every do |config|
#         config.build_settings ['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 
#         'BYPASS_PERMISSION_LOCATION_ALWAYS=1',
#         'PERMISSION_CAMERA=1',
#         'PERMISSION_PHOTOS=1',
#         'PERMISSION_LOCATION_WHENINUSE=1',
#         'PERMISSION_MEDIA_LIBRARY=1'
#       ]
#       finish
#     finish
#     flutter_additional_ios_build_settings(goal)
#   finish
# finish

# post_install do |installer|
#   installer.pods_project.targets.every do |goal|
    
#     # Permisos específicos para geolocator_apple
#     # if goal.title == "geolocator_apple"
#     #   goal.build_configurations.every do |config|
#     #     config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)',
#     #       'BYPASS_PERMISSION_LOCATION_ALWAYS=1',
#     #       'PERMISSION_LOCATION_WHENINUSE=1',
#     #       'PERMISSION_LOCATION=1',
#     #       'PERMISSION_CAMERA=1',
#     #       'PERMISSION_PHOTOS=1',
#     #       'PERMISSION_MEDIA_LIBRARY=1'
#     #     ]
#     #   finish
#     # finish

#     # Configuración común para todos los targets
#     goal.build_configurations.every do |config|
#       config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
#     finish

#     # Ajustes adicionales de Flutter
#     flutter_additional_ios_build_settings(goal)
#   finish
# finish


post_install do |installer|
  installer.pods_project.targets.every do |goal|
    flutter_additional_ios_build_settings(goal)

    goal.build_configurations.every do |config|
      # You possibly can take away unused permissions right here
      # for extra data: https://github.com/Baseflow/flutter-permission-handler/blob/principal/permission_handler_apple/ios/Courses/PermissionHandlerEnums.h
      # e.g. when you do not want digital camera permission, simply add 'PERMISSION_CAMERA=0'
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',

        ## dart: PermissionGroup.calendar
        'PERMISSION_EVENTS=0',
        
        ## dart: PermissionGroup.calendarFullAccess
        'PERMISSION_EVENTS_FULL_ACCESS=0',

        ## dart: PermissionGroup.reminders
        'PERMISSION_REMINDERS=0',

        ## dart: PermissionGroup.contacts
        'PERMISSION_CONTACTS=0',

        ## dart: PermissionGroup.camera
        'PERMISSION_CAMERA=1',

        ## dart: PermissionGroup.microphone
        'PERMISSION_MICROPHONE=0',

        ## dart: PermissionGroup.speech
        'PERMISSION_SPEECH_RECOGNIZER=0',

        ## dart: PermissionGroup.photos
        'PERMISSION_PHOTOS=1',

        ## The 'PERMISSION_LOCATION' macro enables the `locationWhenInUse` and `locationAlways` permission. If
        ## the application only requires `locationWhenInUse`, only specify the `PERMISSION_LOCATION_WHENINUSE`
        ## macro.
        ##
        ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
        'PERMISSION_LOCATION=1',
        'PERMISSION_LOCATION_WHENINUSE=0',

        ## dart: PermissionGroup.notification
        'PERMISSION_NOTIFICATIONS=0',

        ## dart: PermissionGroup.mediaLibrary
        'PERMISSION_MEDIA_LIBRARY=1',

        ## dart: PermissionGroup.sensors
        'PERMISSION_SENSORS=0',

        ## dart: PermissionGroup.bluetooth
        'PERMISSION_BLUETOOTH=0',

        ## dart: PermissionGroup.appTrackingTransparency
        'PERMISSION_APP_TRACKING_TRANSPARENCY=0',

        ## dart: PermissionGroup.criticalAlerts
        'PERMISSION_CRITICAL_ALERTS=0',

        ## dart: PermissionGroup.criticalAlerts
        'PERMISSION_ASSISTANT=0',
      ]

    finish
  finish
finish

LEAVE A REPLY

Please enter your comment!
Please enter your name here