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.
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-sdkCocoaPods: 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.
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>
Initialize in AppDelegate
Call
initializeindidFinishLaunchingWithOptions: 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.swiftimport 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.
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"])
Handle notification & call events
Swiftextension 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
- Run the app on a real device with logging on: you should see
[TingPush] Device registered β¦. - The project's Devices tab: the device appears; iOS devices show the VoIP badge if you use calls.
- The Send tab: send a test to that device.
- Choose π Call and test with the app open, closed and with the screen locked.