Commit 634b29bf by Jaime Blasco Committed by GitHub

fix: init CBCentralManager lazely (#738)

* fix: init CBCentralManager lazely

* prepare release 9.0.0
parent deb17dc7
## 9.0.0
* iOS: Bluetooth permission dialog now appears when requested instead of when the app is initialized.
Note: Requesting Bluetooth status will also prompt the permission dialog (see issue [#591](https://github.com/Baseflow/flutter-permission-handler/issues/591)).
## 8.3.0
* Updated Android Gradle Plugin to 4.1.0 and Gradle Wrapper to 6.7 which is inline with the current Flutter stable version (Flutter 2.5.3).
......
......@@ -132,11 +132,7 @@
case PermissionGroupStorage:
return [StoragePermissionStrategy new];
case PermissionGroupBluetooth:
#if PERMISSION_BLUETOOTH
return [[BluetoothPermissionStrategy alloc] initWithBluetoothManager];
#else
return [BluetoothPermissionStrategy new];
#endif
case PermissionGroupAppTrackingTransparency:
return [AppTrackingTransparencyPermissionStrategy new];
case PermissionGroupCriticalAlerts:
......
......@@ -13,7 +13,7 @@
#import <CoreBluetooth/CoreBluetooth.h>
@interface BluetoothPermissionStrategy : NSObject <PermissionStrategy, CBCentralManagerDelegate>
-(instancetype)initWithBluetoothManager;
- (void)initManagerIfNeeded;
@end
#else
......
......@@ -15,16 +15,14 @@
PermissionGroup _requestedPermission;
}
- (instancetype)initWithBluetoothManager {
self = [super init];
if (self) {
- (void)initManagerIfNeeded {
if (_centralManager == nil) {
_centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}
return self;
}
- (PermissionStatus)checkPermissionStatus:(PermissionGroup)permission {
[self initManagerIfNeeded];
if (@available(iOS 13.1, *)) {
CBManagerAuthorization blePermission = [_centralManager authorization];
return [BluetoothPermissionStrategy parsePermission:blePermission];
......@@ -36,6 +34,7 @@
}
- (ServiceStatus)checkServiceStatus:(PermissionGroup)permission {
[self initManagerIfNeeded];
if (@available(iOS 10, *)) {
return [_centralManager state] == CBManagerStatePoweredOn ? ServiceStatusEnabled : ServiceStatusDisabled;
}
......@@ -43,6 +42,7 @@
}
- (void)requestPermission:(PermissionGroup)permission completionHandler:(PermissionStatusHandler)completionHandler {
[self initManagerIfNeeded];
PermissionStatus status = [self checkPermissionStatus:permission];
if (status != PermissionStatusDenied) {
......
name: permission_handler
description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
version: 8.3.0
version: 9.0.0
homepage: https://github.com/baseflowit/flutter-permission-handler
flutter:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment