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

    How Cisco Transforms AI Data Centers

    February 16, 2026

    AT&T reveals its iPhone 16 deals — get up to $1,000 off with an eligible trade-in

    February 16, 2026

    TypeScript 6.0 beta lays the foundation for shifting the codebase from JavaScript to Go

    February 15, 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

    Fatal ‘Index out of range’ error when using macOS simulator in Xcode but not when using iOS simulator

    February 15, 2026

    ios – How to persist credit balance in a credit-based AI app when using anonymous sign-in?

    February 14, 2026

    Flutter iOS build failing with CocoaPods platform version errors, while Android works fine

    February 13, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    How Cisco Transforms AI Data Centers

    February 16, 2026

    AT&T reveals its iPhone 16 deals — get up to $1,000 off with an eligible trade-in

    February 16, 2026

    TypeScript 6.0 beta lays the foundation for shifting the codebase from JavaScript to Go

    February 15, 2026

    Is IFS therapy evidence-based — or is it a sham? Does it matter?

    February 15, 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!

    How Cisco Transforms AI Data Centers

    February 16, 2026

    AT&T reveals its iPhone 16 deals — get up to $1,000 off with an eligible trade-in

    February 16, 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.