UILocalNotification not doing anything

This may seem like a silly question, but this is my first time using UILocalNotification and I can’t get it to work for a quick test. It just doesn’t do anything.

1. I’ve created 2 variables in the AppDelegate

  • iOS app submission yields “invalid toolchain” although Xcode is up-to-date
  • Invalid Application Binary
  • How can I create iOS push notifications that don’t vibrate?
  • How to do Slow Motion video in IOS
  • App Name has already been used?
  • Disable iOS8 Quicktype Keyboard programmatically on UITextView
  • let today = NSDate()
    let notification: UILocalNotification = UILocalNotification()

    2. Then in the applicationDidEnterBackground function, I have the following

        notification.fireDate = today.dateByAddingTimeInterval(10)
        notification.alertTitle = "My App Test"
        notification.alertBody = "Testing Notification \n :)"

    3. Also added this to the applicationDidBecomeActive function


    Solutions Collect From Internet About “UILocalNotification not doing anything”

    After reading the documentation again, I realized I missed a crucial first step which is to register my App first for user notifications. The Apple doc was written in OBJ-C, but I was able to figure it out in order to convert it to swift. This is what I did:

    1. I added this to my AppDelegate didFinishLaunchingWithOptions function and it now works

    var types: UIUserNotificationType = UIUserNotificationType()
    let settings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: types, categories: nil)