简体   繁体   中英

flutter_local_notifications not working for me

我添加flutter_local_notifications依赖项并设置清单文件(添加权限并接收)但通知不起作用,除了 android 的清单权限之外,我是否需要更多项目设置?

Have you initialized ?吗? If no then try to add below statements in your as below添加以下语句,如下所示

@override
void initState() {
super.initState();
    FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new 
    FlutterLocalNotificationsPlugin();
    // initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
    var initializationSettingsAndroid =
    new AndroidInitializationSettings('ic_launcher');
    var initializationSettingsIOS = IOSInitializationSettings(
    onDidReceiveLocalNotification: onDidReceiveLocalNotification);
    var initializationSettings = InitializationSettings(
    initializationSettingsAndroid, initializationSettingsIOS);
    flutterLocalNotificationsPlugin.initialize(initializationSettings,
    onSelectNotification: onSelectNotification);
}

try this and let me know

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM