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