DEV Community

Cover image for Upgrading from Capacitor 2 in 2024 - Part 4: Minor plugins
Gerhard for Reconcept

Posted on

Upgrading from Capacitor 2 in 2024 - Part 4: Minor plugins

There were a few minor plugins that also needed updating:

  • Camera
  • Rating
  • Biometrics

Camera

Capacitor provides a Camera plugin, which we could easily migrate to from the Cordova plugin.
We only had to match the Cordova CameraOptions to the Capacitor ImageOptions, and we were good to go. Both plugins returned the same result, a path to the file. This meant no further changes necessary.

Easy work, hopefully the other plugins coöporate as well.

RateApp

As all apps do, we also annoy ask the user for a review whenever possible. But both Android and iOs limit the amount of requests an app can do for a review. For instance, on iOS:

No matter how many times you call the API, the system will only show up to a maximum of 3 prompts to the same user in a 365-day period.

We used cordova-launch-review, which started in 2015 and stopped development in 2020. There was a lot of code recommended by the plugin to check if the user was actually requested for a review, and some management for asking again.

The new RateApp has a very simple recommendation:

import { RateApp } from 'Capacitor-rate-app';
RateApp.requestReview();
Enter fullscreen mode Exit fullscreen mode

So we removed all the surrounding code for the previous plugin, and now use RateApp as recommended.

Biometrics

We offer the feature to the user to use biometric validation, so they can unlock or validate documents using their fingerprint or face.
We store a PIN with this biometric authentication, which we send to the backend when validation is needed.

The Cordova plugin we used was a forked branch of cordova-plugin-keychain-touch-id. This forked branch had some required updates to work with the newer Android versions.

The first plugin we tried was Capacitor-biometric-auth, but after implementing the first steps we found out that we couldn’t store the PIN with the authentication, so we had to find something else.

Capacitor-native-biometric provided the solution we needed. Although they intended to store a username/password with the biometric authentication, we just put the PIN in the password field which worked perfectly.

The old plugin could tell us if the user had stored a value, without requiring unlocking it. This was not possible in the new plugin, which always requires unlocking before accessing the value. This means we had to do some work, and had to add a feature where we track separately if the user has set the biometrics.

Unfortunately we can’t migrate the users that use the old plugin to the new plugin. The new plugin stores the PIN in a different way, so with the update it wouldn’t work anymore. So we added a popup notification for the users that uses their biometrics that they need to provide access again.

Top comments (0)