Camera plugin - Android target 33


I had to update my ionic2 project to target version 33 of android and now the action of selecting an image from the gallery doesn’t work for me.

The code is the following

      destinationType: Camera.DestinationType.DATA_URL,
      sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
      mediaType: Camera.MediaType.PICTURE,
      allowEdit: true,
      (imageData) => {
        this.base64Image = "data:image/jpeg;base64," + imageData;;
          (url) => {
          (error) => {
      (err) => {
        console.log(err); **// always end here **

It always gives me error 20, which apparently is a permissions issue… but I don’t know how to make the app request permissions from the user at this point.

Any ideas?

Thank you so much.

Capacitor 4 doesn’t support to target SDK 33, you’ll have to wait until Capacitor 5 is released with official support.
If you target SDK 32 the app will still work on Android 13 devices.

Hi @julio-ionic

Thanks for answering.

This project, which has been inherited, does not use capacity. Makes use of cordova for the camera

I haven’t been in the ionic world for a long time.

Could I make use of capacitor having the rest of the plugins with cordova?

cordova-android 11 doesn’t support SDK 33 neither yet, so you’ll have to wait for cordova-android 12 and keep using target SDK 32.

Capacitor has compatibility with most Cordova plugins, but not all, so it will depend on the plugins you use they will just work or you’ll need to switch to a Capacitor alternative (if it exist)

So either way, you have to wait for the next Capacitor or Cordova release and keep using target SDK 32 instead of 33.

Before I was using target 31 (which is what Google forced me to update to be able to upload the app), but I had a problem with the notifications since it didn’t ask the user if he wanted to activate them… when going to target 33, this is done by the onesignal plugin… Is there a way to request permissions when I use target 32?

I tried with the ‘cordova-plugin-android-permissions’ plugin, but I don’t know if I used it wrong, because the window requesting them never appears

Sadly no, the notifications permission is an Android 13 thing and you have to target SDK 33 for being able to request the permission when you want.
When targeting SDK 31-32 the permission will be automatically requested when you create a notification channel or on next app launch after you have created a notification channel (depends on the device, you can’t control it).

I think I’m a bit screwed… :frowning:
And for another type of permission, could it be requested in typescript code? I’m having problems with the SocialSharing and Camera plugins (both from cordova).

The one with the camera is surely a matter of permits, but I am not able to request them on my own.

I don’t think SocialSharing needs any permissions.
Camera plugin request the permission right before opening the phone gallery to pick pictures (no permission is needed for opening the Camera on Android)
The plugin doesn’t provide a way of requesting the permissions programmatically.

But not even using the ‘cordova-plugin-android-permissions’ plugin could you request permissions before making the call to the image gallery?

I’m not familiar with that plugin, so not sure, but should be possible.