Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    Iran war: US responsible for strike on Iranian school, investigation finds

    March 12, 2026

    MaxLiveProtect: eBPF-Powered Network Infrastructure Security

    March 12, 2026

    SBS Bank begins shift to cloud-native core banking platform

    March 12, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»android – Can’t show or schedule notification with flutter workmanager
    iOS Development

    android – Can’t show or schedule notification with flutter workmanager

    big tee tech hubBy big tee tech hubJanuary 26, 2026012 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    android – Can’t show or schedule notification with flutter workmanager
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    I’m building an app with Flutter for Android and iOS that every day should check for new data and send a notification to the user. To achieve it, I’m using workmanager, to schedule the job, and flutter_local_notifications to show the notification.

    When the job runs, no notification is shown and no exception get caught.

    However, if I try to display a notification as per flutter_local_notifications docs, i.e. without workmanager, it works correctly.

    This is a MRE of my main.dart that shows how I’m scheduling the job and showing the notification:

    import 'dart:io';
    import 'package:flutter_local_notifications/flutter_local_notifications.dart';
    import 'package:intl/intl.dart';
    import 'package:timezone/data/latest_all.dart' as tz;
    import 'package:timezone/timezone.dart' as tz;
    import 'package:workmanager/workmanager.dart';
    import 'package:intl/date_symbol_data_local.dart';
    
    
    final localNotificationPlugin = FlutterLocalNotificationsPlugin();
    bool _initialized = false;
    
    
    void main() async {
      await initialize();
      Workmanager().initialize(callbackDispatcher);
      runApp(App());
    }
    
    @pragma('vm:entry-point')
    Future initialize() async {
      WidgetsFlutterBinding.ensureInitialized();
    
      await initializeDateFormatting(Platform.localeName, null);
      await initLocalNotificationPlugin();
    
      tz.initializeTimeZones();
      tz.setLocalLocation(tz.getLocation(DateTime.now().timeZoneName));
    }
    
    Future initLocalNotificationPlugin() async {
      if (_initialized) {
        return;
      }
    
      _initialized = true;
      const AndroidInitializationSettings initializationSettingsAndroid = AndroidInitializationSettings('@mipmap/ic_launcher');
      final DarwinInitializationSettings initializationSettingsDarwin = DarwinInitializationSettings();
      final InitializationSettings initializationSettings = InitializationSettings(
          android: initializationSettingsAndroid,
          iOS: initializationSettingsDarwin
      );
    
      await localNotificationPlugin.initialize(initializationSettings);
    }
    
    @pragma('vm:entry-point')
    void callbackDispatcher() {
      Workmanager().executeTask((task, inputData) async {
        print('callbackDispatcher');
    
        try {
          await initialize();
        } catch (e) {
          print("Exception on callbackDispatcher");
          print(e);
        }
    
        switch (task) {
          case "fetchAndShow":
            await sendNotification();
            break;
          default:
            // Handle unknown task types
            break;
        }
    
        return Future.value(true);
      });
    }
    
    @pragma('vm:entry-point')
    Future sendNotification() async {
      try {
        await localNotificationPlugin.show(
          0,
          "Notification Title",
          "Notification Body",
          NotificationDetails(
            android: AndroidNotificationDetails("channel_id", "channel_name")
          )
        );
      } catch (e) {
        print('Exception on sendNotification');
        print(e);
      }
    }
    
    class App extends StatelessWidget {
    @override
      Widget build(BuildContext context) {
        Workmanager().registerPeriodicTask('dataSync', 'fetchAndShow', frequency: Duration(days: 1));
        // Build logic
      }
    }
    

    I’m using:

    • flutter: ^3.9.2
    • intl: ^0.20.2
    • flutter_local_notifications: ^19.5.0
    • timezone: ^0.10.1
    • workmanager: ^0.9.0+3



    Source link

    Android Flutter notification schedule Show workmanager
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    ios – SwiftUI iOS26+ Transition or Animation after TextField value entered

    March 12, 2026

    React Native vs Flutter: An overview and 6 decision factors

    March 11, 2026

    uikit – Why the title doesn’t follow the navigation inline state in iOS 26

    March 11, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    Iran war: US responsible for strike on Iranian school, investigation finds

    March 12, 2026

    MaxLiveProtect: eBPF-Powered Network Infrastructure Security

    March 12, 2026

    SBS Bank begins shift to cloud-native core banking platform

    March 12, 2026

    Friday Night Baseball Returns to Apple TV on March 27 for 2026 MLB Season

    March 12, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    Iran war: US responsible for strike on Iranian school, investigation finds

    March 12, 2026

    MaxLiveProtect: eBPF-Powered Network Infrastructure Security

    March 12, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.