Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
permission_handler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
permission_handler
Commits
9d12bb54
Commit
9d12bb54
authored
Mar 12, 2021
by
Rene Floor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add bluetooth permission.
parent
e89eaa91
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
1 deletions
+77
-1
permission_handler/ios/Classes/PermissionHandlerEnums.h
+2
-0
permission_handler/ios/Classes/PermissionManager.h
+1
-0
permission_handler/ios/Classes/PermissionManager.m
+2
-0
permission_handler/ios/Classes/strategies/BluetoothPermissionStrategy.h
+14
-0
permission_handler/ios/Classes/strategies/BluetoothPermissionStrategy.m
+50
-0
permission_handler/pubspec.yaml
+2
-1
permission_handler_platform_interface/lib/src/permissions.dart
+6
-0
No files found.
permission_handler/ios/Classes/PermissionHandlerEnums.h
View file @
9d12bb54
...
@@ -108,7 +108,9 @@ typedef NS_ENUM(int, PermissionGroup) {
...
@@ -108,7 +108,9 @@ typedef NS_ENUM(int, PermissionGroup) {
PermissionGroupIgnoreBatteryOptimizations
,
PermissionGroupIgnoreBatteryOptimizations
,
PermissionGroupNotification
,
PermissionGroupNotification
,
PermissionGroupAccessMediaLocation
,
PermissionGroupAccessMediaLocation
,
PermissionGroupActivityRecognition
,
PermissionGroupUnknown
,
PermissionGroupUnknown
,
PermissionGroupBluetooth
,
};
};
typedef
NS_ENUM
(
int
,
PermissionStatus
)
{
typedef
NS_ENUM
(
int
,
PermissionStatus
)
{
...
...
permission_handler/ios/Classes/PermissionManager.h
View file @
9d12bb54
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
#import "AudioVideoPermissionStrategy.h"
#import "AudioVideoPermissionStrategy.h"
#import "BluetoothPermissionStrategy.h"
#import "ContactPermissionStrategy.h"
#import "ContactPermissionStrategy.h"
#import "EventPermissionStrategy.h"
#import "EventPermissionStrategy.h"
#import "LocationPermissionStrategy.h"
#import "LocationPermissionStrategy.h"
...
...
permission_handler/ios/Classes/PermissionManager.m
View file @
9d12bb54
...
@@ -123,6 +123,8 @@
...
@@ -123,6 +123,8 @@
return
[
NotificationPermissionStrategy
new
];
return
[
NotificationPermissionStrategy
new
];
case
PermissionGroupStorage
:
case
PermissionGroupStorage
:
return
[
StoragePermissionStrategy
new
];
return
[
StoragePermissionStrategy
new
];
case
PermissionGroupBluetooth
:
return
[
BluetoothPermissionStrategy
new
];
default
:
default
:
return
[
UnknownPermissionStrategy
new
];
return
[
UnknownPermissionStrategy
new
];
}
}
...
...
permission_handler/ios/Classes/strategies/BluetoothPermissionStrategy.h
0 → 100644
View file @
9d12bb54
//
// BluetoothPermissionStrategy.h
// permission_handler
//
// Created by Rene Floor on 12/03/2021.
//
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "PermissionStrategy.h"
@interface
BluetoothPermissionStrategy
:
NSObject
<
PermissionStrategy
>
@end
permission_handler/ios/Classes/strategies/BluetoothPermissionStrategy.m
0 → 100644
View file @
9d12bb54
//
// BluetoothPermissionStrategy.m
// permission_handler
//
// Created by Rene Floor on 12/03/2021.
//
#import "BluetoothPermissionStrategy.h"
@implementation
BluetoothPermissionStrategy
-
(
PermissionStatus
)
checkPermissionStatus
:(
PermissionGroup
)
permission
{
if
(
@available
(
iOS
13
.
1
,
*
))
{
CBManagerAuthorization
blePermission
=
[
CBCentralManager
authorization
];
return
[
BluetoothPermissionStrategy
parsePermission
:
blePermission
];
}
else
if
(
@available
(
iOS
13
.
0
,
*
)){
CBCentralManager
*
manager
=
[[
CBCentralManager
alloc
]
init
];
CBManagerAuthorization
blePermission
=
[
manager
authorization
];
return
[
BluetoothPermissionStrategy
parsePermission
:
blePermission
];
}
return
PermissionStatusGranted
;
}
-
(
ServiceStatus
)
checkServiceStatus
:(
PermissionGroup
)
permission
{
CBCentralManager
*
manager
=
[[
CBCentralManager
alloc
]
init
];
if
(
@available
(
iOS
10
,
*
))
{
return
[
manager
state
]
==
CBManagerStatePoweredOn
?
ServiceStatusEnabled
:
ServiceStatusDisabled
;
}
return
[
manager
state
]
==
CBCentralManagerStatePoweredOn
?
ServiceStatusEnabled
:
ServiceStatusDisabled
;
}
-
(
void
)
requestPermission
:(
PermissionGroup
)
permission
completionHandler
:(
PermissionStatusHandler
)
completionHandler
{
completionHandler
([
self
checkPermissionStatus
:
permission
]);
}
+
(
PermissionStatus
)
parsePermission
:(
CBManagerAuthorization
)
bluetoothPermission
API_AVAILABLE
(
ios
(
13
)){
switch
(
bluetoothPermission
){
case
CBManagerAuthorizationNotDetermined
:
return
PermissionStatusDenied
;
case
CBManagerAuthorizationRestricted
:
return
PermissionStatusRestricted
;
case
CBManagerAuthorizationDenied
:
return
PermissionStatusDenied
;
case
CBManagerAuthorizationAllowedAlways
:
return
PermissionStatusGranted
;
}
}
@end
permission_handler/pubspec.yaml
View file @
9d12bb54
...
@@ -16,7 +16,8 @@ dependencies:
...
@@ -16,7 +16,8 @@ dependencies:
flutter
:
flutter
:
sdk
:
flutter
sdk
:
flutter
meta
:
^1.3.0
meta
:
^1.3.0
permission_handler_platform_interface
:
^3.0.0+1
permission_handler_platform_interface
:
path
:
../permission_handler_platform_interface
dev_dependencies
:
dev_dependencies
:
effective_dart
:
^1.3.0
effective_dart
:
^1.3.0
...
...
permission_handler_platform_interface/lib/src/permissions.dart
View file @
9d12bb54
...
@@ -103,6 +103,10 @@ class Permission {
...
@@ -103,6 +103,10 @@ class Permission {
/// The unknown only used for return type, never requested
/// The unknown only used for return type, never requested
static
const
unknown
=
Permission
.
_
(
20
);
static
const
unknown
=
Permission
.
_
(
20
);
/// iOS 13 and above: The authorization state of Core Bluetooth manager.
/// When running < iOS 13 or Android this is always allowed.
static
const
bluetooth
=
Permission
.
_
(
21
);
/// Returns a list of all possible [PermissionGroup] values.
/// Returns a list of all possible [PermissionGroup] values.
static
const
List
<
Permission
>
values
=
<
Permission
>[
static
const
List
<
Permission
>
values
=
<
Permission
>[
calendar
,
calendar
,
...
@@ -126,6 +130,7 @@ class Permission {
...
@@ -126,6 +130,7 @@ class Permission {
accessMediaLocation
,
accessMediaLocation
,
activityRecognition
,
activityRecognition
,
unknown
,
unknown
,
bluetooth
];
];
static
const
List
<
String
>
_names
=
<
String
>[
static
const
List
<
String
>
_names
=
<
String
>[
...
@@ -150,6 +155,7 @@ class Permission {
...
@@ -150,6 +155,7 @@ class Permission {
'access_media_location'
,
'access_media_location'
,
'activity_recognition'
,
'activity_recognition'
,
'unknown'
,
'unknown'
,
'bluetooth'
,
];
];
@override
@override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment