Baseflow / flutter-permission-handler

Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
https://baseflow.com
MIT License
2.02k stars 840 forks source link

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

Open zhongxunchao opened 1 year ago

zhongxunchao commented 1 year ago

💬 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?

vanlooverenkoen commented 1 year ago

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

TimHoogstrate commented 1 year ago

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

jinsubkim-newin commented 1 year ago

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.

vanlooverenkoen commented 1 year ago

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

jinsubkim-newin commented 1 year ago

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.

vanlooverenkoen commented 1 year ago

I have tried:

None of them worked for us

pilgrim1385 commented 10 months ago

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
  3. Flutter Module Project call flutter build ios-framework --output=framework/ to build iOS Frameworks.
  4. 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.

SL-ChaNuka commented 7 months ago

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.