Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 17, 2024 01:31 pm GMT

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 coporate 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();

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 couldnt 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 cant 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 wouldnt work anymore. So we added a popup notification for the users that uses their biometrics that they need to provide access again.


Original Link: https://dev.to/reconcept/upgrading-from-capacitor-2-in-2024-part-4-minor-plugins-52m8

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To