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

Android: app not showing custom permission message #756

Closed Joshig99 closed 1 year ago

Joshig99 commented 1 year ago

Bug summary

i'm trying to request location permission, i added some custom message but app not showing custom message, it is always showing default message

Library version

3.7.3

Environment info

System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M1
    Memory: 65.05 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: Not Found
    npm: 9.5.1 - ~/Joshi/MyProjects/reactnativecli/crsthome/crst/node_modules/.bin/npm
    Watchman: 2022.11.28.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1
    Android SDK:
      API Levels: 29, 30, 31, 32, 33
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0
      System Images: android-27 | Google APIs ARM 64 v8a, android-31 | Google APIs ARM 64 v8a, android-32 | Google APIs ARM 64 v8a, android-33 | Google Play ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 14.1/14B47b - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.67.0 => 0.67.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  1. added code to request location permission
  2. added ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION permissions in AndroidManifest.xml
  3. ran the app and it showing default message for location permission

Reproducible sample code

const requestLocationPermission = async () => {
  try {
    const granted = await request(
      Platform.select({
        android: PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
        ios: PERMISSIONS.IOS.LOCATION_WHEN_IN_USE,
      }),
      {
        title: 'MyApp',
        message:
          'MyApp collects location data to enable mapping, job routing, and direction services even when the app is closed or not in use.',
        buttonNeutral: 'Ask Me Later',
        buttonNegative: 'Cancel',
        buttonPositive: 'OK',
      },
    );
    console.log('granted', granted);
    if (granted === 'granted') {
      console.log('You can use Geolocation');
      return true;
    } else {
      console.log('You cannot use Geolocation');
      return false;
    }
  } catch (err) {
    return false;
  }
};
zoontek commented 1 year ago

Permission rationale are not custom permission messages. Check here for more infos: https://developer.android.com/training/permissions/requesting#workflow_for_requesting_permissions (step 5a / 5b)