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

Using requestBluetoothAuthorizattion when state is unauthorized throws a native API misuse error on iOS #477

Closed
5 tasks done
andreacab2 opened this issue Aug 26, 2022 · 4 comments
Labels
bug Something isn't working properly ios relates to iOS platform runtime issue An issue related to app runtime

Comments

@andreacab2
Copy link

andreacab2 commented Aug 26, 2022

Bug report

CHECKLIST

  • I have reproduced the issue using the example project or provided the necessary information to reproduce the issue.
  • I have checked that no similar issues (open or closed) already exist.

Current behavior:

When you click on "Request Bluetooth Authorization" when the bluetooth state shows "UNAUTHORIZED", you are not asked to authorize anymore and in the native logs, it fails with a native error API MISUSE telling that the CBCentralManager needs to be in powered_on state (look for MISUSE in the native logs trail pasted below).

I have used the example code of the cordova-diagnostic-plugin and was able to reliably reproduce the issue.

Expected behavior:

To my understanding, using diagnostic.requestBluetoothAuthorization should ask again for authorization specifically in the case where the bluetooth state is UNAUTHORIZED to change it to AUTHORIZED

Steps to reproduce:

  1. Install this plugin example on an ios phone
  2. Deny the bluetooth permission for this plugin example's app
  3. launch this plugin example's app
  4. Click on monitor bluetooth change
  5. Blutooth state should be UNAUTHORIZED, Bluetooth authorization status should be DENIED_ALWAYS
  6. Click on "request bluetooth authorization", nothing happens.
  7. Check the native logs, using xcode for example, you can see the API MISUSE logs stating that this call to "request bluetooth authorization" can be done only when the state is powered_on

Screenshots

IMG_3821

Environment information

  • Cordova CLI version
    • 11.0.0
  • Cordova platform version
    • ios 6.2.0
  • Plugins & versions installed in project (including this plugin)
    cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter"
    cordova-plugin-camera 6.0.0 "Camera"
    cordova-plugin-device 2.0.3 "Device"
    cordova-plugin-file 7.0.0 "File"
    cordova-plugin-geolocation 4.1.0 "Geolocation"
    cordova-plugin-statusbar 3.0.0 "StatusBar"
    cordova.plugins.diagnostic 7.1.0 "Diagnostic"
    
  • Dev machine OS and version, e.g.
    • OSX
      ProductName:	macOS
      ProductVersion:	11.6.4
      BuildVersion:	20G417
      

Runtime issue

  • Device details
    • iPhone SE
  • OS details
    • iOS 15.3.1

iOS build issue:

  • Node JS version
    • 16.13.0
  • XCode version
    • 13.2.1

Related code:

insert any relevant code here such as plugin API calls / input parameters

Console output

