iOS Push Notifications in Swift (APNs, CallKit)

Swift, iOS 13+. Notifications via APNs, calls via PushKit + CallKit. No Firebase needed.

🍎 iOS

Swift, iOS 13+. Notifications via APNs, calls via PushKit + CallKit. No Firebase needed.

The SDK is free and open source (MIT) on GitHub. Create a free account to get your App ID.

  1. Add the SDK to your project

    Swift Package Manager (recommended): Xcode β†’ File β†’ Add Package Dependencies… β†’ paste the URL below and pick Up to Next Major Version from 1.0.0:

    https://github.com/DaoChiMinh/tingpush-sdk

    CocoaPods: unzip the download into your project's root folder (this creates TingPushSDK/), then:

    Podfile
    # Podfile (unzip the download into your project root)
    pod 'TingPush', :path => './TingPushSDK/ios'

    Requires iOS 13+. The SDK doesn't need Firebase.

  2. Enable capabilities in Xcode

    Target β†’ Signing & Capabilities:

    • Push Notifications
    • Background Modes β†’ tick Remote notifications and Voice over IP (for calls)
    Info.plist
    <!-- Info.plist (Xcode adds this when you tick Background Modes) -->
    <key>UIBackgroundModes</key>
    <array>
      <string>remote-notification</string>
      <string>voip</string>
    </array>
    <key>NSMicrophoneUsageDescription</key>
    <string>Microphone is used for calls</string>
  3. Initialize in AppDelegate

    Call initialize in didFinishLaunchingWithOptions: when a call arrives while the app is closed, iOS launches it in the background and the SDK must be ready immediately. SwiftUI apps: use @UIApplicationDelegateAdaptor(AppDelegate.self).

    AppDelegate.swift
    import UIKit
    import TingPush
    
    @main
    class AppDelegate: UIResponder, UIApplicationDelegate, TingPushDelegate {
    
        func application(_ application: UIApplication,
                         didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            TingPush.shared.delegate = self
            TingPush.shared.initialize(
                appId: "YOUR_APP_ID",
                callConfiguration: TingPushCallConfiguration(localizedName: "MyApp") // omit if you don't use calls
            )
            return true
        }
    
        func application(_ application: UIApplication,
                         didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
            TingPush.shared.didRegisterForRemoteNotifications(deviceToken: deviceToken)
        }
    
        func application(_ application: UIApplication,
                         didFailToRegisterForRemoteNotificationsWithError error: Error) {
            TingPush.shared.didFailToRegisterForRemoteNotifications(error: error)
        }
    
        func application(_ application: UIApplication,
                         didReceiveRemoteNotification userInfo: [AnyHashable: Any],
                         fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
            TingPush.shared.handleRemoteNotification(userInfo)
            completionHandler(.newData)
        }
    }

    The APNs environment is detected automatically: Xcode debug builds = sandbox, TestFlight/App Store = production.

  4. Assign the user at login

    Swift
    // After login — your backend targets this External ID
    TingPush.shared.login(externalUserId: "user-123")
    
    // On logout
    TingPush.shared.logout()
    
    // Tag the user for targeted sends
    TingPush.shared.setTags(["plan": "vip"])
  5. Handle notification & call events

    Swift
    extension AppDelegate {
        // User tapped a notification (even when the app was closed)
        func tingPush(didOpenNotification notification: TingPushNotification) {
            // navigate using notification.data["screen"]...
        }
    
        // Notification received while the app is open
        func tingPush(didReceiveNotification notification: TingPushNotification) {
            // notification.title, notification.body, notification.data
        }
    
        // User tapped Answer → connect the real call (WebRTC/SIP/Agora…)
        func tingPush(didAcceptCall call: TingPushCall) {
            // call.id, call.callerName, call.data["room"]
        }
    
        // CallKit activated audio: start playing/recording
        func tingPushDidActivateAudioSession() { }
    
        func tingPush(didDeclineCall call: TingPushCall) { }  // declined
        func tingPush(didEndCall call: TingPushCall) { }      // hung up
        func tingPush(didMissCall call: TingPushCall) { }     // missed
    }
    
    // The other side hung up → dismiss the call screen
    TingPush.shared.endCall(callId: call.id)

βœ… After integrating, check

  1. Run the app on a real device with logging on: you should see [TingPush] Device registered ….
  2. The project's Devices tab: the device appears; iOS devices show the VoIP badge if you use calls.
  3. The Send tab: send a test to that device.
  4. Choose πŸ“ž Call and test with the app open, closed and with the screen locked.

Ready to integrate?

Create an account to get your App ID and API Key. Dashboard samples are pre-filled with your project details.