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

Apple rejection. NSAppleMusicUsageDescription

Open gusabdala opened this issue 4 years ago • 10 comments

🐛 Bug Report

Apple rejects due to not defining NSAppleMusicUsageDescription even when not needing this permission.

Expected behavior

Should be able to disable this via preprocessor definition.

Reproduction steps

Configuration

Version: 5.0.0+hotfix.6

Platform:

  • [x] :iphone: iOS
  • [ ] :robot: Android

gusabdala avatar May 26 '20 23:05 gusabdala

@mvanbeusekom Is this something you could resolve?

gusabdala avatar May 30 '20 05:05 gusabdala

What I did, and what others have suggested is to add it to the info file and state that your "app does not use this permission, if requested please reject." It shouldn't ever call though.

If you want to disable it completely, this seems to work I haven't tried it. https://github.com/Baseflow/flutter-permission-handler/issues/26#issuecomment-605026503

smasinde avatar Jun 02 '20 18:06 smasinde

@gusabdala you can mention dummy permission like this in info.plist

<key>NSAppleMusicUsageDescription</key>
<string>This permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us.</string>

shahnawazahmed88 avatar Jun 08 '20 09:06 shahnawazahmed88

I've seen this before and the reason (from my understanding) is because if an underlying SDK or framework requires a certain permission for a specific feature (regardless of whether you implement that feature), you need to include that permission in your plist. The reasoning being, if somehow that code is triggered and the permission isn't accounted for in the plist, it will cause a crash and from my experience Apple review won't allow for such a possibility.

I would echo the comments from @smasinde and @shahnawazahmed88

digitallysavvy avatar Nov 27 '20 01:11 digitallysavvy

Any update on this?

mohdtaha60 avatar Jan 20 '22 14:01 mohdtaha60

Any updates!

msayed-net avatar Jan 24 '22 21:01 msayed-net

Can someone confirm the contents of the ios/Podfile?

Also which version of the plugin are you using?

mvanbeusekom avatar Jan 24 '22 21:01 mvanbeusekom

Here is mine,

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)

    target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',

        ## dart: PermissionGroup.calendar
        'PERMISSION_EVENTS=0',

        ## dart: PermissionGroup.reminders
        'PERMISSION_REMINDERS=0',

        ## dart: PermissionGroup.contacts
        'PERMISSION_CONTACTS=0',

        ## dart: PermissionGroup.camera
        'PERMISSION_CAMERA=0',

        ## dart: PermissionGroup.microphone
        'PERMISSION_MICROPHONE=0',

        ## dart: PermissionGroup.speech
        'PERMISSION_SPEECH_RECOGNIZER=0',

        ## dart: PermissionGroup.photos
        # 'PERMISSION_PHOTOS=0',

        ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
        'PERMISSION_LOCATION=0',

        ## dart: PermissionGroup.notification
        'PERMISSION_NOTIFICATIONS=0',

        ## dart: PermissionGroup.mediaLibrary
        # 'PERMISSION_MEDIA_LIBRARY=0',

        ## dart: PermissionGroup.sensors
        'PERMISSION_SENSORS=0',

        ## dart: PermissionGroup.bluetooth 
        'PERMISSION_BLUETOOTH=0',
      ]
    end
  end
end

msayed-net avatar Jan 24 '22 22:01 msayed-net

please note, I had to add those lines to my info.plist

<key>NSAppleMusicUsageDescription</key>
<string>This permission is not needed by the app, but it is required by an underlying API. If you see this dialog, contact us.</string>

msayed-net avatar Jan 24 '22 22:01 msayed-net

I am assuming you are using a version of the permission_handler before 8.0.0, where permission are all enabled by default (this behavior is flipped since version 8.0.0 and higher). In this case the reason is because the PERMISSION_MEDIA_LIBRARY is enabled (commented out in the ios/Podfile).

The PERMISSION_MEDIA_LIBRARY macro enables/ includes the iOS MPMediaLibrary framework which in turn requires the NSAppleMusicUsageDescription in the Info.plist. If you don't need access to the devices media library you can remove the comment character in the ios/Podfile for the PERMISSION_MEDIA_LIBRARY macro.

mvanbeusekom avatar Jan 24 '22 22:01 mvanbeusekom

Hello, any updates regarding this ?

khalilyamoun avatar Oct 14 '22 09:10 khalilyamoun

Closing this issue as the problem is caused by misconfiguration (see comment).

mvanbeusekom avatar Jun 30 '23 08:06 mvanbeusekom