console output
2022-08-26 11:09:22.043061+0200 Diagnostic plugin example[11240:3532018] Apache Cordova native platform version 6.2.0 is starting.
2022-08-26 11:09:22.043144+0200 Diagnostic plugin example[11240:3532018] Multi-tasking -> Device: YES, App: YES
2022-08-26 11:09:22.048447+0200 Diagnostic plugin example[11240:3532018] Could not load the "LaunchStoryboard" image referenced from a nib in the bundle with identifier "cordova.plugins.diagnostic.example"
2022-08-26 11:09:22.158084+0200 Diagnostic plugin example[11240:3532018] The preference key "AllowNewWindows" is not defined and will default to "FALSE"
2022-08-26 11:09:22.196959+0200 Diagnostic plugin example[11240:3532018] The preference key "MediaPlaybackAllowsAirPlay" is not defined and will default to "TRUE"
2022-08-26 11:09:22.199934+0200 Diagnostic plugin example[11240:3532018] The preference key "AllowBackForwardNavigationGestures" is not defined and will default to "FALSE"
2022-08-26 11:09:22.200000+0200 Diagnostic plugin example[11240:3532018] The preference key "Allow3DTouchLinkPreview" is not defined and will default to "TRUE"
2022-08-26 11:09:22.200030+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine will reload WKWebView if required on resume
2022-08-26 11:09:22.200055+0200 Diagnostic plugin example[11240:3532018] Using WKWebView
2022-08-26 11:09:22.200600+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][console] 0.133038ms
2022-08-26 11:09:22.200877+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][handleopenurl] 0.095963ms
2022-08-26 11:09:22.202201+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][intentandnavigationfilter] 1.253963ms
2022-08-26 11:09:22.202313+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][gesturehandler] 0.038981ms
2022-08-26 11:09:22.202610+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][diagnostic] 0.263095ms
2022-08-26 11:09:22.203813+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][diagnostic_location] 1.152992ms
2022-08-26 11:09:22.203881+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][diagnostic_bluetooth] 0.028968ms
2022-08-26 11:09:22.204058+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][diagnostic_wifi] 0.117898ms
2022-08-26 11:09:22.204129+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][diagnostic_camera] 0.024915ms
2022-08-26 11:09:22.204198+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][diagnostic_notifications] 0.041008ms
2022-08-26 11:09:22.204422+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][diagnostic_microphone] 0.097990ms
2022-08-26 11:09:22.205893+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][diagnostic_contacts] 1.384974ms
2022-08-26 11:09:22.205977+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][diagnostic_calendar] 0.034094ms
2022-08-26 11:09:22.206016+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][diagnostic_reminders] 0.010967ms
2022-08-26 11:09:22.206270+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][diagnostic_motion] 0.223994ms
2022-08-26 11:09:22.207227+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][file] 0.898004ms
2022-08-26 11:09:22.208484+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][statusbar] 1.208901ms
2022-08-26 11:09:22.208541+0200 Diagnostic plugin example[11240:3532018] [CDVTimer][TotalPluginStartup] 8.208036ms
2022-08-26 11:09:22.356453+0200 Diagnostic plugin example[11240:3532018] The preference key "AutoHideSplashScreen" is not defined and will default to "TRUE"
2022-08-26 11:09:22.380249+0200 Diagnostic plugin example[11240:3532018] Diagnostic[native]: Debug enabled
2022-08-26 11:09:33.306770+0200 Diagnostic plugin example[11240:3532336] Diagnostic[native]: Location authorization status is: not_determined
2022-08-26 11:09:33.307024+0200 Diagnostic plugin example[11240:3532337] Diagnostic[native]: Location accuracy authorization is: reduced
2022-08-26 11:09:33.351905+0200 Diagnostic plugin example[11240:3532334] Diagnostic[native]: Battery level: 100
2022-08-26 11:09:33.352390+0200 Diagnostic plugin example[11240:3532018] THREAD WARNING: ['Diagnostic'] took '44.623291' ms. Plugin should use a background thread.
2022-08-26 11:09:33.352644+0200 Diagnostic plugin example[11240:3532334] Diagnostic[native]: Wifi ON
2022-08-26 11:09:33.353725+0200 Diagnostic plugin example[11240:3532337] Diagnostic[native]: Camera available
2022-08-26 11:09:33.354861+0200 Diagnostic plugin example[11240:3532336] Diagnostic[native]: Camera available
2022-08-26 11:09:33.359136+0200 Diagnostic plugin example[11240:3532351] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:09:33.359378+0200 Diagnostic plugin example[11240:3532351] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:09:33.359688+0200 Diagnostic plugin example[11240:3532351] Diagnostic[native]: Current CPU architecture: ARMv8
2022-08-26 11:09:33.365047+0200 Diagnostic plugin example[11240:3532217] Diagnostic[native]: Calendar event authorization status 2022-08-26 11:09:33.365267+0200 Diagnostic plugin example[11240:3532339] Diagnostic[native]: Camera authorization status is: not_determined
is: not_determined
2022-08-26 11:09:33.366396+0200 Diagnostic plugin example[11240:3532349] Diagnostic[native]: Reminders authorization status is: not_determined
2022-08-26 11:09:33.366633+0200 Diagnostic plugin example[11240:3532342] Diagnostic[native]: Microphone authorization status is: not_determined
2022-08-26 11:09:33.367277+0200 Diagnostic plugin example[11240:3532346] Diagnostic[native]: Address book authorization status is: not_determined
2022-08-26 11:09:33.368984+0200 Diagnostic plugin example[11240:3532343] Diagnostic[native]: Remote notifications authorization status is: not_determined
2022-08-26 11:09:33.371746+0200 Diagnostic plugin example[11240:3532335] Diagnostic[native]: Camera Roll authorization status is: not_determined
2022-08-26 11:09:49.554785+0200 Diagnostic plugin example[11240:3532335] Diagnostic[native]: Bluetooth state changed: State unknown, update imminent.
2022-08-26 11:09:49.559910+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Location authorization status is: not_determined
2022-08-26 11:09:49.560234+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Location accuracy authorization is: reduced
2022-08-26 11:09:49.560666+0200 Diagnostic plugin example[11240:3532335] Diagnostic[native]: Camera authorization status is: not_determined
2022-08-26 11:09:49.561517+0200 Diagnostic plugin example[11240:3532339] Diagnostic[native]: Camera available
2022-08-26 11:09:49.561817+0200 Diagnostic plugin example[11240:3532445] Diagnostic[native]: Battery level: 100
2022-08-26 11:09:49.561872+0200 Diagnostic plugin example[11240:3532446] Diagnostic[native]: Camera available
2022-08-26 11:09:49.563891+0200 Diagnostic plugin example[11240:3532446] Diagnostic[native]: Camera Roll authorization status is: not_determined
2022-08-26 11:09:49.563871+0200 Diagnostic plugin example[11240:3532335] Diagnostic[native]: Wifi ON
2022-08-26 11:09:49.564337+0200 Diagnostic plugin example[11240:3532447] Diagnostic[native]: Bluetooth state changed: State unknown, update imminent.
2022-08-26 11:09:49.564632+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Bluetooth state changed: State unknown, update imminent.
2022-08-26 11:09:49.565048+0200 Diagnostic plugin example[11240:3532446] Diagnostic[native]: Microphone authorization status is: not_determined
2022-08-26 11:09:49.566257+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Bluetooth state is: unknown
2022-08-26 11:09:49.566347+0200 Diagnostic plugin example[11240:3532447] Diagnostic[native]: Address book authorization status is: not_determined
2022-08-26 11:09:49.568107+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Reminders authorization status is: not_determined
2022-08-26 11:09:49.568150+0200 Diagnostic plugin example[11240:3532447] Diagnostic[native]: Calendar event authorization status is: not_determined
2022-08-26 11:09:49.568271+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:09:49.568273+0200 Diagnostic plugin example[11240:3532447] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:09:49.569187+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Current CPU architecture: ARMv8
2022-08-26 11:09:49.573232+0200 Diagnostic plugin example[11240:3532335] Diagnostic[native]: Remote notifications authorization status is: not_determined
2022-08-26 11:09:49.573433+0200 Diagnostic plugin example[11240:3532339] Diagnostic[native]: Location authorization status is: not_determined
2022-08-26 11:09:49.573625+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Location accuracy authorization is: reduced
2022-08-26 11:09:49.574669+0200 Diagnostic plugin example[11240:3532447] Diagnostic[native]: Camera authorization status is: not_determined
2022-08-26 11:09:49.575049+0200 Diagnostic plugin example[11240:3532339] Diagnostic[native]: Camera available
2022-08-26 11:09:49.575293+0200 Diagnostic plugin example[11240:3532446] Diagnostic[native]: Wifi ON
2022-08-26 11:09:49.575364+0200 Diagnostic plugin example[11240:3532453] Diagnostic[native]: Bluetooth state changed: State unknown, update imminent.
2022-08-26 11:09:49.575508+0200 Diagnostic plugin example[11240:3532445] Diagnostic[native]: Bluetooth state changed: State unknown, update imminent.
2022-08-26 11:09:49.575908+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Camera available
2022-08-26 11:09:49.575966+0200 Diagnostic plugin example[11240:3532335] Diagnostic[native]: Battery level: 100
2022-08-26 11:09:49.576198+0200 Diagnostic plugin example[11240:3532454] Diagnostic[native]: Microphone authorization status is: not_determined
2022-08-26 11:09:49.576522+0200 Diagnostic plugin example[11240:3532456] Diagnostic[native]: Calendar event authorization status is: not_determined
2022-08-26 11:09:49.576519+0200 Diagnostic plugin example[11240:3532455] Diagnostic[native]: Address book authorization status is: not_determined
2022-08-26 11:09:49.576667+0200 Diagnostic plugin example[11240:3532457] Diagnostic[native]: Reminders authorization status is: not_determined
2022-08-26 11:09:49.576662+0200 Diagnostic plugin example[11240:3532454] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:09:49.576751+0200 Diagnostic plugin example[11240:3532458] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:09:49.577086+0200 Diagnostic plugin example[11240:3532463] Diagnostic[native]: Current CPU architecture: ARMv8
2022-08-26 11:09:49.579224+0200 Diagnostic plugin example[11240:3532445] Diagnostic[native]: Bluetooth state is: unknown
2022-08-26 11:09:49.582860+0200 Diagnostic plugin example[11240:3532458] Diagnostic[native]: Remote notifications authorization status is: not_determined
2022-08-26 11:09:49.584290+0200 Diagnostic plugin example[11240:3532447] Diagnostic[native]: Camera Roll authorization status is: not_determined
2022-08-26 11:09:49.590680+0200 Diagnostic plugin example[11240:3532018] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:09:49.597675+0200 Diagnostic plugin example[11240:3532458] Diagnostic[native]: Location authorization status is: not_determined
2022-08-26 11:09:49.597839+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Location accuracy authorization is: reduced
2022-08-26 11:09:49.598067+0200 Diagnostic plugin example[11240:3532454] Diagnostic[native]: Camera authorization status is: not_determined
2022-08-26 11:09:49.598248+0200 Diagnostic plugin example[11240:3532454] Diagnostic[native]: Wifi ON
2022-08-26 11:09:49.598429+0200 Diagnostic plugin example[11240:3532454] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:09:49.598500+0200 Diagnostic plugin example[11240:3532454] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:09:49.598547+0200 Diagnostic plugin example[11240:3532454] Diagnostic[native]: Bluetooth state is: unauthorized
2022-08-26 11:09:49.598649+0200 Diagnostic plugin example[11240:3532454] Diagnostic[native]: Microphone authorization status is: not_determined
2022-08-26 11:09:49.598837+0200 Diagnostic plugin example[11240:3532457] Diagnostic[native]: Camera available
2022-08-26 11:09:49.598915+0200 Diagnostic plugin example[11240:3532447] Diagnostic[native]: Battery level: 100
2022-08-26 11:09:49.599099+0200 Diagnostic plugin example[11240:3532445] Diagnostic[native]: Calendar event authorization status is: not_determined
2022-08-26 11:09:49.599217+0200 Diagnostic plugin example[11240:3532445] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:09:49.599239+0200 Diagnostic plugin example[11240:3532458] Diagnostic[native]: Camera available
2022-08-26 11:09:49.599230+0200 Diagnostic plugin example[11240:3532457] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:09:49.599389+0200 Diagnostic plugin example[11240:3532456] Diagnostic[native]: Reminders authorization status is: not_determined
2022-08-26 11:09:49.599434+0200 Diagnostic plugin example[11240:3532447] Diagnostic[native]: Address book authorization status is: not_determined
2022-08-26 11:09:49.599504+0200 Diagnostic plugin example[11240:3532445] Diagnostic[native]: Current CPU architecture: ARMv8
2022-08-26 11:09:49.600400+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Camera Roll authorization status is: not_determined
2022-08-26 11:09:49.602320+0200 Diagnostic plugin example[11240:3532449] Diagnostic[native]: Remote notifications authorization status is: not_determined
2022-08-26 11:10:05.947503+0200 Diagnostic plugin example[11240:3532446] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:10:05.947774+0200 Diagnostic plugin example[11240:3532446] Diagnostic[native]: Requesting bluetooth authorization
2022-08-26 11:10:05.948017+0200 Diagnostic plugin example[11240:3532446] [CoreBluetooth] API MISUSE: <CBCentralManager: 0x28359f700> can only accept this command while in the powered on state
2022-08-26 11:10:05.948130+0200 Diagnostic plugin example[11240:3532446] [CoreBluetooth] API MISUSE: <CBCentralManager: 0x28359f700> can only accept this command while in the powered on state
2022-08-26 11:10:05.953096+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Location authorization status is: not_determined
2022-08-26 11:10:05.953647+0200 Diagnostic plugin example[11240:3532465] Diagnostic[native]: Location accuracy authorization is: reduced
2022-08-26 11:10:05.954110+0200 Diagnostic plugin example[11240:3532463] Diagnostic[native]: Camera authorization status is: not_determined
2022-08-26 11:10:05.954603+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Battery level: 100
2022-08-26 11:10:05.954955+0200 Diagnostic plugin example[11240:3532548] Diagnostic[native]: Camera available
2022-08-26 11:10:05.955536+0200 Diagnostic plugin example[11240:3532446] Diagnostic[native]: Camera available
2022-08-26 11:10:05.957003+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Wifi ON
2022-08-26 11:10:05.957280+0200 Diagnostic plugin example[11240:3532465] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:10:05.957251+0200 Diagnostic plugin example[11240:3532549] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:10:05.957375+0200 Diagnostic plugin example[11240:3532465] Diagnostic[native]: Bluetooth state is: unauthorized
2022-08-26 11:10:05.957683+0200 Diagnostic plugin example[11240:3532353] Diagnostic[native]: Microphone authorization status is: not_determined
2022-08-26 11:10:05.957878+0200 Diagnostic plugin example[11240:3532550] Diagnostic[native]: Address book authorization status is: not_determined
2022-08-26 11:10:05.958303+0200 Diagnostic plugin example[11240:3532446] Diagnostic[native]: Camera Roll authorization status is: not_determined
2022-08-26 11:10:05.960612+0200 Diagnostic plugin example[11240:3532463] Diagnostic[native]: Calendar event authorization status is: not_determined
2022-08-26 11:10:05.960806+0200 Diagnostic plugin example[11240:3532446] Diagnostic[native]: Reminders authorization status is: not_determined
2022-08-26 11:10:05.961642+0200 Diagnostic plugin example[11240:3532551] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:10:05.961755+0200 Diagnostic plugin example[11240:3532463] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:10:05.962304+0200 Diagnostic plugin example[11240:3532550] Diagnostic[native]: Current CPU architecture: ARMv8
2022-08-26 11:10:05.964875+0200 Diagnostic plugin example[11240:3532548] Diagnostic[native]: Remote notifications authorization status is: not_determined
2022-08-26 11:13:04.930708+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView::
2022-08-26 11:13:04.930799+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView title:
2022-08-26 11:13:04.930843+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView location: file:///private/var/containers/Bundle/Application/6CF4846B-022B-435F-81CC-5C6F99E72E84/Diagnostic%20plugin%20example.app/www/index.html
2022-08-26 11:13:04.930892+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView reload: 0
2022-08-26 11:13:04.944565+0200 Diagnostic plugin example[11240:3533375] Diagnostic[native]: Location authorization status is: not_determined
2022-08-26 11:13:04.944701+0200 Diagnostic plugin example[11240:3533377] Diagnostic[native]: Location accuracy authorization is: reduced
2022-08-26 11:13:04.945278+0200 Diagnostic plugin example[11240:3533270] Diagnostic[native]: Battery level: 100
2022-08-26 11:13:04.945644+0200 Diagnostic plugin example[11240:3533326] Diagnostic[native]: Camera authorization status is: not_determined
2022-08-26 11:13:04.945744+0200 Diagnostic plugin example[11240:3533326] Diagnostic[native]: Wifi ON
2022-08-26 11:13:04.945777+0200 Diagnostic plugin example[11240:3533270] Diagnostic[native]: Camera available
2022-08-26 11:13:04.945842+0200 Diagnostic plugin example[11240:3533326] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:13:04.945857+0200 Diagnostic plugin example[11240:3533270] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:13:04.945889+0200 Diagnostic plugin example[11240:3533270] Diagnostic[native]: Bluetooth state is: unauthorized
2022-08-26 11:13:04.945988+0200 Diagnostic plugin example[11240:3533326] Diagnostic[native]: Microphone authorization status is: not_determined
2022-08-26 11:13:04.946077+0200 Diagnostic plugin example[11240:3532465] Diagnostic[native]: Camera available
2022-08-26 11:13:04.946203+0200 Diagnostic plugin example[11240:3533270] Diagnostic[native]: Calendar event authorization status is: not_determined
2022-08-26 11:13:04.946236+0200 Diagnostic plugin example[11240:3533375] Diagnostic[native]: Address book authorization status is: not_determined
2022-08-26 11:13:04.947965+0200 Diagnostic plugin example[11240:3533378] Diagnostic[native]: Reminders authorization status is: not_determined
2022-08-26 11:13:04.948062+0200 Diagnostic plugin example[11240:3532465] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:13:04.948161+0200 Diagnostic plugin example[11240:3533270] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:13:04.948553+0200 Diagnostic plugin example[11240:3532465] Diagnostic[native]: Current CPU architecture: ARMv8
2022-08-26 11:13:04.949072+0200 Diagnostic plugin example[11240:3533376] Diagnostic[native]: Camera Roll authorization status is: not_determined
2022-08-26 11:13:04.955741+0200 Diagnostic plugin example[11240:3533380] Diagnostic[native]: Remote notifications authorization status is: not_determined
2022-08-26 11:13:07.621851+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView::
2022-08-26 11:13:07.621955+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView title:
2022-08-26 11:13:07.622000+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView location: file:///private/var/containers/Bundle/Application/6CF4846B-022B-435F-81CC-5C6F99E72E84/Diagnostic%20plugin%20example.app/www/index.html
2022-08-26 11:13:07.622050+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView reload: 0
2022-08-26 11:13:07.634606+0200 Diagnostic plugin example[11240:3533378] Diagnostic[native]: Location authorization status is: not_determined
2022-08-26 11:13:07.635023+0200 Diagnostic plugin example[11240:3533377] Diagnostic[native]: Battery level: 100
2022-08-26 11:13:07.635253+0200 Diagnostic plugin example[11240:3533376] Diagnostic[native]: Location accuracy authorization is: reduced
2022-08-26 11:13:07.635758+0200 Diagnostic plugin example[11240:3533378] Diagnostic[native]: Wifi ON
2022-08-26 11:13:07.635789+0200 Diagnostic plugin example[11240:3533376] Diagnostic[native]: Camera authorization status is: not_determined
2022-08-26 11:13:07.635878+0200 Diagnostic plugin example[11240:3533375] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:13:07.636230+0200 Diagnostic plugin example[11240:3533380] Diagnostic[native]: Camera available
2022-08-26 11:13:07.636341+0200 Diagnostic plugin example[11240:3533375] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:13:07.636460+0200 Diagnostic plugin example[11240:3533377] Diagnostic[native]: Camera available
2022-08-26 11:13:07.636651+0200 Diagnostic plugin example[11240:3533381] Diagnostic[native]: Microphone authorization status is: not_determined
2022-08-26 11:13:07.636681+0200 Diagnostic plugin example[11240:3533375] Diagnostic[native]: Bluetooth state is: unauthorized
2022-08-26 11:13:07.636836+0200 Diagnostic plugin example[11240:3533270] Diagnostic[native]: Address book authorization status is: not_determined
2022-08-26 11:13:07.636970+0200 Diagnostic plugin example[11240:3533397] Diagnostic[native]: Calendar event authorization status is: not_determined
2022-08-26 11:13:07.637227+0200 Diagnostic plugin example[11240:3533378] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:13:07.637262+0200 Diagnostic plugin example[11240:3533376] Diagnostic[native]: Reminders authorization status is: not_determined
2022-08-26 11:13:07.637294+0200 Diagnostic plugin example[11240:3533399] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:13:07.640911+0200 Diagnostic plugin example[11240:3532465] Diagnostic[native]: Camera Roll authorization status is: not_determined
2022-08-26 11:13:07.641535+0200 Diagnostic plugin example[11240:3532465] Diagnostic[native]: Current CPU architecture: ARMv8
2022-08-26 11:13:07.645756+0200 Diagnostic plugin example[11240:3533380] Diagnostic[native]: Remote notifications authorization status is: not_determined
2022-08-26 11:13:09.974365+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView::
2022-08-26 11:13:09.974479+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView title:
2022-08-26 11:13:09.974525+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView location: file:///private/var/containers/Bundle/Application/6CF4846B-022B-435F-81CC-5C6F99E72E84/Diagnostic%20plugin%20example.app/www/index.html
2022-08-26 11:13:09.974574+0200 Diagnostic plugin example[11240:3532018] CDVWebViewEngine shouldReloadWebView reload: 0
2022-08-26 11:13:09.993191+0200 Diagnostic plugin example[11240:3533326] Diagnostic[native]: Location authorization status is: not_determined
2022-08-26 11:13:09.994145+0200 Diagnostic plugin example[11240:3533380] Diagnostic[native]: Location accuracy authorization is: reduced
2022-08-26 11:13:09.995266+0200 Diagnostic plugin example[11240:3533375] Diagnostic[native]: Battery level: 100
2022-08-26 11:13:09.997439+0200 Diagnostic plugin example[11240:3533326] Diagnostic[native]: Camera available
2022-08-26 11:13:09.998004+0200 Diagnostic plugin example[11240:3533380] Diagnostic[native]: Camera available
2022-08-26 11:13:09.998411+0200 Diagnostic plugin example[11240:3533380] Diagnostic[native]: Camera authorization status is: not_determined
2022-08-26 11:13:09.998922+0200 Diagnostic plugin example[11240:3533326] Diagnostic[native]: Wifi ON
2022-08-26 11:13:09.999114+0200 Diagnostic plugin example[11240:3533326] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:13:09.999375+0200 Diagnostic plugin example[11240:3532465] Diagnostic[native]: Bluetooth state changed: The app is not authorized to use Bluetooth Low Energy.
2022-08-26 11:13:10.000339+0200 Diagnostic plugin example[11240:3533381] Diagnostic[native]: Address book authorization status is: not_determined
2022-08-26 11:13:10.000698+0200 Diagnostic plugin example[11240:3533397] Diagnostic[native]: Microphone authorization status is: not_determined
2022-08-26 11:13:10.000790+0200 Diagnostic plugin example[11240:3533399] Diagnostic[native]: Calendar event authorization status is: not_determined
2022-08-26 11:13:10.000868+0200 Diagnostic plugin example[11240:3533398] Diagnostic[native]: Reminders authorization status is: not_determined
2022-08-26 11:13:10.000907+0200 Diagnostic plugin example[11240:3533270] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:13:10.000942+0200 Diagnostic plugin example[11240:3533400] Diagnostic[native]: Background updates are available for the app.
2022-08-26 11:13:10.001308+0200 Diagnostic plugin example[11240:3532465] Diagnostic[native]: Bluetooth state is: unauthorized
2022-08-26 11:13:10.001614+0200 Diagnostic plugin example[11240:3533380] Diagnostic[native]: Camera Roll authorization status is: not_determined
2022-08-26 11:13:10.004413+0200 Diagnostic plugin example[11240:3533270] Diagnostic[native]: Remote notifications authorization status is: not_determined
2022-08-26 11:13:10.009736+0200 Diagnostic plugin example[11240:3533326] Diagnostic[native]: Current CPU architecture: ARMv8


