Hello everyone, I recently migrated an old ionic4 angular cordova application to ionic8 angular capacitor app, but I am facing some strange issues with permissions request on IOS. I added the camera Plugin (Camera | Capacitor Documentation) and added the requirements in info.plist as suggested, but when I deploy the app on ios device (Iphone 8) using testFlight, the system is really slow to show the permission prompt (about 10/15 minutes too). After the permission prompt appears and I give the permission, the camera works correctly, but after first install when I call the camera functionality nothing happens and i have to wait many minutes to see the permission prompt.
Do you have some suggestions about this issue?
If anyone is available to help, i can give you more details if needed
Your code showing the permission request and other camera interaction would be helpful.
Hello, thanks for your answer, here is my code:
import { Camera, CameraDirection, CameraResultType, CameraSource, ImageOptions } from '@capacitor/camera';
[...]
public async takePhoto(options?: any) {
const capturedPhoto = await Camera.getPhoto({
resultType: options.resultType ? options.resultType : CameraResultType.DataUrl, //'uri' | 'dataUrl' | 'base64'
source: options.source ? options.source : CameraSource.Photos, //'CAMERA' | 'PHOTOS' | 'PROMPT'
quality: options.quality ? options.quality : 60,
allowEditing: options.allowEditing ? options.allowEditing : false
});
return capturedPhoto;
}
I called takePhoto() from (click) event on button.
I also tried forcing request permission calling this on class constructor:
checkCameraPermission() {
Camera.checkPermissions().then((res) => {
console.log(res);
if (res.camera !== 'granted') {
Camera.requestPermissions({ permissions: ['camera'] });
}
if (res.photos !== 'granted') {
Camera.requestPermissions({ permissions: ['photos'] });
}
});
}
but it stills takes minutes to show the permission prompt on several iOS devices, maybe could be testFlight issue?
here my info.plist too
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>appName</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.6.6</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>App requires permission to take photos</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>App requires permission to access photo library</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>App requires permission to access photo library</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>App requires permission to access device position</string>
<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>App requires permission to access device position</string>
</dict>
</plist>
Thanks a lot