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
3a7cf04d
Commit
3a7cf04d
authored
Nov 26, 2020
by
Mathias Cochet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make separate permission for photo add only accesss level permission.
parent
afe1dc2c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
6 deletions
+29
-6
permission_handler/ios/Classes/PermissionHandlerEnums.h
+8
-0
permission_handler/ios/Classes/PermissionManager.m
+3
-1
permission_handler/ios/Classes/strategies/PhotoPermissionStrategy.h
+1
-0
permission_handler/ios/Classes/strategies/PhotoPermissionStrategy.m
+17
-5
No files found.
permission_handler/ios/Classes/PermissionHandlerEnums.h
View file @
3a7cf04d
...
@@ -54,6 +54,13 @@
...
@@ -54,6 +54,13 @@
#define PERMISSION_PHOTOS 1
#define PERMISSION_PHOTOS 1
#endif
#endif
// ios: PermissionGroupPhotosAddOnly
// Info.plist: NSPhotoLibraryUsageDescription
// dart: PermissionGroup.photosAddOnly
#ifndef PERMISSION_PHOTOS_ADD_ONLY
#define PERMISSION_PHOTOS_ADD_ONLY
#endif
// ios: [PermissionGroupLocation, PermissionGroupLocationAlways, PermissionGroupLocationWhenInUse]
// ios: [PermissionGroupLocation, PermissionGroupLocationAlways, PermissionGroupLocationWhenInUse]
// Info.plist: [NSLocationUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription]
// Info.plist: [NSLocationUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription]
// dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
// dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
...
@@ -92,6 +99,7 @@ typedef NS_ENUM(int, PermissionGroup) {
...
@@ -92,6 +99,7 @@ typedef NS_ENUM(int, PermissionGroup) {
PermissionGroupMicrophone
,
PermissionGroupMicrophone
,
PermissionGroupPhone
,
PermissionGroupPhone
,
PermissionGroupPhotos
,
PermissionGroupPhotos
,
PermissionGroupPhotosAddOnly
,
PermissionGroupReminders
,
PermissionGroupReminders
,
PermissionGroupSensors
,
PermissionGroupSensors
,
PermissionGroupSms
,
PermissionGroupSms
,
...
...
permission_handler/ios/Classes/PermissionManager.m
View file @
3a7cf04d
...
@@ -96,7 +96,9 @@
...
@@ -96,7 +96,9 @@
case
PermissionGroupPhone
:
case
PermissionGroupPhone
:
return
[
PhonePermissionStrategy
new
];
return
[
PhonePermissionStrategy
new
];
case
PermissionGroupPhotos
:
case
PermissionGroupPhotos
:
return
[
PhotoPermissionStrategy
new
];
return
[[
PhotoPermissionStrategy
alloc
]
initWithAccessAddOnly
:
false
];
case
PermissionGroupPhotosAddOnly
:
return
[[
PhotoPermissionStrategy
alloc
]
initWithAccessAddOnly
:
true
];
case
PermissionGroupReminders
:
case
PermissionGroupReminders
:
return
[
EventPermissionStrategy
new
];
return
[
EventPermissionStrategy
new
];
case
PermissionGroupSensors
:
case
PermissionGroupSensors
:
...
...
permission_handler/ios/Classes/strategies/PhotoPermissionStrategy.h
View file @
3a7cf04d
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#import <Photos/Photos.h>
#import <Photos/Photos.h>
@interface
PhotoPermissionStrategy
:
NSObject
<
PermissionStrategy
>
@interface
PhotoPermissionStrategy
:
NSObject
<
PermissionStrategy
>
-
(
instancetype
)
initWithAccessAddOnly
:
(
BOOL
)
addOnly
;
@end
@end
#else
#else
...
...
permission_handler/ios/Classes/strategies/PhotoPermissionStrategy.m
View file @
3a7cf04d
...
@@ -7,9 +7,21 @@
...
@@ -7,9 +7,21 @@
#if PERMISSION_PHOTOS
#if PERMISSION_PHOTOS
@implementation
PhotoPermissionStrategy
@implementation
PhotoPermissionStrategy
{
bool
addOnlyAccessLevel
;
}
-
(
instancetype
)
initWithAccessAddOnly
:
(
BOOL
)
addOnly
{
self
=
[
super
init
];
if
(
self
)
{
addOnlyAccessLevel
=
addOnly
;
}
return
self
;
}
-
(
PermissionStatus
)
checkPermissionStatus
:
(
PermissionGroup
)
permission
{
-
(
PermissionStatus
)
checkPermissionStatus
:
(
PermissionGroup
)
permission
{
return
[
PhotoPermissionStrategy
permissionStatus
];
return
[
PhotoPermissionStrategy
permissionStatus
:
addOnlyAccessLevel
];
}
}
-
(
ServiceStatus
)
checkServiceStatus
:
(
PermissionGroup
)
permission
{
-
(
ServiceStatus
)
checkServiceStatus
:
(
PermissionGroup
)
permission
{
...
@@ -25,7 +37,7 @@
...
@@ -25,7 +37,7 @@
}
}
if
(
@available
(
iOS
14
,
*
))
{
if
(
@available
(
iOS
14
,
*
))
{
[
PHPhotoLibrary
requestAuthorizationForAccessLevel
:
PHAccessLevelReadWrite
handler
:
^
(
PHAuthorizationStatus
authorizationStatus
)
{
[
PHPhotoLibrary
requestAuthorizationForAccessLevel
:
(
addOnlyAccessLevel
)?
PHAccessLevelAddOnly
:
PHAccessLevelReadWrite
handler
:
^
(
PHAuthorizationStatus
authorizationStatus
)
{
completionHandler
([
PhotoPermissionStrategy
determinePermissionStatus
:
authorizationStatus
]);
completionHandler
([
PhotoPermissionStrategy
determinePermissionStatus
:
authorizationStatus
]);
}];
}];
}
else
{
}
else
{
...
@@ -35,10 +47,10 @@
...
@@ -35,10 +47,10 @@
}
}
}
}
+
(
PermissionStatus
)
permissionStatus
{
+
(
PermissionStatus
)
permissionStatus
:
(
BOOL
)
addOnlyAccessLevel
{
PHAuthorizationStatus
status
;
PHAuthorizationStatus
status
;
if
(
@available
(
iOS
14
,
*
)){
if
(
@available
(
iOS
14
,
*
)){
status
=
[
PHPhotoLibrary
authorizationStatusForAccessLevel
:
PHAccessLevelReadWrite
];
status
=
[
PHPhotoLibrary
authorizationStatusForAccessLevel
:
(
addOnlyAccessLevel
)?
PHAccessLevelAddOnly
:
PHAccessLevelReadWrite
];
}
else
{
}
else
{
status
=
[
PHPhotoLibrary
authorizationStatus
];
status
=
[
PHPhotoLibrary
authorizationStatus
];
}
}
...
...
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