> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/click-to-pay/es/integrate-the-d1-sdk/getting-started/configuration/4.-push-notifications/push-notification-configuration.md).

# Configuración de notificaciones push

The D1 solution supports the push notification using the following services:

* **NFC payment**
  * Firebase Cloud Messaging (FCM) (for Android devices using Google services)
  * Huawei Mobile Services (HMS) core (for Huawei devices with no Google services).
* **3DS**
  * Firebase Cloud Messaging (FCM) (for Android devices using Google services)
  * Apple Push Notification Services (APNs) (for iOS devices).
* **Card issued by D1**
  * Firebase Cloud Messaging (FCM) (for Android devices using Google services)
  * Apple Push Notification Services (APNs) (for iOS devices).

{% hint style="warning" %}
3DS does not support Huawei devices without Google services.
{% endhint %}

The D1 solution supports the push notification using Firebase Cloud Messaging (for Android devices using Google services) or HMS core (for Huawei devices with no Google services). The issuer application receives the notifications and shall pass them to the D1 SDK.

When using this feature, the issuer application will need to pass the received push notification payload to D1 SDK.

The push notifications are data messages to be handled silently by the issuer application.

### Android: Fetch FCM API keys

Refer to the [Firebase Setup](https://firebase.google.com/docs/cloud-messaging/android/client). The FCM API key must be shared with Thales delivery team. Contact the Thales delivery team for further actions on the implementation of push notifications.

### Android: Fetch HMS Push Kit configuration (NFC Wallet only)

Refer to the [HMS Push Kit](https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/service-config-0000001050040166) and [HMS Authentication](https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/open-platform-oauth-0000001050123437). The HMS Push Kit configuration must be shared with Thales delivery team. Contact the Thales delivery team for further actions on the implementation of push notifications.

The solution supports two types of authentications:

* OAuth 2.0 authentication
* API key authentication

### Android: Set runtime notification permission

For apps targeting API level 33, the application must handle the runtime permission `uses-permission android:name="android.permission.POST_NOTIFICATIONS"` in order to post notification in the Notification panel.

{% code title="AndroidManifest.xml" lineNumbers="true" %}

```java
<manifest>
  <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
  <application>
    ...
  </application>
</manifest>
```

{% endcode %}

For more details, refer to [Notification runtime permission](https://developer.android.com/develop/ui/views/notifications/notification-permission).

### iOS: Set up APNs certificates

Refer to the [Certificate-based connection to APNS](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_certificate-based_connection_to_apns_). The generated certificates must be shared with the Thales delivery team. Certificates should be generated for both sandbox and production environments. Contact the Thales delivery team for further actions on the implementation of push notifications.

For cards issued by D1, the notification contains a messageID and requires further processing by D1 SDK, as described in [message handling](https://app.gitbook.com/o/fwy1mtbRONGA2YDKDBr0/s/62lLFDcmLCeqqwmy4Fee/integrate-d1-sdk/getting-started/configuration/4.-push-notifications/message-handling). To enable such additional processing, the permission for background notification is required. Refer to the [Pushing background updates to your App](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app) for more details.

<figure><img src="/spaces/62lLFDcmLCeqqwmy4Fee/files/kv1UIqiz4IPLAbw08Cy3" alt=""><figcaption><p>Enable background notifications for iOS</p></figcaption></figure>

### Update push token

Before being able to receive notifications from D1 backend, the issuer application must register the push notification token obtained from FCM or HMS.

<div align="left"><figure><img src="/spaces/62lLFDcmLCeqqwmy4Fee/files/jpnwIF2VRFqTAD3914Cl" alt=""><figcaption><p>Register the push token with the D1 backend</p></figcaption></figure></div>

{% tabs fullWidth="false" %}
{% tab title="Android - FCM Push Notification" %}
{% code lineNumbers="true" %}

```java
public class D1FirebaseService extends FirebaseMessagingService {
    private D1Task d1Task = null;

    @Override
    public void onNewToken(@NonNull String token) {
        if (d1Task == null) {
            d1Task = new D1Task.Builder()
                    .setContext(getApplicationContext())
                    .build();
        }

        // To update the D1 backend with the latest push token, the `D1Task.login` method 
        // has to be called before invoking the `D1Task.updatePushToken()` method 
        // when the following features are used:
        //  * Click to Pay 
        //  * Messaging Service
        //
        // For NFC Wallet and 3DS features, the D1 SDK does not require the initialisation 
        // to call `D1Task.updatePushToken()`; it only requires an Android `Context`.
        d1Task.updatePushToken(token, new D1Task.Callback<Void>() {
            @Override
            public void onSuccess(@Nullable Void ignored) {
                // Proceed with subsequent flows.
            }

            @Override
            public void onError(@NonNull D1Exception exception) {
                // Refer to D1 SDK Integration – Error Management section.
            }
        });

        // Other application logic.
    }

    // ...
}
```

{% endcode %}
{% endtab %}

{% tab title="iOS - APNs" %}

```swift
extension AppDelegate {
    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
        let token = tokenParts.joined()

        if d1Task == nil {
            var comp = D1Task.Components()
            d1Task = comp.task()
        }

        d1Task.updatePushToken(deviceToken) { [weak self] error in
            if error == nil {
                // Proceed with subsequent flows.
            } else {
                // Refer to D1 SDK Integration – Error Management section.
            }
            
            // Other application logic ...
        }
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}

* Support push token renewal in the issuer application. Notify the D1 SDK using `D1Task.updatePushToken()`.
* If the push token comes from Huawei Mobile Services (HMS), prefix the value with `HMS:` during configuration or refresh. This lets the D1 backend select the correct push service.
* Call `D1Task.login()` before `D1Task.updatePushToken()` when you use:
  * Click to Pay
  * Messaging Service
* For NFC Wallet and 3DS, the D1 SDK does not require initialization before calling `D1Task.updatePushToken()`. It only requires an Android `Context`.
* If you combine Click to Pay or Messaging Service with NFC Wallet or 3DS, call `D1Task.login()` before `D1Task.updatePushToken()`.
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/click-to-pay/es/integrate-the-d1-sdk/getting-started/configuration/4.-push-notifications/push-notification-configuration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
