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

# Handle push tokens

## Register for push notifications

### Register APNs and FCM

The example below shows a typical iOS setup:

* Configure Firebase.
* Request notification permissions.
* Register with APNs.
* Provide the APNs token to Firebase Messaging.

{% hint style="info" %}
FCM configuration (Firebase project setup, entitlements, APNs key, and so on) is out of scope for this guide.

For setup details, see [FCM Introduction](https://firebase.google.com/docs/cloud-messaging), [FCM Architectural Overview](https://firebase.google.com/docs/cloud-messaging/fcm-architecture) and [About FCM messages](https://firebase.google.com/docs/cloud-messaging/concept-options).
{% endhint %}

{% code title="Register APNs and FCM" %}

```swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        // ...
        
        // Use Firebase library to configure APIs
        FirebaseApp.configure()

        // Register user notification 
        let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
        application.registerUserNotificationSettings(settings)
      
        // Firebase register 
        Messaging.messaging().delegate = self
        // Register for Remote Notification 
        application.registerForRemoteNotifications()
        return true
}
```

{% endcode %}

## Update the push token in NFC Wallet

The push token can change (for example, after an app reinstall or when Firebase refreshes the token). When this happens, your digital wallet application must notify the NFC Wallet SDK by calling `NotificationService.updatePushToken`.

{% hint style="info" %}
The NFC Wallet SDK detects when the token is unchanged and avoids unnecessary calls to the NFC Wallet backend.
{% endhint %}

```swift
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
    guard let fcmToken else { return }
      do {
          // update push token 
          let notificationService = try NotificationService()
          try await notificationService.updatePushToken(token)
        } catch {
          // error handling
        }
}
```


---

# 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:

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

The question should be specific, self-contained, and written in natural language.
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.
