21

flutter_local_notifications: ^11.0.0

I used this library but I can find IOSInitializationSettings please help me. I m trying to integrate push notifications into my flutter app.

4 Answers4

66

From the flutter_local_notifications docs, version 10.0 has the following breaking changes:

iOS and macOS classes have been renamed and refactored as they are based on the same operating system and share the same notification APIs. Rather than having a prefix of either IOS or MacOS, these are now replaced by classes with a Darwin prefix. For example, IOSInitializationSettings can be replaced with DarwinInitializationSettings

So change: IOSInitializationSettings --> DarwinInitializationSettings

IOSNotificationDetails --> DarwinNotificationDetails

Asquare17
  • 356
  • 3
  • 9
  • 2
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 28 '22 at 18:08
5

[iOS][macOS] Breaking changes iOS and macOS classes have been renamed and refactored as they are based on the same operating system and share the same notification APIs. Rather than having a prefix of either IOS or MacOS, these are now replaced by classes with a Darwin prefix. For example, IOSInitializationSettings can be replaced with DarwinInitializationSettings

Matus
  • 172
  • 1
  • 1
  • 13
4

Here is the code for initializing for iOS and android.


  Future<void> intialize() async {
    tz.initializeTimeZones();
    const AndroidInitializationSettings androidInitializationSettings =
        AndroidInitializationSettings('@drawable/ic_stat_android');

    IOSInitializationSettings iosInitializationSettings =
        IOSInitializationSettings(
      requestAlertPermission: true,
      requestBadgePermission: true,
      requestSoundPermission: true,
      onDidReceiveLocalNotification: onDidReceiveLocalNotification,
    );

    final InitializationSettings settings = InitializationSettings(
      android: androidInitializationSettings,
      iOS: iosInitializationSettings,
    );

    await _localNotificationService.initialize(
      settings,
      onSelectNotification: onSelectNotification,
    );
  }

I did the code in flutter_local_notifications: ^9.6.0

Adil Shinwari
  • 408
  • 2
  • 10
0
var initializationSettingsIOS = DarwinInitializationSettings(
      requestAlertPermission: true,
      requestBadgePermission: true,
      requestSoundPermission: true,
      onDidReceiveLocalNotification: (int id, String? title, String? body, String? payload) async {});
  • Thank you for contributing to the Stack Overflow community. This may be a correct answer, but it’d be really useful to provide additional explanation of your code so developers can understand your reasoning. This is especially useful for new developers who aren’t as familiar with the syntax or struggling to understand the concepts. **Would you kindly [edit] your answer to include additional details for the benefit of the community?** – Jeremy Caney Aug 14 '23 at 01:07