skip to Main Content

I’m making a mobile app using flutter and I’m making push notifications using FCM.

I’m using flutter permission handler package to know whether the users allow the notification or not when they see the notification permission dialog.

However, the permission handler is not working. Whether the user allows the permission or not, the permission handler always says that the user denied the notification permission.

I tried using the other package, but it doesn’t work.
Please feel free to give me some any idea.

This is the code that I used.

var status = await Permission.notification.status;
      developer.log('status : ${status.isDenied}');

2

Answers


  1. For Android just try by adding POST_NOTIFICATIONS permission in your AndroidManifest

    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    
    Login or Signup to reply.
  2. This package does not work on IOS out of the box. Referring to the documentation, you should add to your pod file this code to bottom block of the file:

    # ...some flutter things
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
        # ...
        # Start of the permission_handler configuration <----
        target.build_configurations.each do |config|
    
          config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
                 '$(inherited)',
    
            'PERMISSION_NOTIFICATIONS=1',
          ]
        end
        # End of the permission_handler configuration <----
        # ...
      end
    end
    

    then flutter clean and it should work (tested today)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search