Daniel Daniel - 4 months ago 21x
Swift Question

UILocalNotifications don't appear on locked screen

I ran my app on my iphone. (Simply connected my phone and chose my iPhone as the target.) I built local notifications in my app which are scheduled and appear perfectly on time on the iPhone. However, they don't appear on the locked screen, even though under Settings -> Notifications -> [my app] -> Show on Lock Screen is turned on.

What is strange is that they even appear in the Notification Centre.

This is similar to UILocalNotification not showing in the lock screen however I found no answer there either.

Has anybody encountered this? I'm thinking it may be an iOS bug. I'm using the latest iOS, Xcode, OS X to date.


You have to take permission for show the notification on lock screen ! once look at the code in Appdelegate.m

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    let notificationCategory = UIMutableUserNotificationCategory()
    let categories = Set<UIUserNotificationCategory>(arrayLiteral: notificationCategory)
    let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: categories)
    return true