Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
shaliniele6263 opened this issue Oct 11, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@shaliniele6263
Copy link

shaliniele6263 commented Oct 11, 2024

Before submitting a new issue

  • I tested using the latest version of the library, as the bug might be already fixed.
  • I tested using a supported version of react native.
  • 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 shaliniele6263 added the bug Something isn't working label Oct 11, 2024
@shaliniele6263 shaliniele6263 changed the title Multiple request made via different flow results in either crash or doesn;t show one less priority permission modal Multiple request made via different flow results in either crash or doesn't show one less priority permission modal Oct 11, 2024
@zoontek
Copy link
Owner

zoontek commented Oct 17, 2024

@shaliniele6263 I recommend using AppState and check that the app is in foreground before requesting (if another popup is already shown, it will not be). Or implement a queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants