npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tokenized/cordova-plugin-ios-permit-getusermedia

v1.0.0

Published

Cordova plugin allowing getUserMedia camera view without triggering a permission dialog every time

Downloads

33

Readme

Cordova Permit iOS getUserMedia Plugin

A Cordova plugin allowing the embedded web app (loaded from a file inside the app bundle) to call navigator.mediaDevices.getUserMedia (part of browser WebRTC support) and show a camera view without triggering a new iOS permission dialog every time.

The plugin does nothing on Android, has no JavaScript interface, and no configuration options.

Requirements

  • iOS 15.0 or later is required
  • Tested with cordova-ios v6.2.0

How it works

During application load, the plugin creates and installs a custom WKUIDelegate on the WKWebView. Whenever the JS code in the web view calls navigator.mediaDevices.getUserMedia, the web view asks the delegate for a “permission decision” by sending it a webView:requestMediaCapturePermissionForOrigin:initiatedByFrame:type:decisionHandler: message. The plugin checks the protocol of the origin, and if it’s file then it makes an “allow” decision, which suppresses the permission dialog. For all other origins it makes the default “prompt” decision, so if you’re running getUserMedia from web pages loaded from outside the app, they will continue to prompt for permission. If you need to allow that, feel free to fork this plugin.

Note that all other WKUIDelegate messages are forwarded to the original delegate that was in place when this plugin is loaded, so the other functions of CDVWebViewUIDelegate should continue to work. Be aware this might not work properly if you’re using another plugin that tries to do something similar.

Note that the app itself needs permission to access the camera through the normal iOS mechanism. That permission dialog will be triggered by the first call you make to getUserMedia. You can (and should, because it’s an App Store review failure if you don’t) customize the text of that popup to explain exactly what your app needs the camera for. Do that in your Cordova config.xml something like this:

<config-file overwrite="true" parent="NSCameraUsageDescription" platform="ios" target="*-Info.plist">
    <string>The app uses the camera to scan QR codes</string>
</config-file>

License

The project is MIT licensed: MIT.