Other information:

@andreacab2 andreacab2 changed the title requestBluetoothAuthorizattion when state is unauthorized throws a native API misuse error on iOS Using requestBluetoothAuthorizattion when state is unauthorized throws a native API misuse error on iOS Aug 26, 2022
@uncoded-apps
Copy link

We are experiencing exactly this issue.

@dpa99c
Copy link
Owner

dpa99c commented Oct 4, 2022

On iOS there is no explicit method in the iOS Bluetooth manager to request permission.
Instead, any interaction with the native Bluetooth Manager class - even initialising it - causes the Bluetooth permission dialog to be shown to the user.
Hence if you call getBluetoothState() or registerBluetoothStateChangeHandler() after a fresh app install, the permission dialog will be shown because the plugin has to init the Bluetooth Manager in order to check the Bluetooth state.

Once the user has denied Bluetooth permission - either by pressing "Don't Allow" in the permission dialog or switching off Bluetooth permission on the app's Settings page - it is not possible to programmatically request it again (i.e. show the dialog).
At this point, the app must show a message to the user requesting them to manually re-enable Bluetooth.

So the current implementation is misleading as it indicates that it can programmatically recover from Bluetooth being unauthorized - it cannot.

I'll push a commit which handles this situation more gracefully.

@dpa99c dpa99c closed this as completed in 35b583e Oct 4, 2022
@dpa99c dpa99c added bug Something isn't working properly ios relates to iOS platform runtime issue An issue related to app runtime ready for release On master branch but not published as npm release labels Oct 4, 2022
@dpa99c
Copy link
Owner

dpa99c commented Oct 4, 2022

Fix released in [email protected]

@dpa99c dpa99c removed the ready for release On master branch but not published as npm release label Oct 4, 2022
@andreacab2
Copy link
Author

Hey thanks for the explanation, it makes sense and thanks for the improvements as well, appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working properly ios relates to iOS platform runtime issue An issue related to app runtime
Projects
None yet
Development

No branches or pull requests

3 participants