> For the complete documentation index, see [llms.txt](https://doc.appflow.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.appflow.ai/docs/sdk-set-up-instructions/ios-sdk/push-notifications-configuration.md).

# Push Notifications Configuration

***

You can create and send event-based push notifications via Appflow\.ai without coding. Please, follow this doc to complete the one-time configuration.

## **Upload .p12 certificate to Appflow\.ai**

Appflow\.ai requires Apple Push Notifications service (APNs) with the .p12 certificate to send push notifications on the iOS platform, which is the unified key to send push notifications in sandbox and production.

{% hint style="warning" %}

#### <mark style="color:orange;">.p12 certificate uploaded to Appflow\.ai should be the same as the .p12 certificate in your app</mark>

{% endhint %}

### 1. Create a distribution certificate

a. Go to Apple Developer Center, navigate to [**Certificates, Identifiers & Profiles**](https://developer.apple.com/account/resources/certificates/list), in the **Certificates** section, click the "plus" button to create a new Distribution Certificate.

<figure><img src="/files/ZwLe0MQumr9nkNOi7zAO" alt=""><figcaption></figcaption></figure>

b. Choose **Apple Push Notification service SSL (Sandbox & Production)** in **Services**, then "Continue";

<figure><img src="/files/DWJPGNi9bd6hzhLrTKf3" alt=""><figcaption></figcaption></figure>

c. Select the **App ID** to "Continue";

<figure><img src="/files/hK1l9BAlpiwJh32OMARz" alt=""><figcaption></figcaption></figure>

Then, you will be asked to Upload a Certificate Signing Request (CSR) file to continue.

### 2. Create a Certificate Signing Request(CSR) file

a. Open KeyChain Access on your Mac\
b. Choose Keychain Access > Certificate Assistant > Request a Certificate from a Certificate Authority.

<figure><img src="/files/cfKJIS8LO6rm03jOGCSK" alt=""><figcaption></figcaption></figure>

c. Fill info and "**Saved to disk**" to continue. You can learn more from this [Apple doc](https://developer.apple.com/help/account/create-certificates/create-a-certificate-signing-request):

<figure><img src="/files/h5ODPNDhK08McBMlbqGE" alt=""><figcaption></figcaption></figure>

Now you have the *Certificate Signing Request (CSR) file* on your Mac.

### 3. Upload CSR file to continue

a. Back to **Apple Developer Center**, upload the *Certificate Signing Request (CSR) file* to continue.

<figure><img src="/files/3HIvB3jQbs0pP1X7VLlt" alt=""><figcaption></figcaption></figure>

b. Download your Certificate, you will have an \_**aps.cer** \_file on your Mac

<figure><img src="/files/mKzODdFUYiN6qlb7VXhG" alt=""><figcaption></figcaption></figure>

### 4. Convert **aps.cer** to **.p12** file:

a. double click "aps.cer" file to install in Keychain Access;\
b. if the certificate is not trusted, you need to trust the certificate.\
c. Export the file int&#x6F;**.p12** file,

<figure><img src="/files/RNqNd99C3t2wWkvBHT77" alt=""><figcaption></figcaption></figure>

d. You'll be asked "Enter a password",**Please DO NOT enter a password here**, just click "OK" to proceed. Then the .p12 file is saved on your Mac.

### 5. Upload .p12 file to Appflow\.ai

Go to Appflow\.ai Dash => Settings => Applications => Select the App to **Edit**

Now you can upload the **.p12** file to Appflow\.ai.

***

## **Configure Notifications on Your App**

### 1. Capabilities

You need to enable Push Notifications services on your project:

a. Your App Target => Signing & Capabilities => click " + Capabilities"

<figure><img src="/files/Li4YKTc3UjHr7MRkmqdu" alt=""><figcaption></figcaption></figure>

b. Double click to add "Push Notification"

<figure><img src="/files/VFAOvgcCr4qxt5GvPcns" alt=""><figcaption></figcaption></figure>

### 2. Request PushNotifications Permissions in AppDelegate

```swift
private func requestPushNotificationsPermissions() {
    let userNotificationCenter = UNUserNotificationCenter.current()
    userNotificationCenter.requestAuthorization(options: [.alert, .sound, .badge]) { [weak self] granted, error in
        print("Permission granted: \(granted)")
        if granted {
            self?.getNotificationSettings()
        }
    }
}
```

### 3. Permission request completed, get notification settings

```swift
private func getNotificationSettings() {
    UNUserNotificationCenter.current().getNotificationSettings { settings in
        print("Notification settings: \(settings)")
        guard settings.authorizationStatus == .authorized else { return }
        DispatchQueue.main.async {
            UIApplication.shared.registerForRemoteNotifications()
        }
    }
}
```

### 4. Successfully register APNs and report DeviceToken

```swift
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    let deviceToken = deviceToken.reduce("", { $0 + String(format: "%02X", $1) })
    Appflow.shared.purchases.uploadDeviceInfo(deviceToken: deviceToken) { _, _ in
    }
}
```

Congrats! You've finished the remote Push Notifications configuration on Appflow\.ai. You can create push notifications in: Appflow\.ai Dash => Experiments => Push Notifications.


---

# 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://doc.appflow.ai/docs/sdk-set-up-instructions/ios-sdk/push-notifications-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.
