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 Viasat is providing a blueprint for the industrial edge

    April 26, 2026

    Hampshire College to close: Why colleges are going out of business

    April 26, 2026

    Bringing Professional-Level Skills to Cisco Networking Academy

    April 26, 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 – Apply shadow only outside of a SwifUI transparent button?

    April 26, 2026

    ios – AVCaptureDevice.exposurePointOfInterest readback does not match set value on iPad Pro M4 / M3(UltraWide)and Gen2,3,4(TrueDepth) using resizeAspectFill

    April 25, 2026

    ios – Trying to build just after installing cordova and getting error after error

    April 24, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    How Viasat is providing a blueprint for the industrial edge

    April 26, 2026

    Hampshire College to close: Why colleges are going out of business

    April 26, 2026

    Bringing Professional-Level Skills to Cisco Networking Academy

    April 26, 2026

    Product sprints for developer-oriented portals and content

    April 26, 2026
    Timer Code
    15 Second Timer for Articles
    20
    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 Viasat is providing a blueprint for the industrial edge

    April 26, 2026

    Hampshire College to close: Why colleges are going out of business

    April 26, 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.