Closed ajnozari closed 3 months ago
@ajnozari Let's say you want to ask for microphone permission. You will have to update your app.json
file this way:
{
"expo": {
"name": "Awesome app",
"plugins": [
[
"react-native-permissions",
{
// Add setup_permissions to your Podfile (see iOS setup - steps 1, 2 and 3)
"iosPermissions": [
"Camera",
"Microphone"
]
}
]
],
"ios": {
// Add descriptions to your Info.plist (see iOS setup - step 4)
"infoPlist": {
"NSCameraUsageDescription": "[REASON]",
"NSMicrophoneUsageDescription": "[REASON]"
}
},
"android": {
// Add permissions to your AndroidManifest.xml (see Android setup)
"permissions": [
"android.permission.CAMERA",
"android.permission.RECORD_AUDIO"
]
}
}
}
I'm updating the README to make this easier to understand.
Thank you, once all of the relevant sections were added expo prebuild
is now working as expected.
I am not having any luck modifying t he Podfile, I keep getting "No permission handler detected"
There was a problem loading the project.
This development build encountered the following error:
• No permission handler detected.
• Check that you are correctly calling setup_permissions in your Podfile.
• Uninstall this app, reinstall your Pods, delete your Xcode DerivedData folder and rebuild it.
-[RNPermissions constantsToExport]
RNPermissions.mm
-[RCTModuleData gatherConstantsAndSignalJSReq
uire Ending:]
-[RCTModuleData exportedConstants]
facebook::react::RCTNativeModule::getConstants)
facebook::react::ModuleRegistry::getConfig (std::
1:: basic_string<char, std::_1::char_traits<char>, st d::
_1: :allocator<char>> const&)
facebook::react::JSINativeModules::createModulef acebook: ji:: Runtime&, std::_1:: basic_string<char, std::
_1::char_traits<char>, std::_1::allocator<char
>> const&)
I already added the permission to app.json and I am using react-native-clean-project before each build.
This is my Podfile:
# Podfile
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}
ENV['RCT_NEW_ARCH_ENABLED'] = podfile_properties['newArchEnabled'] == 'true' ? '1' : '0'
ENV['EX_DEV_CLIENT_NETWORK_INSPECTOR'] = podfile_properties['EX_DEV_CLIENT_NETWORK_INSPECTOR']
# Node require function to resolve scripts with node for hoisting
def node_require(script)
require Pod::Executable.execute_command('node', ['-p', "require.resolve('#{script}', {paths: [process.argv[1]]})", __dir__]).strip
end
# Include React Native and React Native Permissions setup scripts
node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')
platform :ios, podfile_properties['ios.deploymentTarget'] || '13.4'
install! 'cocoapods',
:deterministic_uuids => false
prepare_react_native_project!
target 'MyApp' do
use_expo_modules!
config = use_native_modules!
use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
use_frameworks! :linkage => ENV['USE_FRAMEWORKS'].to_sym if ENV['USE_FRAMEWORKS']
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/..",
:privacy_file_aggregation_enabled => podfile_properties['apple.privacyManifestAggregationEnabled'] != 'false',
)
# Setup permissions with the permissions you need
setup_permissions([
'PhotoLibraryAddOnly',
])
post_install do |installer|
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false,
:ccache_enabled => podfile_properties['apple.ccacheEnabled'] == 'true',
)
# Necessary for Xcode 14, preventing resource bundles from signing on device builds
installer.target_installation_results.pod_target_installation_results
.each do |pod_name, target_installation_result|
target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
resource_bundle_target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
end
end
end
end
post_integrate do |installer|
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
end
end
@alketii Try below prepare_react_native_project!
, not inside target 'MyApp' do…end
, like in the README / example app.
@zoontek still not working. I also double-checked if I have the other requirements.
Before submitting a new issue
Bug summary
I'm trying to get this working on the latest version of expo (fresh install) but I'm confused on something. If I'm using expo development builds do I need to do the pod file setup? I only ask as I noticed that any changes are reset when running
yarn expo prebuild --clean
.I apologize if this question has already been answered but I feel the documentation could be made a little clearer on what is required for Expo users. Currently there is the section on the plugin, but I'm not sure if that also handles calling setup_permissions, as I am getting a
No permission handler detected
issue but even when I try to add the relevant sections based on your example repo I cannot seem to get it to work.I appreciate any assistance.
Library version
4.1.5
Environment info
Steps to reproduce
yarn expo prebuild
yarn expo run:ios
Reproducible sample code