knickerbong
knickerbong

Reputation: 67

Flutter local notifications iOS doesn't work

I read that you need to add the following lines to the didFinishLaunchingWithOptions method

if #available(iOS 10.0, *) {
  UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}

Where do I put this inside:

import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: if #available(iOS 10.0, *) {
                             UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
                           })
  }
}

Upvotes: 2

Views: 1443

Answers (1)

dixita
dixita

Reputation: 94

override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
     if #available(iOS 10.0, *) {
          UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
        }
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

Upvotes: 3

Related Questions