react-native-permissions icon indicating copy to clipboard operation
react-native-permissions copied to clipboard

Multiple request made via different flow results in either crash or doesn't show one less priority permission modal

Open shaliniele6263 opened this issue 4 months ago • 1 comments

Before submitting a new issue

  • [X] I tested using the latest version of the library, as the bug might be already fixed.
  • [X] I tested using a supported version of react native.
  • [X] I checked for possible duplicate issues, with possible answers.

Bug summary

Please bear with me if I'm not able to explain it very well.

Explanation :

I have two flows where I am asking for the permission

  • On state change i.e when the state of the navigation changes from OTP screen to Home screen. Here, I am asking for the location permission because there is a map on the home screen.
  • One is the notification permission which is in the useEffect of my App.js which runs as soon as the user Id is set i.e after login

Problem :

Only the notification permission modal is showing up, no location permission modal.

Library version

3.6.10, 4.1.5

Environment info

"devDependencies": {
        "@babel/core": "^7.20.0",
        "@babel/preset-env": "^7.24.8",
        "@babel/preset-react": "^7.20.0",
        "@babel/runtime": "^7.20.0",
        "@react-native-community/eslint-config": "^3.0.0",
        "@types/react-native": "^0.71.1",
        "babel-eslint": "^10.1.0",
        "babel-jest": "^29.2.1",
        "babel-preset-airbnb": "^5.0.0",
        "eslint": "^8.57.0",
        "eslint-config-airbnb": "^19.0.4",
        "eslint-config-prettier": "^9.1.0",
        "eslint-plugin-babel": "^5.3.1",
        "eslint-plugin-import": "^2.29.1",
        "eslint-plugin-jsx-a11y": "^6.8.0",
        "eslint-plugin-react": "^7.34.4",
        "eslint-plugin-react-hooks": "^4.6.0",
        "eslint-plugin-react-native": "^4.1.0",
        "husky": "^8.0.3",
        "jest": "^29.2.1",
        "lint-staged": "^13.0.3",
        "metro-react-native-babel-preset": "^0.73.7",
        "prettier": "^2.4.1",
        "prettier-eslint": "^16.3.0",
        "react-test-renderer": "18.0.0"
    },

Steps to reproduce

ask for the permission either same or different at the same time via two different ways. eg on button click and inside useEffect.

Reproducible sample code


const requestAndroidPermission = async () => {
    try {
        const granted = await PermissionsAndroid.request(
            PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION
        )
    } catch (err) {
        return false
    }
}

export const requestLocationPermission = async () => {
    if (Platform.OS === 'ios') return requestIosPermission()
    return requestAndroidPermission()
}

export const postNotificationPremission = async () => {
    const apiLevel = await getApiLevel()
    if (apiLevel >= 33 && Platform.OS === 'android') {
    
        try {
            await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS)
        } catch (error) {
        } 
    }
}

shaliniele6263 avatar Oct 11 '24 10:10 shaliniele6263