xiaozhizhong / flutter_simple_bluetooth_printer

MIT License
3 stars 2 forks source link

Error: BTException (BTException{error: BTError.bluetoothNotAvailable, message: null}) #2

Open chuvanhoang888 opened 1 year ago

chuvanhoang888 commented 1 year ago

Hello Sir,

When i turn off bluetooch on device and execute build, error "BTException (BTException{error: BTError.bluetoothNotAvailable, message: null})" on both Android and Ios versions. However, on Ios, I have a more serious error that when I exit the app, the app will crash and can't be reopened, I have tried to open it many times but no success.

Screen Shot 2023-02-20 at 15 08 05

xiaozhizhong commented 1 year ago

May need more information. For "exit the app", do you mean kill the App process? Is there any error logs when you reopened? What does the screen show when you try to reopen the app?

chuvanhoang888 commented 1 year ago

May need more information. For "exit the app", do you mean kill the App process? Is there any error logs when you reopened? What does the screen show when you try to reopen the app?

Sir, I can't even get back into the app

xiaozhizhong commented 1 year ago

Have you add this codes into info.plist

<key>UIBackgroundModes</key>  
<array>
    <string>bluetooth-central</string>
    <string>bluetooth-peripheral</string>
</array>
chuvanhoang888 commented 1 year ago

Have you add this codes into info.plist

<key>UIBackgroundModes</key>  
<array>
    <string>bluetooth-central</string>
    <string>bluetooth-peripheral</string>
</array>

Screen Shot 2023-02-20 at 15 42 04

I tried it before but the problem is still not solved. Can you check if bluetooch is on or off before doing discovery.

xiaozhizhong commented 1 year ago

image I do have check bluetooth state before discovery. If bluetooth is not enabled, a BTException (BTException{error: BTError.bluetoothNotAvailable, message: null}) will be throw and the discovery action is stop

chuvanhoang888 commented 1 year ago

I do have check bluetooth state before discovery. If bluetooth is not enabled, a BTException (BTException{error: BTError.bluetoothNotAvailable, message: null}) will be throw and the discovery action is stop

Sir, can you add this function to ask user to enable bluetooch when state bluetooch is off with function "_ensureBluetoothAvailable"

https://stackoverflow.com/questions/23833757/any-way-to-turn-on-bluetooth-programmatically-on-ios7

xiaozhizhong commented 1 year ago

Okay, I'll try when I got time

xiaozhizhong commented 1 year ago

update: set CBCentralManagerOptionShowPowerAlertKey to true

chuvanhoang888 commented 1 year ago

Hello,

FK-POS80-AT printer case on ios

Vào 21:21, Th 5, 23 thg 2, 2023 xiaozhizhong @.***> đã viết:

update: set CBCentralManagerOptionShowPowerAlertKey to true

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/2#issuecomment-1441881276, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2DK4GW7KLN56B6AUJ3WY5W7NANCNFSM6AAAAAAVBRZRU4 . You are receiving this because you authored the thread.Message ID: @.*** com>

xiaozhizhong commented 1 year ago

May need more information. For "exit the app", do you mean kill the App process? Is there any error logs when you reopened? What does the screen show when you try to reopen the app?

Sir, I can't even get back into the app

I guess it's because Flutter doesn't support launch iOS App without connecting to IDE in debug mode. Try rerun the app or run in release mode.

xiaozhizhong commented 1 year ago

@chuvanhoang888 Hi, I added getState function, you can now check the state and show error to user if bluetooth is disabled or unauthorized before you scan & connect to bluetooth. Besides, I rollback CBCentralManagerOptionShowPowerAlertKey to false on iOS to keep it the same with Android. Please retry with branch v0.1.5

chuvanhoang888 commented 1 year ago

Thanks, I'll check it out.

Vào 22:14, Th 3, 28 thg 2, 2023 xiaozhizhong @.***> đã viết:

@chuvanhoang888 https://github.com/chuvanhoang888 Hi, I added getState function, you can now check the state and show error to user if bluetooth is disabled or unauthorized before you scan & connect to bluetooth. Besides, I rollback CBCentralManagerOptionShowPowerAlertKey to false on iOS to keep it the same with Android.

— Reply to this email directly, view it on GitHub https://github.com/xiaozhizhong/flutter_simple_bluetooth_printer/issues/2#issuecomment-1448362467, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY5GZ2A6FUD2E62FOARO4PTWZYI6VANCNFSM6AAAAAAVBRZRU4 . You are receiving this because you were mentioned.Message ID: @.*** com>