App crashes when switching on/off bluetooth permissions in iOS settings
I am building an app using Flutterblue and for that I need bluetooth to be switched on and bluetooth permissions. I am using permission handler to check it like this:
bluetoothPermission = await Permission.bluetooth.isGranted;
I've created a button which is green when bluetooth permission is granted and blue when not, I've created my own stream to listen to bluetoothPermission = await Permission.bluetooth.isGranted;
But when I open my app settings on iOS and either switch on or off the bluetooth permission, my app crashes and I receive this SIGKILL:
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGKILL frame #0: 0x00000001dd2fb644 libsystem_kernel.dylibmach_msg_trap + 8
libsystem_kernel.dylibmach_msg_trap: -> 0x1dd2fb644 <+8>: ret libsystem_kernel.dylibmach_msg_overwrite_trap:
0x1dd2fb648 <+0>: mov x16, #-0x20
0x1dd2fb64c <+4>: svc #0x80
0x1dd2fb650 <+8>: ret
Target 0: (Runner) stopped.
Lost connection to device.`
I do the same exact same with location switched on and location permission but that goes fine.
Can anyone help me out with this problem? I have no clue where to look or what might cause this.
I can see the exact same error with the camera permission. And I can confirm that it works with locations (and for notifications)
@Annelein it is normal behavior on iOS, nothing to do with the plugin.
@petro-i even in android
even if I restart the application the moment I go to the page where it checks for that permission in crashes
Any updates/confirmations? I am facing this issue on both Android (location permission) and iOS (bluetooth permission). In my case, the crashes happen when I turn off the permissions in Settings on Android and toggle either on or off in Settings on iOS.
The error message I have on iOS is same with @Annelein.
For Android, I got this: D/Surface (31553): Surface::disconnect(this=0x72ee5ea000,api=-1) D/Surface (31553): Surface::disconnect(this=0x729d0b1000,api=1) I/GED (31553): ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 29, oppidx_max 29, oppidx_min 0 Lost connection to device. Exited (sigterm)
This issue is happening to me as well in iOS - App detects the user has permanently denied bluetooth access, prompts them to go to the settings page. On the settings page, if they switch Bluetooth to the ON position the app instantly crashes:
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGKILL frame #0: 0x00000002100d74e0 libsystem_kernel.dylibmach_msg_trap + 8
libsystem_kernel.dylibmach_msg_trap: -> 0x2100d74e0 <+8>: ret libsystem_kernel.dylibmach_msg_overwrite_trap:
0x2100d74e4 <+0>: mov x16, #-0x20
0x2100d74e8 <+4>: svc #0x80
0x2100d74ec <+8>: ret
Target 0: (Runner) stopped.
Lost connection to device.
`
Anyone have a solution for this?
This isn't an issue pertaining to the package, as explained in this comment from similar issue #293
This is not a problem of this lib. If you try to run you app without doing anything and open iOS settings and try to change app permission the app exit automatically.
You can test this behavior on any existing apps.
ie. Instagram.
- If you go deep into a navigation flow
- have some state in a page (scroll, content)
- close the app (not kill)
- go to OS settings
- toggle Instagram permissions
- go back to Instagram app
- you'll notice that Instagram is rebooted again from scratch (not saving any of your previous states)
Since the app is essentially "rebooted", Flutter assumes you Lost connection to deviceand throws this error and In order to get around this to test your app. You would need to launch in release mode
in the terminal
flutter run --release
@luggy-wuggy thanks, works exactly as you said
@luggy-wuggy Thank you~~~~, I thought there was something wrong with my program
Closing this issue, as the problem has been identified: the behavior is driven by the OS, not the plugin. See the https://github.com/Baseflow/flutter-permission-handler/issues/509#issuecomment-1113636977 for an explanation. Thanks @luggy-wuggy!