简体   繁体   English

在锁定屏幕上隐藏iOS 10通知

[英]Hide iOS 10 notification on lock screen

I have a situation where I want to get iOS 10 notification data (from dictionary),but I don't want to display any notification on the lock screen. 我有一种情况(我想从字典中获取iOS 10通知数据),但是我不想在锁定屏幕上显示任何通知。

Any solution? 有什么办法吗? Is this possible ? 这可能吗 ?

if #available(iOS 10.0, *)
{
     let content = UNMutableNotificationContent()
     content.body = "Test"

     var userInfo = [String:String]()
     userInfo["identifier"] = Identifier as String
     userInfo["Time"] = DateString as String
     content.userInfo = userInfo
}

I want to get data from dictionary but it shows alert notification on lock screen. 我想从字典中获取数据,但是它在锁定屏幕上显示警报通知。

let trigger = UNCalendarNotificationTrigger.init(dateMatchingComponents: components, repeats: false)
let request = UNNotificationRequest.init(identifier: "hello", content: content, trigger: trigger)

You can achieve this thing by sending Silent Push Notification to your device. 您可以通过向设备发送Silent Push Notification来实现此目的。

To get silent push notification, 要获取静默推送通知,

You've to set content-available flag to 1 in your push notification payload. 您必须在推送通知有效负载中将content-available标志设置为1。

Silent push notifications won't be shown on your lock screen. 静音推送通知将不会显示在锁定屏幕上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 iOS 10 中实现“从锁屏回复通知” - Implementing "reply to notification from lock screen" in iOS 10 iOS 10本地通知:在锁定屏幕上显示通知内容 - iOS 10 local notifications: show notification content on lock screen 如何在后台模式和锁定屏幕中隐藏或取消来自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:以编程方式关闭锁定屏幕上显示的通知? - iOS: Programmatically dismiss a notification that is displayed on lock screen? 在iOS 8上访问“锁定”屏幕的应用程序通知设置 - Access App Notification Settings for Lock screen on iOS 8 iOS 带视频的推送通知未在锁定屏幕上显示 - iOS Push notification with video is not showing on lock screen 在锁定屏幕iOS上处理推送通知 - Handling Push Notification on Lock Screen ios iOS 10将MPNowPlayingInfoPropertyPlaybackRate设置为0使锁定屏幕空白 - IOS 10 setting MPNowPlayingInfoPropertyPlaybackRate to 0 blanks the lock screen ios 本地通知 - 摆脱锁定屏幕上的“通知”文字 - ios local notification - get rid of “Notification” text on the lock screen 当手机进入锁屏iOS时如何触发本地通知 - How to trigger a local notification when phone goes to lock screen ios
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM