UILocalNotification不显示在锁定屏幕上
问题描述:
是否有任何特殊参数需要UILocalNotification才能在锁定屏幕上显示,如Facebook Messenger消息?我的通知确实出现在通知中心的“通知”下。我认为这种行为与AppStore通知类似,只是将通知显示为通知,但用户从未收到警报。UILocalNotification不显示在锁定屏幕上
答
当您完成registerUserNotificationSettings
时,您可能没有添加.Badge
。你应该有
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: categories)
application.registerUserNotificationSettings(settings)
答
你必须获得在锁定屏幕上显示通知的权限!一旦看看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
}
这取决于用户的偏好。如果用户不想在锁定屏幕中看到您的通知,则不会显示。 – matt 2014-09-26 01:44:55
该应用程序已被设置为在锁定屏幕上显示,但我从未见过它显示在那里。但它确实显示本地通知已触发,并显示在通知中心。 – Pochi 2014-09-26 01:50:35
没有没有特殊的参数显示它在锁定的屏幕上...请参阅此链接.... http://*.com/questions/25929665/features-supported-by-ios8-interactive-notification/25930069#25930069欲了解更多信息...请参阅此... https://github.com/sgup77/SGNotification – 2014-09-26 05:35:31