Baseflow / Baseflow/flutter-permission-handler

[Enhancement proposal]: Add phone and storage macros so users can choose to include or not

Open
#1,120 0 comments 0 reactions 0 assignees View on GitHub
good first issue P2 platform: ios type: enhancement up for graps
Dominant language
Dart
Stars
2.2k
Forks
970
Avg merge
14h 22m
Merged PRs (30d)
2

Description

### Please check the following before submitting a new issue.

- [X] I have searched the [existing issues](https://github.com/baseflow/flutter-permission-handler/issues).
- [X] I have carefully [read the documentation](https://github.com/baseflow/flutter-permission-handler/blob/main/permission_handler/README.md) and verified I have added the required platform specific configuration.

### Please select affected platform(s)

- [ ] Android
- [X] iOS
- [ ] Windows

### Proposal

Currently on iOS, no enum values exist for phone and storage permission strategies in `PermissionHandlerEnums.h`. However, enum values exist for all other permission strategies (camera, microphone, etc).

Other permission strategies are executed only if their enum values are defined. For example, for bluetooth, the enum value `PERMISSION_BLUETOOTH` is defined in `PermissionHandlerEnums.h`. Then, in `BluetoothPermissionStrategy.h`, bluetooth permission is only implemented if its enum value is defined:

```objective-c
#if PERMISSION_BLUETOOTH
...
#else

#import "UnknownPermissionStrategy.h"
...
#endif
```

Currently, this if...else block doesn't exist in `PhonePermissionStrategy.h` or `StoragePermissionStrategy.h`:

```objective-c
NS_ASSUME_NONNULL_BEGIN

@interface StoragePermissionStrategy : NSObject

@end

NS_ASSUME_NONNULL_END
```

This means phone and storage permission strategies are always added, including dependencies like `CoreTelephony` needed for phone permissions strategy.

Instead, we can add macros `PERMISSION_STORAGE` and `PERMISSION_PHONE` to `PermissionHandlerEnums.h`, and add an if...else block in phone and storage permission strategy header files, as follows:
```objective-c
#if PERMISSION_STORAGE
...
#else

#import "UnknownPermissionStrategy.h"
...
#endif
```

### Pitch

This will allow users to specify if they want phone and storage permissions in their Podfiles.

For phone permission strategy, this would mean users who don't need phone permissions can leave out the `CoreTelephony` framework from their applications.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.