Flutter_local_notifications: I Can't get this to work on Swift Flutter Projects.

Created on 18 Feb 2020  路  6Comments  路  Source: MaikuB/flutter_local_notifications

I know you say to add this code, but it doesn't seem to work.

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

But I can't replicate the abilities.

My AppDelegate looks like this:

`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: launchOptions)
}

}
`

How do I add this segment in?

Most helpful comment

import UIKit
import Flutter

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

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

Sorry repeating this in case you missed but it if you continue to have issues with then I'll need more info, like a link to a repository, details of which version of the plugin you're using and the output of running flutter doctor -v

All 6 comments

Would it be possible to add a more detailed guide of setting up on iOS device for the Read Me page.

I know you say to add this code, but it doesn't seem to work.

Note that this has been tested by myself and others in the community to work fine

How do I add this segment in?

Copy and paste it so it executed/added at some point before super.application.. call

Would it be possible to add a more detailed guide of setting up on iOS device for the Read Me page.

Please look at submitting a pull request (once you've got it working) as I don't know the specifics of what you're after. The firebase_messaging plugin has similar instructions as well

I tried creating a brand new app whilst on the latest stable build of Flutter, made the changes etc and it worked fine. If you continue to have issues with then I'll need more info, like a link to a repository, details of which version of the plugin you're using and the output of running flutter doctor -v

Can you please paste what your appDelegate.swift file looks like?

import UIKit
import Flutter

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

    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

Sorry repeating this in case you missed but it if you continue to have issues with then I'll need more info, like a link to a repository, details of which version of the plugin you're using and the output of running flutter doctor -v

Closing since there's been no further response on this for a while

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaripekkala picture jaripekkala  路  5Comments

IsaacKB picture IsaacKB  路  5Comments

hsalazarl picture hsalazarl  路  6Comments

dyhwang picture dyhwang  路  5Comments

salah-rashad picture salah-rashad  路  3Comments