【问题标题】:UILocalNotification not showing in the lock screenUILocalNotification 未显示在锁定屏幕中
【发布时间】:2014-09-26 01:41:18
【问题描述】:

UILocalNotification 是否需要任何特殊参数才能像 Facebook Messenger 消息一样显示在锁定屏幕上?我的通知确实出现在通知中心的“通知”下。我认为这种行为类似于 AppStore 通知,它们仅显示为通知,但从未提醒用户。

【问题讨论】:

  • 这取决于用户的喜好。如果用户不想在锁定屏幕中看到您的通知,它就不会出现。
  • 该应用程序已设置为显示在锁定屏幕上,但我从未见过它显示在那里。但是,它确实显示触发了本地通知,并显示在通知中心。
  • 不,没有特殊参数可以在锁定屏幕上显示它...请参阅此链接....stackoverflow.com/questions/25929665/… 了解更多信息...请参阅此...github.com/sgup77/SGNotification
  • 确保将通知安排在延迟后,以便在锁定屏幕后显示在锁定屏幕上。

标签: ios ios8


【解决方案1】:

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

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

【讨论】:

    【解决方案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 
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      相关资源
      最近更新 更多