// // AppDelegate+OpenApp.swift // MoviaBox // // Created by 佳尔 on 2025/4/25. // import UIKit 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 { ///URL打开APP func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { } ///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) } }