user3606833 user3606833 - 3 years ago 201
Swift Question

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.

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)

Answer Source

You can achieve this thing by sending Silent Push Notification to your device.

To get silent push notification,

You've to set content-available flag to 1 in your push notification payload.

Silent push notifications won't be shown on your lock screen.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download