Skip to main content
Question

The iOS device is not showing in Dashboard of Klaviyo.


Forum|alt.badge.img

for enabling iOS i creating key uploaded on Klaviyo provided all the details to Klaviyo now in code I added the public API key. but still when i install on the device the no people growth seen on the dashboard.

import KlaviyoSwift
import UserNotifications
import UIKit

// MARK: - App Delegate Implementation
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Initialize Klaviyo with your PUBLIC API key
        KlaviyoSDK().initialize(with: "MY PUBLIC KEY")

        // Configure notification center
        let center = UNUserNotificationCenter.current()
        center.delegate = self

        // Request notification permissions
        let options: UNAuthorizationOptions = [.alert, .sound, .badge]
        center.requestAuthorization(options: options) { granted, error in
            if let error = error {
                print("Authorization error: \(error.localizedDescription)")
                return
            }

            // Always register for remote notifications regardless of authorization status
            // This ensures Klaviyo gets the latest authorization status
            DispatchQueue.main.async {
                UIApplication.shared.registerForRemoteNotifications()
            }
        }

        return true
    }

    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        // Convert token to string for debugging
        let tokenString = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
        print("APNs Device Token: \(tokenString)")

        // Register token with Klaviyo
        KlaviyoSDK().set(pushToken: deviceToken)

        print("User properties set successfully.")
    }

    func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
        print("Failed to register for remote notifications: \(error.localizedDescription)")
    }

    // MARK: - Notification Handling
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        // Handle Klaviyo notifications and deep links
        let handled = KlaviyoSDK().handle(
            notificationResponse: response,
            withCompletionHandler: completionHandler
        ) { url in
            print("Handling deep link: \(url.absoluteString)")
            // Add deep link navigation logic here
        }

        if !handled {
            completionHandler()
        }
    }

    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        // Show notifications even when app is in foreground
        if #available(iOS 14.0, *) {
            completionHandler([.list, .banner, .sound])
        } else {
            completionHandler([.alert, .sound])
        }
    }
}

Please Guide me is there any issues in my code

Did this topic or the replies in the thread help you find an answer to your question?

2 replies

Byrne C
Community Manager
Forum|alt.badge.img+15
  • Community Manager
  • 127 replies
  • March 17, 2025

Hi ​@Rushikesh_157,

Are you still experiencing issues setting this up? It appears that you’ve connected your IOS app to Klaviyo using the steps outlined in this article, correct? Is Klaviyo showing that your app is connected to Klaviyo? When somebody downloads your app and allows push notifications, is their profile sent to Klaviyo, or is this not yet occurring? I realize I’m asking a lot of questions, but I want to ensure that I fully understand the issue. Looking forward to your response.

-Byrne


Forum|alt.badge.img
  • Author
  • Contributor I
  • 2 replies
  • March 17, 2025

Hi ​@Byrne C Yes I'm still facing the same issue. And yes I followed the above article to build the code. klaviyo is not showing new iOS user profile in the dashboard. They also allows the push notifications still the klaviyo not able to fetch there profile and show in dashboard.