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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception occurred while executing exported method askAsync on module ExpoPermissions: null #5548

Closed
janicduplessis opened this issue Sep 5, 2019 · 15 comments
Assignees
Labels

Comments

@janicduplessis
Copy link
Contributor

馃悰 Bug Report

I'm getting this error in production:

Encountered an exception while calling native method: Exception occurred while executing exported method askAsync on module ExpoPermissions: null

Happened 429 times for 89 users over 25 days.

Environment

Android, regular RN project with unimodules

image

Steps to Reproduce

I cannot reproduce locally. I'm pretty sure it comes from this call:

const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);

Expected Behavior

No error

Actual Behavior

It doesn't seem to cause a noticeable issue, afaik there is no need to require permissions for notifications on Android. Not sure what the code that ask notif permissions does on Android.

Reproducible Demo

N/A

@janicduplessis
Copy link
Contributor Author

Here's a more detailled breakdown of android versions:

image

I tried reproducing on a Android 9 simulator but no luck there. The only Android device I have currently is on Android 7.1.2 and also doesn't repro.

@lukmccall
Copy link
Contributor

Hi @janicduplessis, which version of expo-permissions do you use?
It'll be nice if you also provide a part of your packages.json, which contains expo related dependencies.

@lukmccall lukmccall added the needs more info To be used when awaiting reporter response label Nov 8, 2019
@AryanJ-NYC
Copy link
Contributor

AryanJ-NYC commented Jan 9, 2020

@lukmccall I get a similar error. Am using:

    "expo": "~36.0.2",
    "expo-analytics-amplitude": "~8.0.0",
    "expo-camera": "^8.0.0",
    "expo-constants": "^8.0.0",
    "expo-contacts": "~8.0.0",
    "expo-font": "~8.0.0",
    "expo-image-picker": "~8.0.0",
    "expo-linear-gradient": "~8.0.0",
    "expo-mail-composer": "~8.0.0",
    "expo-permissions": "~8.0.0",

I was also asking for Android notification permissions which are a normal category permission.

I've changed my code to something like:

if (Platform.OS === 'ios')
  await Permissions.askAsync(Permissions.NOTIFICATIONS)

@WouterFlorijn
Copy link
Contributor

@lukmccall any idea if there's a possible workaround or fix for this? We're having the same issue and it's blocking our release since we updated Expo.

My reproduction steps (for both production and development):

  • Install the app.
  • Disable push notifications in Android settings.
  • Call Permissions.askAsync(Permissions.NOTIFICATIONS)

Result: nothing happens for the user, and the console shows the error mentioned in the issue.

@Phillip-Cognativ
Copy link

@WouterFlorijn

My working solution is to keep a list of dangerous Android permissions, and only prompt an Android user for those permissions, ignoring normal permissions. Notifications is a normal permission so it is set automatically and I don't think expo-permissions is able to prompt the user to reset it if they have manually disabled it like you have done.

export const PERMISSIONS: {[key: string]: Permission } = {
  CALENDAR: EXPermissions.CALENDAR,
  CAMERA: EXPermissions.CAMERA,
  CONTACTS: EXPermissions.CONTACTS,
  LOCATION: EXPermissions.LOCATION,
  MICROPHONE: EXPermissions.AUDIO_RECORDING,
  CAMERA_ROLL: EXPermissions.CAMERA_ROLL,
  LOCAL_NOTIFICATIONS: EXPermissions.USER_FACING_NOTIFICATIONS,
  NOTIFICATIONS: EXPermissions.NOTIFICATIONS,
  SETTINGS: EXPermissions.SYSTEM_BRIGHTNESS,
};

export const DANGEROUS_PERMISSIONS: Permission[] = [
  PERMISSIONS.CALENDAR,
  PERMISSIONS.CAMERA,
  PERMISSIONS.CONTACTS,
  PERMISSIONS.LOCATION,
  PERMISSIONS.AUDIO_RECORDING,
  PERMISSIONS.CAMERA_ROLL,
  PERMISSIONS.SYSTEM_BRIGHTNESS,
];

@BrodaNoel
Copy link
Contributor

I'm having the same problem and I only use

Permissions.askAsync(Permissions.USER_FACING_NOTIFICATIONS)

@yangga
Copy link

yangga commented Mar 19, 2020

Same here. Does anyone have a solution for this?

@yasahmed
Copy link

any solution ?

@lukmccall
Copy link
Contributor

Hi @yasahmed. Could you provide logs from your device? Or provide more details about your environment, android version? It'll be nice if you also create a simple demo that can reproduce this bug.

I've looked at this bug in the past, but unfortunately, I couldn't reproduce it.

@Speedy1991
Copy link

Hi @lukmccall

import {Permissions} from 'react-native-unimodules'
const {granted} = await Permissions.askAsync(
    Permissions.USER_FACING_NOTIFICATIONS,
    Permissions.NOTIFICATIONS,
  )

Leads to
[Mon Jun 22 2020 10:00:20.368] WARN 0 [Error: Encountered an exception while calling native method: Exception occurred while executing exported method askAsync on module ExpoPermissions: permission cannot be null or empty]

Strangely calling getAsync returns always true (even it is disabled via android app settings)

 const {granted, canAskAgain} = await Permissions.getAsync(
    Permissions.USER_FACING_NOTIFICATIONS,
    Permissions.NOTIFICATIONS,
  )
  // granted: true, canAskAgain: true

Setup (Bare Project):

"react": "16.13.1",
"react-native": "0.62.2",
"react-native-unimodules": "0.9.1",

Tested on a real Android 9 device with disabled notifications

@lukmccall
Copy link
Contributor

Hi @Speedy1991, the bug which you found isn't connected with this issue. So, I've created a separate issue for this (see #8909).
It concerns problems with the askAsync method. The issue with getAsync was fixed by #8539 and it will be available in the SDK 38.

@RodolfoGS
Copy link
Contributor

RodolfoGS commented Jul 5, 2020

Same here:

Encountered an exception while calling native method: Exception occurred while executing exported method askAsync on module ExpoPermissions: permission cannot be null or empty

I can't reproduce it, I get that errors in Sentry.

  Expo CLI 3.21.13 environment info:
    System:
      OS: macOS 10.15.5
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 14.4.0 - /usr/local/bin/node
      Yarn: 1.19.1 - /usr/local/bin/yarn
      npm: 6.14.5 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 4.0 AI-193.6911.18.40.6514223
      Xcode: 11.5/11E608c - /usr/bin/xcodebuild
    npmPackages:
      expo: ~37.0.12 => 37.0.12
      react: ~16.9.0 => 16.9.0
      react-native: ~0.61.5 => 0.61.5
      expo-permissions: ^9.0.1
    npmGlobalPackages:
      expo-cli: 3.21.13

Devices:
image

image

@lukmccall
Copy link
Contributor

Hi @RodolfoGS, your problem should be fixed by #8910 ;)

@lukmccall
Copy link
Contributor

Closing this issue due to inactivity. Moreover, we can't reproduce it either. If this is still a problem for you and it's reproducible using the latest SDK version, feel free to open up a new issue!

@RodolfoGS
Copy link
Contributor

@lukmccall sorry, I don't saw your comment.
Yes, was fixed with #8910 Thank you so much for your help, you are great 馃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests