2

I am using the library react-native-permissions. Originally I wanted to get permissions for sending notifications, but ran into many build errors and decided to at least get Contact permissions.

I followed the steps on the docs.

podfile:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'

target 'MyApp' do
  permissions_path = '../node_modules/react-native-permissions/ios'

  config = use_native_modules! 
  pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts"

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  target 'MyAppTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

included in my info.plist:

    <key>NSContactsUsageDescription</key>
    <string>Allow permission for contacts</string>

in my App.js

import { request, PERMISSIONS } from 'react-native-permissions';

  useEffect(() => {
    request(PERMISSIONS.IOS.CONTACTS)
      .then((result) => {
        console.log(result);
      })
      .catch((e) => console.log(e));
  }, []);

The moment the request gets executed the app instantly crashes.

Any help would be greatly appreciated!

ozansozuoz
  • 217
  • 1
  • 13
  • 1
    One way to get insight into crashes is to run the app in Xcode and cause the crash there. – Abe Dec 29 '21 at 22:18
  • 1
    Thank you, I had added permission on my apps tests folder. Once I added permission to the main info.plist, it was solved! – ozansozuoz Dec 31 '21 at 03:11
  • I'm currently having this same issue, we you able to find a work around by any change ? – Relie Essom May 21 '22 at 23:21

0 Answers0