【问题标题】:Use of unresolved identifier: "UNMutableNotificationContent"使用未解析的标识符:“UNMutableNotificationContent”
【发布时间】:2017-02-27 05:00:08
【问题描述】:

我有以下代码:

func sendLucidNotification() {
    let content = UNMutableNotificationContent()
    content.title = "10 Second Notification Demo"
    content.subtitle = "From MakeAppPie.com"
    content.body = "Notification after 10 seconds - Your pizza is Ready!!"
    content.categoryIdentifier = "message"

}

当我调用 UNMutableNotificationContent 或任何“UNMutableNotification”变体时,我收到以下错误:

Use of unresolved identifier: "UNMutableNotificationContent"

我使用的是 Xcode 8.0,但是当我尝试自动完成时,它也无法识别它。有任何想法吗 ?谢谢!

【问题讨论】:

  • 你导入UserNotifications框架了吗?

标签: ios swift uilocalnotification unnotificationrequest


【解决方案1】:

很可能您需要在编写此代码的位置添加 import notification_framework 语句,例如

import notification_framework_name

还要确保框架可用于您的目标构建。

更新:在您的情况下,导入语句将是:

import UserNotifications

【讨论】:

  • Nirav D. cmets 实际上是具体的答案。上面的答案有点神秘。
  • #import <UserNotifications/UserNotifications.h> 在 obj-c 中
猜你喜欢
  • 2018-03-12
  • 1970-01-01
  • 1970-01-01
  • 2016-02-25
  • 2016-07-17
  • 2016-04-29
  • 2020-12-09
相关资源
最近更新 更多