'Rich notification play video clip
I'm trying to get rich notification and play video on the notification. I success to show an image and not found swift sample code.
What need to be done to add video clip / mp4 notification support? which function need to add to the NotificationService class ?
Thanks Yakir
Solution 1:[1]
There is no need to add extra code and no need to use AV player also. we can achieve that by initialising UNNotificationAttachment with url which we get after URLSession.shared.downloadTask
URLSession.shared.downloadTask(with: attachmentURL) { url, _ , _ in
let attachment = try UNNotificationAttachment(identifier: "identifier", url: url, options: nil)
content.attachments.append(attachment)
}
While updating the content in NotificationServiceExtension. Notification will load the video if it is video url.
Note: - please make sure video should be small size or as suggested by Apple.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |