Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: When mixing Flutter and iOS, use frameworks( https://docs.flutter.cn/add-to-app/ios/project-setup )Method integration #1422

Open
2 of 5 tasks
Koenger opened this issue Dec 18, 2024 · 0 comments

Comments

@Koenger
Copy link

Koenger commented Dec 18, 2024

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Windows

Steps to reproduce

  1. When mixing Flutter and iOS, use frameworks( https://docs.flutter.cn/add-to-app/ios/project-setup )Method integration

  2. Added to info. plist
    NSBluetoothAlwaysUsageDescription
    message
    NSBluetoothPeripheralUsageDescription
    message
    NSCameraUsageDescription
    message
    NSLocationAlwaysAndWhenInUseUsageDescription
    message
    NSLocationAlwaysUsageDescription
    message
    NSLocationUsageDescription
    message
    NSLocationWhenInUseUsageDescription
    message
    NSMicrophoneUsageDescription
    message
    NSPhotoLibraryAddUsageDescription
    message
    NSPhotoLibraryUsageDescription
    message
    NSRemindersUsageDescription
    message
    NSUserTrackingUsageDescription
    message

  3. And added it to the Podfile
    post_install do |installer|
    installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|

    user_target_xcconfig.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
    '$(inherited)',
    ## dart: PermissionGroup.calendar
    #'PERMISSION_EVENTS=1',
    ## dart: PermissionGroup.reminders
    #'PERMISSION_REMINDERS=1',
    ## dart: PermissionGroup.contacts
    #'PERMISSION_CONTACTS=1',
    ## dart: PermissionGroup.speech
    #'PERMISSION_SPEECH_RECOGNIZER=1',

    # dart: PermissionGroup.bluetooth 
    'PERMISSION_BLUETOOTH=1',
    # dart: PermissionGroup.appTrackingTransparency
    'PERMISSION_APP_TRACKING_TRANSPARENCY=1',
    ## dart: PermissionGroup.camera 
    'PERMISSION_CAMERA=1',
    ## dart: PermissionGroup.microphone 
    'PERMISSION_MICROPHONE=1',
    ## dart: PermissionGroup.photos
    'PERMISSION_PHOTOS=1',
    ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse] 
    'PERMISSION_LOCATION=1',
    ## dart: PermissionGroup.notification 
    'PERMISSION_NOTIFICATIONS=1',
    ## dart: PermissionGroup.mediaLibrary 
    'PERMISSION_MEDIA_LIBRARY=1',
    ## dart: PermissionGroup.sensors 
    'PERMISSION_SENSORS=1',
    ## dart: PermissionGroup.criticalAlerts
    'PERMISSION_CRITICAL_ALERTS=1',
    

    ]

    config.build_settings['ENABLE_BITCODE'] = 'NO'
    if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 13.0
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
    end
    end
    end
    end
    But during runtime, it keeps returning returning PermissionStatus.patentlyDenied

Expected results

PermissionStatus.granted

Actual results

returning PermissionStatus.patentlyDenied

Code sample

static checkPermission(
{required List permissionList,
String? errMsg,
VoidCallback? onSuccess,
VoidCallback? onFailed,
VoidCallback? goSetting}) async {
List newPermissionList = [];

for (Permission permission in permissionList) {
  PermissionStatus status = await permission.status;

  if (!status.isGranted) {
    newPermissionList.add(permission);
  }
}

if (newPermissionList.isNotEmpty) {
  PermissionStatus permissionStatus =
      await requestPermission(newPermissionList);
  switch (permissionStatus) {
    case PermissionStatus.denied:
      onFailed != null ? onFailed() : defaultCall("message");
      break;

    case PermissionStatus.granted:
      onSuccess != null ? onSuccess() : defaultCall("message");
      break;

    case PermissionStatus.restricted:
    case PermissionStatus.limited:
    case PermissionStatus.permanentlyDenied:
      goSetting != null ? goSetting() : await openAppSettings();
      break;
    case PermissionStatus.provisional:
    // TODO: Handle this case.
  }
} else {
  onSuccess != null ? onSuccess() : defaultCall("message");
}

}

static Future requestPermission(
List permissionList) async {
Map<Permission, PermissionStatus> statuses = await permissionList.request();
PermissionStatus currentPermissionStatus = PermissionStatus.granted;
statuses.forEach((key, value) {
if (!value.isGranted) {
currentPermissionStatus = value;
return;
}
});
return currentPermissionStatus;
}

Screenshots or video

Screenshots or video demonstration

[Upload media here]

Version

permission_handler: 11.3.1

Flutter Doctor output

Doctor output

[✓] Flutter (Channel stable, 3.22.3, on macOS 14.5 23F79 darwin-arm64, locale
zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.96.0)
[✓] Connected device (4 available)

@Koenger Koenger changed the title [Bug]: [Bug]: When mixing Flutter and iOS, use frameworks( https://docs.flutter.cn/add-to-app/ios/project-setup )Method integration Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant