UILocalNotification在锁屏不显示(UILocalNotification not

2019-10-21 01:12发布

是否有任何特殊参数的UILocalNotification必须有为了显示在锁屏像Facebook的Messenger消息吗? 我通知并出现在“通知”的通知中心。 我认为,行为类似于AppStore的通知,在他们仅作为通知,但用户永远不会报警。

Answer 1:

你可能没有添加.Badge当你做你的registerUserNotificationSettings 。 你应该有

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


Answer 2:

你必须采取许可锁定屏幕上显示的通知! 一旦看看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 
}


文章来源: UILocalNotification not showing in the lock screen
标签: ios ios8