Search code examples
iosswiftuilocalnotificationunnotificationrequest

Use of unresolved identifier: "UNMutableNotificationContent"


I have the following code:

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"

}

When I call, UNMutableNotificationContent, or any "UNMutableNotification" variation I get the following error:

Use of unresolved identifier: "UNMutableNotificationContent"

I'm on Xcode 8.0, but when I try autocompleting it doesn't recognize it either. Any ideas ? Thank you!


Solution

  • Most probably you need to add the import notification_framework statement where you have written this code e.g

    import notification_framework_name
    

    Also make sure the framework is available for your target build.

    Update: in your case the import statement would be :

    import UserNotifications