UILocalNotification未显示在锁定屏幕中

时间:2014-09-26 01:41:18

标签: ios ios8

UILocalNotification是否有任何特殊参数可以在锁定屏幕上显示,如Facebook Messenger消息?我的通知确实出现在“通知”下的通知中心。我认为这种行为类似于AppStore通知,它们只显示为通知,但用户从未收到警报。

2 个答案:

答案 0 :(得分:0)

您执行.Badge时可能没有添加registerUserNotificationSettings。你应该

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

答案 1 :(得分:0)

您必须获得在锁定屏幕上显示通知的权限!一看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 
}