我是 Xcode和 Swift的新手.我想发送带有显示图像的本地通知.我使用UNNotificationAttachment附加以下代码中的图像: let content = UNMutableNotificationContent()content.title = "Testing"content.body = "Testing ric
let content = UNMutableNotificationContent() content.title = "Testing" content.body = "Testing rich notification" let attachement = try! UNNotificationAttachment(identifier: "image", url: Bundle.main.url(forResource: "myImg", withExtension: "png")!, options: nil) content.attachments = [attachement] let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 10, repeats: false) let request = UNNotificationRequest(identifier: "TenSecond", content: content, trigger: trigger) // Schedule the notification. let center = UNUserNotificationCenter.current() center.add(request) { (error : Error?) in if error != nil {} }
我可以在通知横幅的右侧看到一个缩略图,但它太小了.我想增加缩略图的大小,以便通知如下所示:
Notification With larger thumbnail
可能吗?
使用iOS 10,您可以使用UserNotificationsUI框架将通知主体替换为具有较大UIImageView的缩略图.有关详情,请参见 Customizing the Appearance of Notifications.