I am using the permission_handler which is working fine, but now I need to know if a certain Permission
has been requested
before.
So I am looking for something like PermissionStatus.notDetermined
. Does this package offer something like this? I couldn't find it, but it is at least for me quite an important thing to know.
I know there is something similar in the firebase_messaging
package.
I only want to display a pop up, if the the systemPermissionStatus has NOT been requested before.
This can of course also be done with saving some values like "wasRequested" in SharedPreferences
for example, but I thought there must be an existing function for this usecase?
Let me know if you need any more information.
Update
I also noticed that status
and the returned status
from .request
is different.
That doesn't make any sense for me, it's super confusing.
final stat = await Permission.notification.status; // -> denied
final req = await Permission.notification.request(); // -> permanentlyDenied
as @gopelkujo already pointed out:
denied
can be used asnotDetermined
The wording "denied" is a bit confusing I think..
To my issue:
It was always giving me back denied
instead of permanentlyDenied
, because I didn't do the configuration correctly. After adding the setup in the Podfile
, everything is working as expected.
# You can remove unused permissions here
# for more information: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h
# e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
## dart: PermissionGroup.photos
'PERMISSION_PHOTOS=1',
## dart: PermissionGroup.notification
'PERMISSION_NOTIFICATIONS=1',
## dart: PermissionGroup.appTrackingTransparency
'PERMISSION_APP_TRACKING_TRANSPARENCY=1',