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