SDK

Scannables

This functionality will allow your app to present content after they have scanned a NFC Tag or QR Code (we use QR Codes whenever the device does not support NFC). This could be extremely useful if you're looking to extend physical objects with engaging content pretty much the same way you do when sending a notification.

Before you can start using this functionality you will need to create one or more tags in our dashboard. This is covered in our guides located here.

By default, we include an activity that is shown when a scannable session is started. If you need to customise it, for instance, the theme, add the following to your AndroidManifest.xml file:

<activity
    android:name="re.notifica.scannables.ScannableActivity"
    android:theme="@style/Theme.App" />

When NFC is not supported or disabled, our library will fall back to scanning QR codes.

In most cases you will want to start scanning a tag whenever the user opens your app and clicks a button in your UI. This would be done from one your app's components like this:

await NotificareScannables.startScannableSession();

You can also check manually if the device supports NFC scannable sessions and act accordingly.

if (await NotificareScannables.canStartNfcScannableSession) {
  await NotificareScannables.startNfcScannableSession();
} else {
  await NotificareScannables.startQrCodeScannableSession();
}

Once the user taps a NFC tag or scans a QR code, your app will be responsible for handling the results. In the component that started the session you would then implement the following:

NotificareScannables.onScannableDetected.listen((scannable) async {
  final notification = scannable.notification;
  if (notification != null) {
    await NotificarePushUI.presentNotification(notification);
  }
});

NotificareScannables.onScannableSessionFailed.listen((error) {

});

This will make sure that as soon as the NFC tag is scanned your app will be able to handle results and present the content accordingly.