Home > front end >  Dart Flutter The method 'init' isn't defined for the type 'OneSignal'
Dart Flutter The method 'init' isn't defined for the type 'OneSignal'

Time:03-12

I'm trying to make a system of sending notifications to the phone with OneSignal.

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:kelimeogrenmeuygulamasi/arayuzEkrani.dart';
import 'package:onesignal_flutter/onesignal_flutter.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  Firebase.initializeApp();
  OneSignal.shared.init("YOUR ONESIGNAL APP ID", iOSSettings: {
    OSiOSSettings.autoPrompt: false,
    OSiOSSettings.inAppLaunchUrl: false
  });
  runApp(mainApp());
}

In this code, I get an error in the init part.

Error:

enter image description here

How can I resolve this error?

CodePudding user response:

i am facing same error, i was searching and found out that setAppId instead of init maybe works, so try it

  • Related