SDK

Implementation

If you are using Loyalty v2 passes, you only need to include the notificare-loyalty dependency and nothing else. We automatically delegate incoming push notification passes to the Google Wallet app when available, otherwise to the Google Wallet website.

Legacy

If you are still using Loyalty v1 passes, there are a few more steps you will need to take care of. Let's dive deeper into how passes are handled in your Android app.

In order for our library to be able to open passes distributed via a push notification, a link in an email or in a website you need to declare an activity like the one below in your AndroidManifest.xml.

<activity
    android:name="re.notifica.loyalty.PassbookActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="${notificareApplicationId}.applinks.notifica.re"
            android:pathPrefix="/pass"
            android:scheme="https" />
    </intent-filter>
</activity>

Make sure you replace the ${notificareApplicationId} with your app's actual ID. You can find it in our dashboard as described here. Adding this entry to your AndroidManifest.xml is all it takes to start handling digital cards.

There are also a couple of options for passes. If you wish that a pass is constantly shown in the lock screen (even if the user dismisses it) while it is relevant, you should provide the following option.

<application>
    <meta-data
        android:name="re.notifica.loyalty.pass_notification_ongoing"
        android:value="true" />
</application>

Please note that the relevance functionality is only available when the notificare-geo module is being used and the user has granted the appropriate permissions.

By default, the relevance notification will be shown in the default channel from the Push module. If you are not using it, or would like to define a custom channel for the relevance notification, you can use the following property.

<application>
    <meta-data
        android:name="re.notifica.loyalty.pass_notification_channel"
        android:value="pass_notification_channel" />
</application>

You can also provide a default relevant text, which will be shown whenever a pass is relevant and a value for this field has not been included in the pass.

<application>
    <meta-data
        android:name="re.notifica.loyalty.pass_relevance_text"
        android:value="A pass that is relevant for the current location is in the wallet." />
</application>

Finally, you can also override the pass' icon which is included in the pass and provide yourself a different resource. This icon will be shown in the lock screen whenever the pass is relevant or its values have changed.

<application>
    <meta-data
        android:name="re.notifica.loyalty.pass_notification_small_icon"
        android:resource="@drawable/ic_baseline_style_24" />
</application>

Wallet

Just like with the inbox, a list of passes is also exposed as LiveData to allow you to build an in-app wallet.

Notificare.loyalty().observablePasses.observe(this) { passes ->

}
NotificareLoyaltyCompat.getObservablePasses();

You can, at any point in your application, just retrieve the list of passes stored in your application.

Notificare.loyalty().passes
NotificareLoyaltyCompat.getPasses();

In most cases you will only need to use our default UI to handle passes. But there might be situations where you might want to obtain a pass object to, let's say, retrieve its contents. If you know the pass serial number, or barcode, you can use the methods below to retrieve a serialized model.

Notificare.loyalty().fetchPassBySerial(serial, object : NotificareCallback<NotificarePass> {
    override fun onSuccess(result: NotificarePass) {

    }

    override fun onFailure(e: Exception) {

    }
})

Notificare.loyalty().fetchPassByBarcode(barcode, object : NotificareCallback<NotificarePass> {
    override fun onSuccess(result: NotificarePass) {

    }

    override fun onFailure(e: Exception) {

    }
})
NotificareLoyaltyCompat.fetchPassBySerial(serial, new NotificareCallback<NotificarePass>() {
    @Override
    public void onSuccess(NotificarePass result) {

    }

    @Override
    public void onFailure(@NonNull Exception e) {

    }
});

NotificareLoyaltyCompat.fetchPassByBarcode(barcode, new NotificareCallback<NotificarePass>() {
    @Override
    public void onSuccess(NotificarePass result) {

    }

    @Override
    public void onFailure(@NonNull Exception e) {

    }
});

Additionally, if you need to present the fetched pass to the user, you can call the following method.

Notificare.loyalty().present(activity, pass)
NotificareLoyaltyCompat.present(activity, pass);