flutter-permission-handler icon indicating copy to clipboard operation
flutter-permission-handler copied to clipboard

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

Open victorsanni opened this issue 2 years ago • 0 comments

Please check the following before submitting a new issue.

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:

#if PERMISSION_BLUETOOTH
...
#else

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

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

NS_ASSUME_NONNULL_BEGIN

@interface StoragePermissionStrategy : NSObject <PermissionStrategy>

@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:

#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.

victorsanni avatar Aug 07 '23 16:08 victorsanni