简体   繁体   English

iOS 带视频的推送通知未在锁定屏幕上显示

[英]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.

相关问题 在锁定屏幕iOS上处理推送通知 - Handling Push Notification on Lock Screen ios 锁定屏幕iOS9中显示的最大推送通知数 - Max number of push notification that is shown in lock screen iOS9 如何在iOS推送通知显示在锁定屏幕通知中心之前拦截它? - How can I intercept an iOS Push Notification before it's displayed on the lock screen notification center? 在锁定屏幕上捕获推送通知文本 - Catch push notification text on lock screen Phonegap 推送通知不会出现在状态栏中,也不会出现在使用 PushPlugin 插件的 iOS 锁定屏幕中 - Phonegap push notification does not appear in Status bar nor in Lock screen for iOS using the PushPlugin plugin 如何在后台模式和锁定屏幕中隐藏或取消来自APN的iOS中的推送通知(Uiusernotification或RemoteNotification)? - How to Hide or cancel Push notification in iOS ( Uiusernotification or RemoteNotification) which comes from apns in background mode and lock screen? 在锁定屏幕上隐藏iOS 10通知 - Hide iOS 10 notification on lock screen 在iOS 8上访问“锁定”屏幕的应用程序通知设置 - Access App Notification Settings for Lock screen on iOS 8 iOS:以编程方式关闭锁定屏幕上显示的通知? - iOS: Programmatically dismiss a notification that is displayed on lock screen? 锁定屏幕中的iOS Webview视频URL - iOS webview video URL in lock screen
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM