Mohammad Faizan
Mohammad Faizan

Reputation: 854

The method 'IOSInitializationSettings' isn't defined using local notification plugin

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.

Upvotes: 28

Views: 34553

Answers (4)

Anthony Anisimov
Anthony Anisimov

Reputation: 936

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

Upvotes: 92

jacobit kashala
jacobit kashala

Reputation: 79

var initializationSettingsIOS = DarwinInitializationSettings(
      requestAlertPermission: true,
      requestBadgePermission: true,
      requestSoundPermission: true,
      onDidReceiveLocalNotification: (int id, String? title, String? body, String? payload) async {});

Upvotes: 1

Matus
Matus

Reputation: 169

[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

Upvotes: 5

Adil Shinwari
Adil Shinwari

Reputation: 796

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

Upvotes: 4

Related Questions