Error?) -> Swift.Void) public struct UNAuthorizationOptions : OptionSet { public init(rawValue: UInt) public static var badge: UNAuthorizationOptions { get } public static var sound: UNAuthorizationOptions { get } public static var alert: UNAuthorizationOptions { get } public static var carPlay: UNAuthorizationOptions { get } } badge: App Icon 上顯⽰示的數字
曾被啟動過,但現在沒有啟動,收到 silent notification 時,可以被啟動在背景做事。但如果使⽤用者強 制把 App 殺掉,它將不會被啟動。 • 收到 silent notification 時,可以利利⽤用 local notification 顯 ⽰示推播 The ability of APNs to deliver remote notifications to a nonrunning app requires the app to have been launched at least once. On an iOS device, if a user force-quits your app using the app multitasking UI, the app does not receive remote notifications until the user relaunches it.
bestAttemptContent: UNMutableNotificationContent? override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) { self.contentHandler = contentHandler bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) if let bestAttemptContent = bestAttemptContent { // Modify the notification content here... bestAttemptContent.title = "\(bestAttemptContent.title) [modified]" contentHandler(bestAttemptContent) } } override func serviceExtensionTimeWillExpire() { // Called just before the extension will be terminated by the system. // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { contentHandler(bestAttemptContent) } } }