Push Notifications Configuration

Configure no-code push notifications in Appflow.ai to engage with your end users flexibly.


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.

.p12 certificate uploaded to Appflow.ai should be the same as the .p12 certificate in your app

1. Create a distribution certificate

a. Go to Apple Developer Center, navigate to Certificates, Identifiers & Profiles, in the Certificates section, click the "plus" button to create a new Distribution Certificate.

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

c. Select the App ID to "Continue";

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.

c. Fill info and "Saved to disk" to continue. You can learn more from this Apple doc:

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.

b. Download your Certificate, you will have an _aps.cer _file on your Mac

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 into.p12 file,

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"

b. Double click to add "Push Notification"

2. Request PushNotifications Permissions in AppDelegate

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

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

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.

Last updated