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]: Bluetooth permission on iOS permanently denied #1333

Open
3 of 5 tasks
lazarvgd opened this issue Jun 10, 2024 · 10 comments
Open
3 of 5 tasks

[Bug]: Bluetooth permission on iOS permanently denied #1333

lazarvgd opened this issue Jun 10, 2024 · 10 comments
Assignees

Comments

@lazarvgd
Copy link

lazarvgd commented Jun 10, 2024

Please check the following before submitting a new issue.

Please select affected platform(s)

  • Android
  • iOS
  • Windows

Steps to reproduce

  1. add the dependency to pubspec.yaml
  2. add permission for BT in info.plist
  3. update podfile with the following code:
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
              '$(inherited)',

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

            ]
  1. request permission in the code as following:
  @override
  Future<bool> getBluetoothPermission() async {
   final PermissionStatus  status = await Permission.bluetoothConnect.request();
    return status == PermissionStatus.granted;
  }

Expected results

When the bt is enabled in Settings-> <app_name> -> Bluetooth, result of the code should be "granted", when it is disabled it should be some variant of denied.

Actual results

The actual result is that the code always return permanentlyDenied.

Code sample

Code sample
  @override
  Future<bool> getBluetoothPermission() async {
   final PermissionStatus  status = await Permission.bluetoothConnect.request();
    return status == PermissionStatus.granted;
  }

Screenshots or video

Screenshots or video demonstration

image
Screenshot 2024-06-10 at 10 21 53

Version

11.3.1

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.22.1, on macOS 14.5 23F79 darwin-arm64, locale en-GB)
    • Flutter version 3.22.1 on channel stable at /Users/lj/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (3 weeks ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/lj/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (5 available)
    • SM S911B (mobile)               • RFCW202MYCV               • android-arm64  • Android 14 (API 34)
    • iPhone-J1HPW2QJMW (mobile)      • 00008110-001E14E90E3A401E • ios            • iOS 17.5.1 21F90
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 125.0.6422.142

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Tested on iOS 17.5.1, iphone 14.

@ritheshSalyan
Copy link

I too had this issue.

The problem in my case was, that I had not run pod install after modifying podfile.

Solution: reinstall the pod.

  1. Move to ios folder
    cd ios
  2. Run the command pod install.

this solved my issue.

@lazarvgd
Copy link
Author

The proposed solution does not work.

@TimHoogstrate
Copy link
Contributor

Dear @lazarvgd,

Does this also happen while you test this in the Example app?

Kins regards,

@TimHoogstrate TimHoogstrate self-assigned this Jun 28, 2024
@TimHoogstrate TimHoogstrate added the status: needs more info We need more information before we can continue work on this issue. label Jun 28, 2024
@tilongzs
Copy link

tilongzs commented Jul 2, 2024

I have encountered the same problem.Sorry, I am not good at iOS compilation and the Example app cannot be compiled successfully.
Tested on iOS 16.7.7, iphone 8.

@github-actions github-actions bot removed the status: needs more info We need more information before we can continue work on this issue. label Jul 2, 2024
@Phenek
Copy link

Phenek commented Jul 10, 2024

Specific App Settings Permission
image

this bluetooth permission request returns permanentlyDenied status

      var status1 = await Permission.bluetooth.request();

In fact Permission is granted, I can scan nearby bluetooth devices!

And the example app return a 'Granted' answer:
image


It seems related to our own project...

So I tried to put the project reference in pubspec.yaml

  permission_handler:
    path: ../../flutter-permission-handler/permission_handler

I still got a permanentlyDenied status for my application, and it does not stop on breakpoint in file
flutter-permission-handler/permission_handler/lib/permission_handler.dart

If you have any advice to debug this?
let me know.

@TimHoogstrate
Copy link
Contributor

I have encountered the same problem.Sorry, I am not good at iOS compilation and the Example app cannot be compiled successfully. Tested on iOS 16.7.7, iphone 8.

The example project compiles correctly.

@Phenek,

Please file a separate issue. Also check the correct plist entries and the pod file entries. Then run flutter build ios.

Kind regards,

@TimHoogstrate TimHoogstrate added the status: needs more info We need more information before we can continue work on this issue. label Aug 5, 2024
@fufylev
Copy link

fufylev commented Aug 7, 2024

same issue for me - spent already many hrs on this but still fail to solve the issue. A always get Permission.denied when in fact on the devise the permission is granted.

Any updates on this?
Flutter 3.22.2
iOS 17.6

@github-actions github-actions bot removed the status: needs more info We need more information before we can continue work on this issue. label Aug 7, 2024
@TimHoogstrate
Copy link
Contributor

Dear @fufylev,

Please file a separate issue. And follow the instructions in the README. You probably forgot to update the podfile or the plist entries.

Kind regards,

@TimHoogstrate TimHoogstrate added the status: needs more info We need more information before we can continue work on this issue. label Aug 7, 2024
@Hoai-Phong
Copy link

@fufylev
When I have granted permission on the app, why does it still show as permanentlyDenied?
Is there any way to fix it?
image

image

permission_handler: ^11.3.1

@github-actions github-actions bot removed the status: needs more info We need more information before we can continue work on this issue. label Aug 20, 2024
@TimHoogstrate TimHoogstrate added the status: needs more info We need more information before we can continue work on this issue. label Aug 20, 2024
@Phenek
Copy link

Phenek commented Aug 23, 2024

@TimHoogstrate Sorry, but why do I need to file a separate issue?
This issue is what it is. No need to duplicate, don't you think?

My issue is exactly the title of this one.
Bluetooth permission on iOS permanently denied, even when in fact on the devise the permission is granted.

So I tried to put the project as code reference in pubspec.yaml

  permission_handler:
    path: ../../flutter-permission-handler/permission_handler

but I could not debug, because breakpoints don't stop on my Visual Studio Code. I don't why?
Can you please, share you debug advice @TimHoogstrate

@github-actions github-actions bot removed the status: needs more info We need more information before we can continue work on this issue. label Aug 23, 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

7 participants