UILocalNotification不显示在locking屏幕上
有没有什么特殊的参数需要UILocalNotification才能显示在Facebook Messenger消息的locking屏幕上? 我的通知确实出现在通知中心的“通知”下。 我认为这种行为与AppStore通知类似,只是将通知显示在通知中,但用户从未收到警报。
你可能没有添加.Badge
时,你做了你的registerUserNotificationSettings
。 你应该有
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: categories) application.registerUserNotificationSettings(settings)
您必须获得在locking屏幕上显示通知的权限! 一次看看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 }