close

[Solved] The method ‘IOSInitializationSettings’ isn’t defined

Hello Guys How are you all? Hope You all are fine. When I was trying to run my flutter app and suddenly I get the following error in my stack track: The method ‘IOSInitializationSettings’ isn’t defined in flutter. So today Here I come with all possible solutions for this error.

We are providing you with all possible solutions to solve this error. let’s start this article without wasting your time.

How The method ‘IOSInitializationSettings’ isn’t defined Error Occurs?

I Have initialized the flutter_local_notifications plugin in my flutter app But I am facing the following error.

The method 'IOSInitializationSettings' isn't defined 

How To Solve The method ‘IOSInitializationSettings’ isn’t defined Error?

  1. How To Solve The method 'IOSInitializationSettings' isn't defined Error?

    This error occurs Because You forget to add IOSInitializationSettings in Your Code. To Solve The method 'IOSInitializationSettings' isn't defined Error You just need to add IOSInitializationSettings in your code and your error will be solved.

  2. The method 'IOSInitializationSettings' isn't defined

    This error occurs Because You forget to add IOSInitializationSettings in Your Code. To Solve The method 'IOSInitializationSettings' isn't defined Error You just need to add IOSInitializationSettings in your code and your error will be solved.

Solution 1: add IOSInitializationSettings in Your Code

This error occurs Because You forget to add IOSInitializationSettings in Your Code. To Solve The method ‘IOSInitializationSettings’ isn’t defined Error You just need to add IOSInitializationSettings in your code and your error will be solved. Just Copy the below Code and add in your code.

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

Here is my Full Code for initializing flutter_local_notifications for Android and iOS.

  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,
    );
  }

And now, Your error will be solved.

Conclusion

So, It’s All About This Error. I hope this tutorial helps you to Solve your error. Please Comment Below if You stucks anywhere with my code. And please comment below on which solution worked for you. Thank You.

Also, Check Out the Below Tutorials

Leave a Comment