> 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/nfc-wallet-sdk-ios/es/get-started/configuration/4.-push-notifications/handle-push-tokens.md).

# Gestionar tokens push

## Regístrese para recibir notificaciones push

### Registrar APNs y FCM

El siguiente ejemplo muestra una configuración típica de iOS:

* Configure Firebase.
* Solicite permisos de notificación.
* Regístrese en APNs.
* Proporcione el token de APNs a Firebase Messaging.

{% hint style="info" %}
La configuración de FCM (configuración del proyecto de Firebase, entitlements, clave de APNs, etc.) queda fuera del alcance de esta guía.

Para obtener detalles de la configuración, consulte [Introducción a FCM](https://firebase.google.com/docs/cloud-messaging), [Descripción general de la arquitectura de FCM](https://firebase.google.com/docs/cloud-messaging/fcm-architecture) y [Acerca de los mensajes de FCM](https://firebase.google.com/docs/cloud-messaging/concept-options).
{% endhint %}

{% code title="Registrar APNs y FCM" %}

```swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        // ...
        
        // Usa la biblioteca de Firebase para configurar las API
        FirebaseApp.configure()

        // Registrar notificación de usuario 
        let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
        application.registerUserNotificationSettings(settings)
      
        // Registro de Firebase 
        Messaging.messaging().delegate = self
        // Registrarse para notificaciones remotas 
        application.registerForRemoteNotifications()
        return true
}
```

{% endcode %}

## Actualizar el token push en NFC Wallet

El token push puede cambiar (por ejemplo, después de reinstalar la app o cuando Firebase actualiza el token). Cuando esto ocurre, su aplicación de billetera digital debe notificar al SDK de NFC Wallet llamando a `NotificationService.updatePushToken`.

{% hint style="info" %}
El SDK de NFC Wallet detecta cuando el token no ha cambiado y evita llamadas innecesarias al backend de NFC Wallet.
{% endhint %}

```swift
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
    guard let fcmToken else { return }
      do {
          // actualizar el token push 
          let notificationService = try NotificationService()
          try await notificationService.updatePushToken(token)
        } catch {
          // gestión de errores
        }
}
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-ios/es/get-started/configuration/4.-push-notifications/handle-push-tokens.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
