步骤:
1. 添加框架 UserNotifications
2. 注册远程通知
let center = UNUserNotificationCenter.current() center.requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in // Enable or disable features based on authorization. if granted == true { print("Allow") UIApplication.shared.registerForRemoteNotifications() } else { print("Don‘t Allow") } }
3. 获取Token
时间: 2024-12-27 08:21:10