react-native-permissions

An unified permissions API for React Native on iOS, Android and Windows.

MIT License

Downloads
2M
Stars
4K
Committers
109

Bot releases are hidden (Show)

react-native-permissions - 3.8.1

Published by zoontek over 1 year ago

react-native-permissions - 3.8.0

Published by zoontek over 1 year ago

  • Add new architecture support (#748 by @WoLewicki)
react-native-permissions - 3.7.3

Published by zoontek over 1 year ago

  • Add support for reactNativePermissionsIOS.json config file (closes #753)
react-native-permissions - 3.7.2

Published by zoontek over 1 year ago

  • Include missing react-native.config.js file in the npm package (#752 by @johnf)
  • Replace cosmiconfig dependency by read-pkg (fixes this issue)
react-native-permissions - 3.7.1

Published by zoontek over 1 year ago

  • Only request the App Tracking Transparency iOS permission when the app is focused (as it's not allowed in background).
    This means that this code (which was a workaround):
useEffect(() => {
  const listener = AppState.addEventListener('change', (status) => {
    if (Platform.OS === 'ios' && status === 'active') {
      request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY)
        .then((result) => console.log(result))
        .catch((error) => console.log(error));
    }
  });

  return listener.remove;
}, []);

       Can safely be replaced by:

useEffect(() => {
  if (Platform.OS === 'ios') {
    request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY)
      .then((result) => console.log(result))
      .catch((error) => console.log(error));
  }
}, []);
react-native-permissions - 3.7.0

Published by zoontek over 1 year ago

The new react-native setup-ios-permissions command

This release come with a new permission handler linkage system for iOS: the react-native setup-ios-permissions command. No need to update your Podfile file anymore, everything is now handled by your package.json.

The benefits from this solution are many, but the main ones are that it should fixes Xcode cache issues and the well-known use_frameworks issue (no more workaround needed! 🎉)

📌 The "old way" will continue to work until the next major update, but it has been removed from the latest documentation since this is not the preferred way anymore.

To migrate, remove all the extra code from your Podfile (and the use_frameworks workaround if you used it):

- # Convert all permission pods into static libraries
- pre_install do |installer|
-   Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
-   installer.pod_targets.each do |pod|
-     if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
-       def pod.build_type;
-         # Uncomment the line corresponding to your CocoaPods version
-         # Pod::BuildType.static_library # >= 1.9
-         # Pod::Target::BuildType.static_library # < 1.9
-       end
-     end
-   end
- end

target 'MyAwesomeApp' do

    # …

-  permissions_path = '../node_modules/react-native-permissions/ios'

-  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
-  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
-  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
-  pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition"

Add a reactNativePermissionsIOS config in your package.json:

{
  "reactNativePermissionsIOS": [
    "Camera",
    "LocationWhenInUse",
    "Notifications",
    "SpeechRecognition"
  ]
}

Then run react-native setup-ios-permissions and pod install. That's all! ✨


P.-S. As these commands must be run each tome each time you update this config, delete your node_modules directory or update this library, I highly recommand to use a postinstall script to simplify this:

{
  "reactNativePermissionsIOS": [
    "Camera",
    "LocationWhenInUse",
    "Notifications",
    "SpeechRecognition"
  ],
  "devDependencies": {
    "pod-install": "0.1.38"
  },
  "scripts": {
    "postinstall": "react-native setup-ios-permissions && pod-install"
  }
}

Also in this release:

  • Update project dependencies to React Native 0.71 in order to prepare new architecture support.
  • Update the example app UI (with react-native-paper v5):
react-native-permissions - 3.6.1

Published by zoontek about 2 years ago

react-native-permissions - 3.6.0

Published by zoontek over 2 years ago

  • Add support for new Android 13 permissions (#701 by @bang9):
    • android.permission.BODY_SENSORS_BACKGROUND
    • android.permission.NEARBY_WIFI_DEVICES
    • android.permission.READ_MEDIA_AUDIO
    • android.permission.READ_MEDIA_IMAGES
    • android.permission.READ_MEDIA_VIDEO
react-native-permissions - 3.5.0

Published by zoontek over 2 years ago

⚠️ You have to target at least SDK 33 to perform the request:

buildscript {
  ext {
    buildToolsVersion = "33.0.0" // <- set at least 33.x
    minSdkVersion = 21
    compileSdkVersion = 33 // <- set at least 33
    targetSdkVersion = 33 // <- set at least 33

    // …
react-native-permissions - 3.4.0

Published by zoontek over 2 years ago

Previous Android flow

New Android flow

ℹ️  It should not be breaking if you followed the previous flow.

Known issues

  • On Android, there is currently no way, without relying on SharedPreferences (a trick that break Ask next time setting and Only this time grant status), to determine if a permission is BLOCKED without requesting it.
  • Dismissing the popup on Android 11+ will result in BLOCKED (see https://github.com/facebook/react-native/issues/30158). It's a flaw in the Android permission system, not specific to this library or React Native.
react-native-permissions - 3.3.1

Published by zoontek over 2 years ago

  • Fix test mock (#681 by @rkaartikeyan)
react-native-permissions - 3.3.0

Published by zoontek over 2 years ago

  • Add providesAppSettings support in NotificationSettings (#678 by @cwhenderson20)
react-native-permissions - 3.2.0

Published by zoontek almost 3 years ago

  • Add Android ACCESS_MEDIA_LOCATION permission (#669 by @hectoruiz)
react-native-permissions - 3.1.0

Published by zoontek about 3 years ago

  • Add new Android 12 bluetooth permissions (#655 by @jsimonassi)
  • Add App Tracking Transparency instructions in the documentation (#657 by @TheWirv)
  • Fix react-native-windows reference directory (#652 by @JerryMacedoCastro)
react-native-permissions - 3.0.6

Published by zoontek about 3 years ago

  • Make react-native-windows peer dependency optional (#656 by @grit96)
react-native-permissions - 3.0.5

Published by zoontek over 3 years ago

  • Export PERMISSIONS constants in Jest mock (#628 by @1natsu172)
react-native-permissions - 3.0.4

Published by zoontek over 3 years ago

  • Fix Android requestMultiple not handling BLOCKED state properly (#609 by @Iskander508)
react-native-permissions - 3.0.3

Published by zoontek over 3 years ago

  • Fix BluetoothPeripheral permission handler for Xcode 12.5+ (Fix #590)
react-native-permissions - 3.0.2

Published by zoontek over 3 years ago

  • Add mavenCentral() as jcenter() is shutting down
react-native-permissions - 3.0.1

Published by zoontek over 3 years ago

  • Update Microphone iOS permission handler to use [AVAudioSession sharedInstance] (Fix #571)
Package Rankings
Top 0.77% on Npmjs.org
Badges
Extracted from project README
mit licence npm version npm downloads platform - android platform - ios platform - windows
Related Projects