zoontek / react-native-permissions

An unified permissions API for React Native on iOS, Android and Windows.
MIT License
4.1k stars 836 forks source link

Getting error adding pod "Invalid `Podfile` file: cannot load such file -- /Users/[project]/apps/mobile/node_modules/react-native-permissions/scripts/setup. #818

Closed thidasapankaja closed 1 year ago

thidasapankaja commented 1 year ago

Bug summary

I got an error trying to access request Push Permission in iOS saying "Notifications pod is missing". So, I added pod 'Permission-Notifications', :path => '../node_modules/react-native-permissions/ios/Notifications.podspec' as suggested. But I'm still getting some error saying

[!] InvalidPodfilefile: cannot load such file -- /Users/thidasa/[folder]/apps/mobile/node_modules/react-native-permissions/scripts/setup.

And when I looked at

My react-native version is 0.67.3 . What am I missing ?

This is my pod file

$RNFirebaseAsStaticFramework = true
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/@nrwl/react-native/nx_post_install'
require_relative '../node_modules/react-native-permissions/scripts/setup'

platform :ios, '13.0'

setup_permissions([
  # 'AppTrackingTransparency',
  # 'BluetoothPeripheral',
  # 'Calendars',
  # 'Camera',
  # 'Contacts',
  # 'FaceID',
  # 'LocationAccuracy',
  # 'LocationAlways',
  # 'LocationWhenInUse',
  # 'MediaLibrary',
  # 'Microphone',
  # 'Motion',
  'Notifications',
  # 'PhotoLibrary',
  # 'PhotoLibraryAddOnly',
  # 'Reminders',
  # 'Siri',
  # 'SpeechRecognition',
  # 'StoreKit',
])

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

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

  pod 'MarketingCloudSDK', '8.0.13'

  pod 'Permission-Notifications', :path => '../node_modules/react-native-permissions/ios/Notifications/Permission-Notifications.podspec'

I'm getting err

Library version

3.8.0

Environment info

System:
    OS: macOS 14.0
    CPU: (10) arm64 Apple M1 Pro
    Memory: 87.80 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.14.0/bin/yarn
    npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
    Watchman: 2023.05.22.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.12.1 - /Users/thidasa/.rvm/gems/ruby-3.1.3/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 15.0/15A240d - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.17 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: * => 17.0.2 
    react-native: * => 0.67.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Mentioned in Bug Summary

Reproducible sample code

$RNFirebaseAsStaticFramework = true
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/@nrwl/react-native/nx_post_install'
require_relative '../node_modules/react-native-permissions/scripts/setup'

platform :ios, '13.0'

setup_permissions([
  # 'AppTrackingTransparency',
  # 'BluetoothPeripheral',
  # 'Calendars',
  # 'Camera',
  # 'Contacts',
  # 'FaceID',
  # 'LocationAccuracy',
  # 'LocationAlways',
  # 'LocationWhenInUse',
  # 'MediaLibrary',
  # 'Microphone',
  # 'Motion',
  'Notifications',
  # 'PhotoLibrary',
  # 'PhotoLibraryAddOnly',
  # 'Reminders',
  # 'Siri',
  # 'SpeechRecognition',
  # 'StoreKit',
])

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

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

  pod 'MarketingCloudSDK', '8.0.13'

  pod 'Permission-Notifications', :path => '../node_modules/react-native-permissions/ios/Notifications/Permission-Notifications.podspec'
zoontek commented 1 year ago
thidasapankaja commented 1 year ago

Thanks @zoontek . I checked this. But it doesn't open the Push Notification permission modal. How can I get it requested from react-native js code ? For reference, for Android we can get it worked from request(PERMISSIONS.ANDROID.POST_NOTIFICATIONS); . But for iOS I don't see a way to request the Push Notification Permission

zoontek commented 1 year ago

Read the documentation: https://github.com/zoontek/react-native-permissions#requestnotifications