ios_app_v2/yobble/PushAppDelegate.swift
2025-12-03 05:47:52 +03:00

56 lines
2.1 KiB
Swift
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

////
//// PushAppDelegate.swift
//// yobble
////
//// Created by cheykrym on 02.12.2025.
//// 72acf38bfbf0e990f745a612527911f8df1d63d60de70d41391c54b52498f7ab
//
//import UIKit
//import UserNotifications
//
//class PushAppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {
//
// // Запрос разрешения на уведомления
// func application(_ application: UIApplication,
// didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
//
// UNUserNotificationCenter.current().delegate = self
//
// UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
// guard granted else {
// print(" User denied push notifications")
// return
// }
//
// DispatchQueue.main.async {
// UIApplication.shared.registerForRemoteNotifications()
// }
// }
//
// return true
// }
//
// // Получаем пуш-токен устройства
// func application(_ application: UIApplication,
// didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
//
// let token = deviceToken.map { String(format: "%02x", $0) }.joined()
// print("📨 Device Token:", token)
// }
//
// // Ошибка регистрации
// func application(_ application: UIApplication,
// didFailToRegisterForRemoteNotificationsWithError error: Error) {
// print(" Failed to register for remote notifications:", error)
// }
//
// // Пуш пришёл в форграунде
// func userNotificationCenter(_ center: UNUserNotificationCenter,
// willPresent notification: UNNotification,
// withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
//
// // показываем алерт даже если приложение открыто
// completionHandler([.banner, .sound, .badge])
// }
//}