What's the proper way to deal with permissions in this case?

  1. SDK Version: ~43.0.2
  2. Platforms(Android/iOS/web/all): iOS
  3. Add the appropriate “Tag” based on what Expo library you have a question on.
  • Managed workflow.
  • Must remain compatible with EAS Build as we want to rely on this super cool pipeline.
  • Custom Development Client.

I’m trying to build an Expo + WebView based wrapper for our web app that allows people to communicate with each other in virtual rooms. Our mobile-optimized web app works great in iOS Safari and Chrome on Android once you’ve given access to your microphone and camera, and we want to wrap it inside a native app because that’ll give us push notifications.

So now I’m trying to load this into a WebView and make it work as smoothly as it does in iOS Safari. I’m just focusing on iOS right now to get it done well before moving on to Android.

There are some funny things happening and I can’t quite figure out what’s wrong. :thinking:

In app.config.ts I’m setting all the iOS permission keys and values, while leaving entitlements empty:

ios: {
  infoPlist: {
    UIBackgroundModes: ['audio', 'voip'],
    UIRequiredDeviceCapabilities: ['microphone'],
    NSCameraUsageDescription: 'Give access to your camera so you can do video chats.',
    NSMicrophoneUsageDescription: 'Give access to your microphone so you can talk to others.',
  },
  entitlements: {},
}

With that, the WebView is able to use the microphone and camera. BUT:

  1. After first launch and upon toggling the mic / camera on for the first time within the WebView, iOS will prompt the user for permissions. That’s expected. Immediately afterwards though, the WebView also prompts for it, which is something I’m trying to figure out how to avoid because it feels clunky and buggy from the user’s perspective. Any pointers for that?

  2. The WebView will forget the permissions it had received every time the app loads again after quitting, for the same URL. More specifically, if I quit the app and open it again, then toggle the mic or camera on, I get a new permissions prompt. iOS Safari does that too, but there is an option to make it remember the permission permanently for a website/host. Is something similar achievable with WebView?

  3. If the app got quit after the permissions grant and then loaded again, then the native side, iOS in this case, prompts the user again despite having granted permissions before. I’m not sure why that is, because typically iOS would require a reinstall before prompting for permissions again. Maybe this is happening because the permission is triggered from within the WKWebView only, and not through a dedicated native API?

So I read through the expo-permissions documentation and trying to understand whether this is part of the solution. Do I read it correctly that we’d have to add the expo-camera and expo-av packages so that expo-permissions is able to make the permission requests natively?

Thanks for any pointers you may have