---
title: "iOS SDK: Push notifications"
description: "Set up push notifications for customer messages with the Gleap iOS SDK. Follow the integration code examples."
url: https://docs.gleap.ai/en/articles/441-ios-sdk-push-notifications
collection: "iOS"
updated: 2026-11-01
language: en
---

# iOS SDK: Push notifications

Set up push notifications for customer messages with the Gleap iOS SDK. Follow the integration code examples.

Stay connected with your customers by utilizing push notifications to alert them of new chat messages, release notes, and news articles. This will deepen engagement and foster stronger relationships.

Gleap supports [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) to send push notifications to users.

## Setup Firebase Cloud Messaging

To make use of Gleap Push Notifications you must add the Firebase Cloud Messaging service to your app or website. Learn how to get started with FCM [here](https://firebase.google.com/docs/cloud-messaging).

## Getting your Firebase Cloud Messaging Token

Open your project in Firebase and open the project settings.

Click on "Cloud Messaging" and, if it is not already enabled, activate the Firebase Cloud Messaging API (V1).

![Firebase Cloud Messaging API v1 settings in the existing example project.](https://staticfiles.gleap.io/p613b5dd730aed737108f87ab/EXsrhvuamORx0xa4YtpmZJLx4XMOleKSVb6TBLALNylbZ14MDv1sYjLjJyqQKq2vtu3fAsIo4uf.png)

Proceed to the "Service Accounts" section and generate a new private key, which will automatically create a file named like `serviceAccountKey.json`.

![Firebase service-account setup in the existing example project. No private key is displayed.](https://staticfiles.gleap.io/p613b5dd730aed737108f87ab/3L6WWg4TfpUDuiPLiyLesRpKNB76FF1eO4geLNXJnFQPDCnJqHFf0jyWRy7EArmsw8yjT2uITrs.png)

In Gleap, open Settings → Developer → Push notifications and upload the Firebase service-account JSON file. Keep the file private; it authorizes push delivery for the Firebase project.

![Push notification service-account file upload. No credential is shown.](https://staticfiles.gleap.io/p613b5dd730aed737108f87ab/P0ExxlppVbgauOrnK6goEgpy9DwTz5Ov3oHyxwBLNQNVfiXkOmA5Fs7cHQPhzZnopvdi2bMl7dL.png)

## Subscribe to the Gleap user topic

The last step to complete the push notification setup is to subscribe to the user topic, which Gleap will send the push notifications to. In order to do so, you will need to register the register & unregister push message topic callbacks.

```javascript
import Foundation
import UIKit
// Don't forget the imports
import Gleap
import Firebase
import FirebaseMessaging

// Add the GleapDelegate protocol to your view controller
class DemoViewController: UIViewController, GleapDelegate {

    override func viewDidLoad() {
        // Assign self to the delegate
        Gleap.sharedInstance().delegate = self;
    }

    func registerPushMessageGroup(_ pushMessageGroup: String) {
        // Register topic
        Messaging.messaging().subscribe(toTopic: pushMessageGroup) { error in }
    }

    func unregisterPushMessageGroup(_ pushMessageGroup: String) {
        // Unregister topic
        Messaging.messaging().unsubscribe(fromTopic: pushMessageGroup) { error in }
    }
}
```

That's it - build and run your app 🚀

## Handle push-notifications click

In order to open the message, the user clicked on, you will need to add some extra code to your app. The idea is to get the data from the push notification and then pass it to the SDK by utilizing handlePushNotification().

Please note depending on your specific code, the callbacks might be different. The important part is to forward the notification data to `Gleap.handlePushNotification()`.

```js
import UIKit
import Foundation
import Gleap

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    @available(iOS 10.0, *)
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content.userInfo
        print("Handle push from background or closed \(userInfo)")

        // Check for specific notification indicating it's from "GLEAP"
        if let sender = userInfo["sender"] as? String, sender == "GLEAP" {
            Gleap.handlePushNotification(userInfo)
        }

        completionHandler()
    }

    // Add other necessary AppDelegate methods...
}
```

## Notification images

When a changelog or news article with a featured image is sent as a push notification, Gleap includes the image in the push payload (`mutable-content` is set and the image URL is delivered via `fcm_options.image`).

On iOS, displaying an image in a notification requires a **Notification Service Extension** in your app — without it, the notification is still delivered, just without the image.

1.  In Xcode, select **File → New → Target…** and choose **Notification Service Extension**.
    
2.  Add the `FirebaseMessaging` dependency to the new extension target (via Swift Package Manager or CocoaPods).
    
3.  Replace the generated `NotificationService.swift` with:
    

```js
import UserNotifications
import FirebaseMessaging

class NotificationService: UNNotificationServiceExtension {

    var contentHandler: ((UNNotificationContent) -> Void)?
    var bestAttemptContent: UNMutableNotificationContent?

    override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
        self.contentHandler = contentHandler
        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

        guard let bestAttemptContent = bestAttemptContent else { return }

        // Downloads the image from fcm_options.image and attaches it to the notification.
        Messaging.serviceExtension().populateNotificationContent(bestAttemptContent, withContentHandler: contentHandler)
    }

    override func serviceExtensionTimeWillExpire() {
        if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
            contentHandler(bestAttemptContent)
        }
    }
}
```

## Related

- [iOS SDK setup](https://docs.gleap.ai/en/articles/434-ios-sdk-setup.md)
- [iOS SDK: User identity](https://docs.gleap.ai/en/articles/435-ios-sdk-user-identity.md)
- [iOS SDK: Callbacks](https://docs.gleap.ai/en/articles/436-ios-sdk-callbacks.md)
- [iOS SDK: Frontend tools](https://docs.gleap.ai/en/articles/437-ios-sdk-frontend-tools.md)
- [iOS SDK: Forms](https://docs.gleap.ai/en/articles/438-ios-sdk-forms.md)
