jacobg commented on PR #1609: URL: https://github.com/apache/cordova-android/pull/1609#issuecomment-1906284437
Thanks! I was able to get it working in my app but requesting permission in javascript code first before opening chooser: ```js getFileEl () { return document.getElementById(`file-${this.$.uid}`) }, async requestCameraPermission () { const diagnostic = window.cordova?.plugins?.diagnostic if (!diagnostic) return true const releasePermissionLock = await this.rootStore.acquireLockToRequestPermissions() return new Promise((resolve, reject) => { diagnostic.requestCameraAuthorization( status => resolve(status === diagnostic.permissionStatus.GRANTED), error => reject(error), false ) }) .finally(async () => { releasePermissionLock() }) }, async addDocument () { if (this.saving) return // The permissions and file picker will pause the webview, so we need to prevent that. this.idleStore.setPreventPause(true) // First we need to ask for camera permission, even though we don't know // whether they'll choose camera or not. // TODO: It seems Cordova needs to do this for us: // https://github.com/apache/cordova-android/pull/1609#issuecomment-1905156891 const granted = await this.requestCameraPermission() if (!granted) { console.warn('User did not grant camera permission before adding document') } const fileEl = this.getFileEl() if (!fileEl) { console.warn('File input element not mounted after requesting camera permission') return } // Open file picker. fileEl.click() }, ``` It would be nice if the native code could intercept the user choosing Camera, and only then ask for permissions, rather than ask for permissions before showing the chooser even though user may choose from gallery. But I'm not sure why @breautek thinks intent doesn't need to grant permission? Maybe there's a different approach? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org