简体   繁体   English

UILocalNotification没有显示在锁定屏幕中

[英]UILocalNotification not showing in the lock screen

Is there any special parameters an UILocalNotification has to have in order to show on the lock screen like the Facebook Messenger messages? UILocalNotification是否必须具有任何特殊参数才能像Facebook Messenger消息一样在锁定屏幕上显示? My notification does appear on the notification center under "notifications". 我的通知确实出现在通知中心的“通知”下。 I think the behaviour is similar to the AppStore notifications in where they are only shown as a notification but the user is never alerted. 我认为该行为类似于AppStore通知,其中它们仅显示为通知,但永远不会提醒用户。

You probably didn't add .Badge when you did your registerUserNotificationSettings . 你可能没有添加.Badge当你做你的registerUserNotificationSettings You should have 你应该有

let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: categories)
application.registerUserNotificationSettings(settings)

You have to take permission for show the notification on lock screen ! 您必须获得许可才能在锁定屏幕上显示通知! once look at the code in Appdelegate.m 一次查看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)
application.registerUserNotificationSettings(settings)
return true 
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM