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