Replies: 2 comments
-
Hello 👋 Which sample basic app are you referring to? We have a test app here that is updated to v3 core with the plugins For permissions: on both iOS and Android, the permission isn't prompted until your code uses said permission. So the first time a user uses the Camera, it will show the permission but in the future it would not. If you want to prompt for a specific permission before anything happens (which personally I wouldn't, bad UX) you add an empty permission request in your native code in // Example swift code for camera permission
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .authorized: // The user has previously granted access to the camera.
self.setupCaptureSession()
case .notDetermined: // The user has not yet been asked for camera access.
AVCaptureDevice.requestAccess(for: .video) { granted in
if granted {
self.setupCaptureSession()
}
}
case .denied: // The user has previously denied access.
return
case .restricted: // The user can't grant access due to restrictions.
return
} Android example if (Context.checkSelfPermission(this.getApplicationContext(), Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
// Permission is already accepted
} else if (shouldShowRequestPermissionRationale(...)) {
// Show prompt to user saying why you need said permission
showInContextUI(...);
} else {
// Ask for permission
requestPermissionLauncher.launch(Manifest.permission.CAMERA);
} |
Beta Was this translation helpful? Give feedback.
-
Thomas,
Thanks for the link to the test app, I will check it out.
I was talking about the app in v3 docs that gets installed when I do npm
init @capacitor/app.
…On Thu, May 20, 2021, 8:32 AM Thomas Vidas ***@***.***> wrote:
Hello 👋
Which sample basic app are you referring to? We have a test app here
<https://github.com/ionic-team/capacitor-testapp> that is updated to v3
core with the plugins
For permissions: on both iOS and Android, the permission isn't prompted
until your code uses said permission. So the first time a user uses the
Camera, it will show the permission but in the future it would not.
If you want to prompt for a specific permission before anything happens
(which personally I wouldn't, bad UX) you add an empty permission request
in your native code in AppDelegate.swift for iOS and in MainActivity.java
for Android
// Example swift code for camera permission
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .authorized: // The user has previously granted access to the camera.
self.setupCaptureSession()
case .notDetermined: // The user has not yet been asked for camera access.
AVCaptureDevice.requestAccess(for: .video) { granted in
if granted {
self.setupCaptureSession()
}
}
case .denied: // The user has previously denied access.
return
case .restricted: // The user can't grant access due to restrictions.
return
}
Android example
if (Context.checkSelfPermission(this.getApplicationContext(), Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
// Permission is already accepted
} else if (shouldShowRequestPermissionRationale(...)) {
// Show prompt to user saying why you need said permission
showInContextUI(...);
} else {
// Ask for permission
requestPermissionLauncher.launch(Manifest.permission.CAMERA);
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4591 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFO3GI35TLKGXLBLQ5TNC2DTOUTSVANCNFSM45FJXTHQ>
.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The Capacitor3 sample basic app appears to still use Capacitor.Plugins.
Will there be a V3 sample app that uses import for plugins?
It shouldn't be too hard when embedding it in a
<script type='module'> Related question: can I specify that the permissions prompt (only for used plugins) comes during first app start even when using Capacitor.Plugins? If so, how?Beta Was this translation helpful? Give feedback.
All reactions