MaikuB / flutter_local_notifications

A Flutter plugin for displaying local notifications on Android, iOS, macOS and Linux
2.46k stars 1.4k forks source link

Cannot find 'FlutterLocalNotificationPlugin' in scope #2149

Closed joaoribeiro-controlink closed 11 months ago

joaoribeiro-controlink commented 1 year ago

Describe the bug When I try to build my app on xcode it gives me the error "Cannot find 'FlutterLocalNotificationPlugin' in scope"

Sample code to reproduce the problem AppDelegate.swift:

import UIKit
import Flutter
import flutter_local_notifications

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {

    FlutterLocalNotificationPlugin.setPluginRegistrantCallback { (registry) in
        GeneratedPluginRegistrant.register(with: registry)
    }

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

    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

pubspec.yaml:

name: salty_pelican_app
description: Salty Pelican

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.1.0

environment:
  sdk: ">=2.16.1 <3.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  http:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  intl: 0.18.1
  flutter_spinkit: ^5.1.0

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  connectivity_plus: ^2.2.1
  flutter_offline: ^2.1.0
  internet_connection_checker: ^1.0.0+1
  awesome_dialog: ^3.0.2
  auto_size_text: ^3.0.0
  flutter_snake_navigationbar: ^0.6.1
  country: ^2.0.0
  azlistview: ^2.0.0
  url_launcher: ^6.1.0
  photo_view: ^0.14.0
  diacritic: ^0.1.3
  font_awesome_flutter: ^10.1.0
  image_picker: ^0.8.5+3
  file_picker: ^6.1.1
  mime: ^1.0.2
  firebase_core: ^2.21.0
  firebase_messaging: ^14.7.3
  flutter_local_notifications: ^16.1.0
  image_gallery_saver: ^1.7.1
  open_file: ^3.2.1
  path_provider: ^2.0.11
  flutter_keychain: ^2.2.1
  badges: ^2.0.3

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_launcher_icons: ^0.10.0

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.1

flutter_icons:
    image_path: "lib/assets/icons/icon.png"
    android: true
    ios: true
    remove_alpha_ios: true

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  generate: true
  # To add assets to your application, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg
  assets:
    - lib/assets/icons/icon.png
    - lib/assets/icons/notification-icon.png
    - lib/assets/images/gate.jpg
    - lib/assets/images/hello.png
    - lib/assets/images/house.png
    - lib/assets/images/card.png
    - lib/assets/images/no_image.png
    - lib/assets/allergens/aipo_128.png
    - lib/assets/allergens/alcool_128.png
    - lib/assets/allergens/amendoim_128.png
    - lib/assets/allergens/cafe_128.png
    - lib/assets/allergens/carne_128.png
    - lib/assets/allergens/crustaceos_128.png
    - lib/assets/allergens/dioxido_enxofre_128.png
    - lib/assets/allergens/frutos_secos_128.png
    - lib/assets/allergens/frutose_128.png
    - lib/assets/allergens/gluten_128.png
    - lib/assets/allergens/lactose_128.png
    - lib/assets/allergens/leite_128.png
    - lib/assets/allergens/moluscos_128.png
    - lib/assets/allergens/mostarda_128.png
    - lib/assets/allergens/ovo_128.png
    - lib/assets/allergens/peixes_128.png
    - lib/assets/allergens/sementes_sesamo_128.png
    - lib/assets/allergens/soja_128.png
    - lib/assets/allergens/sulfito_128.png
    - lib/assets/allergens/tremoco_128.png
    - lib/assets/allergens/vegan_128.png
    - lib/assets/allergens/vegetariano_128.png

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

Can anyone help me with this??

MaikuB commented 11 months ago

You've mistyped as you are missing a "s", that is instead of FlutterLocalNotificationPlugin, it should be FlutterLocalNotificationsPlugin as it's plural

MaikuB commented 11 months ago

Forgot to add that you could've referenced https://github.com/MaikuB/flutter_local_notifications/blob/master/flutter_local_notifications/example/ios/Runner/AppDelegate.swift to copy and paste from