flutter-permission-handler icon indicating copy to clipboard operation
flutter-permission-handler copied to clipboard

[app-to-app] Request permission failed after integrating flutter framework

Open zhongxunchao opened this issue 2 years ago • 8 comments

💬 Questions and Help

I build iOS framework with command flutter build ios-framework, and my business contains Camera Permission Request. After the framework is integrated, the permission request failed. I know I can add config in Podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    
    target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
      '$(inherited)',
      #dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
      'PERMISSION_LOCATION=1',
      'PERMISSION_PHOTOS=1',
      'PERMISSION_CAMERA=1'
      ]
    end
  end
end

But if the flutter project is built as framework, it won't work, because it won't add the right macro such as PERMISSION_LOCATION=1 to the flutter target. What should I do?

zhongxunchao avatar Apr 23 '23 03:04 zhongxunchao

I am having the same issue -> https://github.com/Baseflow/flutter-permission-handler/issues/956

vanlooverenkoen avatar May 03 '23 12:05 vanlooverenkoen

I've labeled this as an enhancement. Related to https://github.com/Baseflow/flutter-permission-handler/issues/956 and https://github.com/Baseflow/flutter-permission-handler/issues/682

TimHoogstrate avatar Aug 23 '23 07:08 TimHoogstrate

We've had some trials and errors, and finally made it. The key regarding add-to app is you must edit podfile in your existing ios app, not the one in the flutter module. Hope you guys have good luck.

jinsubkim-newin avatar Aug 28 '23 08:08 jinsubkim-newin

We have done that as well, for us that doesn't work. 🤷

vanlooverenkoen avatar Aug 28 '23 08:08 vanlooverenkoen

Could you try to edit podfile in the flutter module too? I've checked the code and found we added some source code of permissions in both of podfiles.

jinsubkim-newin avatar Aug 28 '23 08:08 jinsubkim-newin

I have tried:

  • updating podfile of the host app
  • updating podfile of flutter module
  • updating podfile of the host app & flutter module.

None of them worked for us

vanlooverenkoen avatar Aug 28 '23 08:08 vanlooverenkoen

Same issue. I use Flutter Module Project to build iOS Frameworks, then add these frameworks to my Native iOS Example App, everything works fine except permission. When I call PermissionStatus status = await Permission.microphone.request();, I get a PermissionStatus.permanentlyDenied.

I find @jinsubkim-newin 's answer, and it works!

  1. Add Privacy - Microphone Usage Description in Native iOS Example App's Info.plist
  2. Find ".ios" folder(a hidden folder) in Flutter Module Project's folder. Open "Podfile" inside ".ios" and edit like this:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    
    # flutter permission_handler required.
    target.build_configurations.each do |config|
      # Xcode 14.3 remove arc folder, need update deployment_target version.
      # ref: https://blog.csdn.net/crasowas/article/details/129901398.
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
      '$(inherited)',
      ## dart: PermissionGroup.microphone
      'PERMISSION_MICROPHONE=1',
      ]
    end
  end
end
  1. Flutter Module Project call flutter build ios-framework --output=framework/ to build iOS Frameworks.
  2. Add these new frameworks to my Native iOS Example App, and works fine. System permission dialogue shows up when I first call PermissionStatus status = await Permission.microphone.request();

Hope this helps.

pilgrim1385 avatar Nov 08 '23 14:11 pilgrim1385

Same issue. I use Flutter Module Project to build iOS Frameworks, then add these frameworks to my Native iOS Example App, everything works fine except permission. When I call PermissionStatus status = await Permission.microphone.request();, I get a PermissionStatus.permanentlyDenied.

I find @jinsubkim-newin 's answer, and it works!

  1. Add Privacy - Microphone Usage Description in Native iOS Example App's Info.plist
  2. Find ".ios" folder(a hidden folder) in Flutter Module Project's folder. Open "Podfile" inside ".ios" and edit like this:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    
    # flutter permission_handler required.
    target.build_configurations.each do |config|
      # Xcode 14.3 remove arc folder, need update deployment_target version.
      # ref: https://blog.csdn.net/crasowas/article/details/129901398.
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
      '$(inherited)',
      ## dart: PermissionGroup.microphone
      'PERMISSION_MICROPHONE=1',
      ]
    end
  end
end
  1. Flutter Module Project call flutter build ios-framework --output=framework/ to build iOS Frameworks.
  2. Add these new frameworks to my Native iOS Example App, and works fine. System permission dialogue shows up when I first call PermissionStatus status = await Permission.microphone.request();

Hope this helps.

Is there any solution for this problem. i tried this also.not working.

SL-ChaNuka avatar Feb 07 '24 07:02 SL-ChaNuka