ThimraTV/MoviaBox/AppDelegate/AppDelegate+OpenApp.swift
2025-04-30 14:49:22 +08:00

68 lines
2.0 KiB
Swift

//
// AppDelegate+OpenApp.swift
// MoviaBox
//
// Created by on 2025/4/25.
//
import UIKit
import FacebookCore
extension AppDelegate {
func registerAPNS() {
let center = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: [.badge, .sound, .alert]) { grant, error in
if grant {
// SPRewardsAPI.requestUploadOpenNotify(completer: nil)
}
}
UIApplication.shared.registerForRemoteNotifications()
}
}
extension AppDelegate: UNUserNotificationCenterDelegate {
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// NIMSDK.shared().updateApnsToken(deviceToken)
}
///APP
// func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
// completionHandler([.badge])
// }
///app
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
completionHandler()
}
}
extension SceneDelegate {
///URLAPP
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let url = URLContexts.first?.url else {
return
}
ApplicationDelegate.shared.application(UIApplication.shared, open: url, sourceApplication: nil, annotation: [UIApplication.OpenURLOptionsKey.annotation])
}
///UniversalLink app
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
guard let webpageURL = userActivity.webpageURL else { return }
guard let query = webpageURL.query else { return }
spLog(message: query)
}
}