Deploy Ladill Mini / deploy (push) Successful in 35s
Ship full-featured mobile clients with auth, payments, QRs, push notifications, and iOS polish including Figtree typography, app icons, and QR previews. Co-authored-by: Cursor <cursoragent@cursor.com>
64 lines
2.0 KiB
Swift
64 lines
2.0 KiB
Swift
import FirebaseCore
|
|
import FirebaseMessaging
|
|
import UIKit
|
|
import UserNotifications
|
|
|
|
final class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
|
|
|
|
func application(
|
|
_ application: UIApplication,
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
|
) -> Bool {
|
|
FirebaseApp.configure()
|
|
|
|
UNUserNotificationCenter.current().delegate = self
|
|
Messaging.messaging().delegate = self
|
|
|
|
if launchOptions?[.remoteNotification] != nil {
|
|
Task { @MainActor in
|
|
PushNotificationRouter.shared.openInbox()
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
|
Messaging.messaging().apnsToken = deviceToken
|
|
}
|
|
|
|
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
|
#if DEBUG
|
|
print("APNs registration failed: \(error.localizedDescription)")
|
|
#endif
|
|
}
|
|
|
|
// MARK: - FCM
|
|
|
|
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
|
|
guard let fcmToken else { return }
|
|
Task { await PushTokenRegistrar.onTokenRefresh(fcmToken) }
|
|
}
|
|
|
|
// MARK: - UNUserNotificationCenterDelegate
|
|
|
|
func userNotificationCenter(
|
|
_ center: UNUserNotificationCenter,
|
|
willPresent notification: UNNotification,
|
|
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
|
|
) {
|
|
completionHandler([.banner, .sound, .badge])
|
|
}
|
|
|
|
func userNotificationCenter(
|
|
_ center: UNUserNotificationCenter,
|
|
didReceive response: UNNotificationResponse,
|
|
withCompletionHandler completionHandler: @escaping () -> Void
|
|
) {
|
|
Task { @MainActor in
|
|
PushNotificationRouter.shared.openInbox()
|
|
}
|
|
completionHandler()
|
|
}
|
|
}
|