[英]iOS Push notification with video is not showing on lock screen
I am testing notification service extension on iphone 7 (iOS 13.4).我正在 iphone 7 (iOS 13.4) 上测试通知服务扩展。 I am sending multiples media types (jpg, gif and mp4).
我正在发送多种媒体类型(jpg、gif 和 mp4)。 The content with jpg and gif are showing good, but mp4 notification only shows content when iphone is unlocked.
jpg 和 gif 的内容显示良好,但 mp4 通知仅在 iphone 解锁时显示内容。 When iphone is locked and notification video played the image is not showing, white screen all the time, although the video is heard.
当 iphone 被锁定并且播放通知视频时,虽然可以听到视频,但没有显示图像,一直是白屏。 if I press the touch button while video is playing with white screen the image appears.
如果我在以白屏播放视频时按下触摸按钮,则会出现图像。
In the notification settings for the app all permissions are granted (I think).在应用程序的通知设置中,所有权限都被授予(我认为)。
Do I have to ask the user for any special permissions?我是否必须向用户询问任何特殊权限? Any idea?
任何想法?
Thanks.谢谢。
Yes, you have to write give permission during write completeFileProtectionUntilFirstUserAuthentication.是的,您必须在写入 completeFileProtectionUntilFirstUserAuthentication 期间写入授予权限。
Below is the sample code:下面是示例代码:
`extension UNNotificationAttachment {
convenience init(gifData: Data, options: [NSObject: AnyObject]?) throws {
let fileManager = FileManager.default
let temporaryFolderName = ProcessInfo.processInfo.globallyUniqueString
let temporaryFolderURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(temporaryFolderName, isDirectory: true)
try fileManager.createDirectory(at: temporaryFolderURL, withIntermediateDirectories: true, attributes: nil)
let imageFileIdentifier = UUID().uuidString + ".mp4"
let fileURL = temporaryFolderURL.appendingPathComponent(imageFileIdentifier)
try gifData.write(to: fileURL, options: .completeFileProtectionUntilFirstUserAuthentication)
try self.init(identifier: imageFileIdentifier, url: fileURL, options: options)
}
}`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.