Flutter Local Notifications - Learn how to implement local notifications into both Android and iOS using flutter_local_notifications plugin.

Overview

Flutter Local Notifications Example

Flutter Local Notifications - Learn how to implement local notifications into both Android and iOS using flutter_local_notifications plugin.

This project shows -

  • how to setup platform-specific initialization settings.
  • how to work with flutter_local_noifications package.
  • how to display a notification.
  • how to schedule a notification and a recurring notification with daily or weekly interval.
  • how to cancel a single notification and all pendinng notifications.

Read the article here on Medium.

Check the sample video here on Instagram.

Preview

Getting Started

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

If you like this repository, kindly give it a star

You might also like...

A mobile application for both android and ios made for work out and fitness purpose

A mobile application for both android and ios made for work out and fitness purpose

It's a mobile application for both android and ios made for work out and fitness purpose with many features you can read about here, but it can be used under all subject you want, well architected code and organized !

Dec 18, 2022

Telnyx flutter - A Flutter package for both android and iOS which helps developers with Telnyx API services

Telnyx Flutter A Flutter package for both android and iOS which helps developers

Jan 23, 2022

A Flutter Accident reporting App working in both iOS and Android

Flutter Accident Reporting App A Flutter Accident reporting App working in both iOS and Android.This project total size of all Dart files is 4714 bite

Oct 13, 2022

💳 A Flutter package for making payments via credo central. Provides support for both Android and iOS

💳 Credo Package for Flutter TODO: Put a short description of the package here that helps potential users know whether this package might be useful fo

Dec 26, 2021

A horoscope forecasting application for both Android and iOS

A horoscope forecasting application for both Android and iOS

Zodoscope A Horoscope Forcasting Application Built with Flutter, for Android and iOS API used: http://horoscope-api.herokuapp.com/ Key Features All Zo

Sep 25, 2022

This project was writed with pure dart code,which means it's support both iOS and Android.

This project was writed with pure dart code,which means it's support both iOS and Android.

This project was writed with pure dart code,which means it's support both iOS and Android. Screenshot Todo show/hide animation Usage You can find the

Dec 24, 2022

Notefy - Task Saving App for both Android and iOS

Assignment for Flutter Developers Goal of the assignment is to: - Show the capa

Jan 25, 2022

This Repository is contain about learn Flutter and Dart [Learn]

Flutter-Dart-Code-Learn-Journey This Repository is contain about learn Flutter and Dart [Learn] Introduction Learn Dart Data Type Control Flow Collect

Jan 11, 2022

🎬 A movie catalog app for both Android & IOS ~ Flutter.io project in Dart | Dart, Bloc, Movies

Movie Catalog App 🎬 Browse through movies from the YIFY api Getting Started For help getting started with Flutter, view our online documentation. Tod

Nov 21, 2022
Comments
  • Onselect notification function to navigate screen is not working in conditional part (else)

    Onselect notification function to navigate screen is not working in conditional part (else)

    Here is the code. In this code at function onselectnotification while ontapping notification to navigate screen is not working in conditional part (else).Kindly solve this ASAP.

    import 'dart:convert';

    import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:settleme/Screens/Dashboard/Settings/SettingsScreen.dart'; import 'package:settleme/Screens/Login/LoginScreen.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { await Firebase.initializeApp(); }

    AndroidNotificationChannel? channel;

    FlutterLocalNotificationsPlugin? flutterLocalNotificationsPlugin; late FirebaseMessaging messaging;

    final GlobalKey navigatorKey = new GlobalKey();

    Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp();

    messaging = FirebaseMessaging.instance; messaging.subscribeToTopic("TopicToListen");

    // Set the background messaging handler early on, as a named top-level function FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);

    if (!kIsWeb) { channel = const AndroidNotificationChannel( 'flutter_notification_title', // title 'flutter_notification_description', // description importance: Importance.high, enableLights: true, enableVibration: true, showBadge: true, playSound: true);

    flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); await flutterLocalNotificationsPlugin! .resolvePlatformSpecificImplementation< AndroidFlutterLocalNotificationsPlugin>() ?.createNotificationChannel(channel!);

    await FirebaseMessaging.instance .setForegroundNotificationPresentationOptions( alert: true, badge: true, sound: true, ); } runApp(MyApp()); }

    class MyApp extends StatelessWidget { // This widget is the root of your application. @OverRide Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, navigatorKey: navigatorKey, title: 'Flutter Notification', theme: ThemeData( primarySwatch: Colors.blue, ), home: HomePage(), ); } } class HomePage extends StatefulWidget { final String? message;

    HomePage({Key? key, this.message}) : super(key: key);

    @OverRide _HomePageState createState() => _HomePageState(); }

    class _HomePageState extends State { bool _isLoggedIn = false; @OverRide void initState() { super.initState();

    final android = AndroidInitializationSettings('@drawable/ic_notification'); final iOS = IOSInitializationSettings(); final initSettings = InitializationSettings(android: android, iOS: iOS);

    flutterLocalNotificationsPlugin ?.initialize(initSettings, onSelectNotification: onSelectNotification);

    setupInteractedMessage();

    FirebaseMessaging.onMessage.listen((message) async { RemoteNotification? notification = message.notification; AndroidNotification? android = message.notification?.android;

    if (notification != null && android != null && !kIsWeb) { String action = jsonEncode(message.data);

    flutterLocalNotificationsPlugin!.show(
        notification.hashCode,
        notification.title,
        notification.body,
        NotificationDetails(
          android: AndroidNotificationDetails(
            channel!.name,
            channel!.description.toString(),
            priority: Priority.high,
            importance: Importance.max,
            setAsGroupSummary: true,
            styleInformation: DefaultStyleInformation(true, true),
            largeIcon: DrawableResourceAndroidBitmap('@mipmap/ic_launcher'),
            channelShowBadge: true,
            autoCancel: true,
            icon: '@drawable/ic_notification',
          ),
        ),
        payload: action);
    

    } }); FirebaseMessaging.onMessageOpenedApp .listen((message) => _handleMessage(message.data)); }

    void onSelectNotification(String? payload) async { Future _prefs = SharedPreferences.getInstance(); final SharedPreferences prefs = await _prefs; _isLoggedIn = prefs.getBool('_isLoggedIn')??false; setState(() { if (_isLoggedIn == true) { // isLoading = true; navigatorKey.currentState!.push(MaterialPageRoute(builder: (context) => SettingsScreen())); } else{ navigatorKey.currentState!.push(MaterialPageRoute(builder: (context) => Loginpage())); }

    });

    // if(payload!.length<6) { // debugPrint('notification payload: $payload'); // await navigatorKey.currentState!.push(MaterialPageRoute(builder: (context) => SettingsScreen())); // } // else if(payload!.length>=6) { // debugPrint('notification payload: $payload'); // await navigatorKey.currentState!.push(MaterialPageRoute(builder: (context) => Loginpage())); // } }

    Future setupInteractedMessage() async { await FirebaseMessaging.instance .getInitialMessage() .then((value) => _handleMessage(value != null ? value.data : Map())); }

    void _handleMessage(Map<String, dynamic> data) { if (data['redirect'] == "Settings") { Navigator.push( context, MaterialPageRoute( builder: (context) => SettingsScreen(message: data['message']))); } else if (data['redirect'] == "Login") { Navigator.push( context, MaterialPageRoute( builder: (context) => Loginpage(message: data['message']))); } }

    @OverRide Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Home"), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'You will receive notification', ), ], ), ), ); } }

    opened by Sarat-1997 0
Owner
Sandip Pramanik
Passionate Flutter Developer from INDIA, Technical Content Creator, Nitdgp '22
Sandip Pramanik
Plugin to implement APNS push notifications on iOS and Firebase on Android.

apns Plugin to implement APNS push notifications on iOS and Firebase on Android. Why this plugin was made? Currently, the only available push notifica

null 0 May 14, 2022
Ahmed Elsayed 257 Jan 7, 2023
Klutter plugin makes it possible to write a Flutter plugin for both Android and iOS using Kotlin only.

The Klutter Framework makes it possible to write a Flutter plugin for both Android and iOS using Kotlin Multiplatform. Instead of writing platform spe

Gillian 33 Dec 18, 2022
Flutterbodydetection - A flutter plugin that uses MLKit on iOS/Android platforms to enable body pose and mask detection using Pose Detection and Selfie Segmentation APIs for both static images and live camera stream.

body_detection A flutter plugin that uses MLKit on iOS/Android platforms to enable body pose and mask detection using Pose Detection and Selfie Segmen

null 18 Dec 5, 2022
A Very Flexible Widget that can Implement Material Sheets on all Directions, both modal and persistent, and consequently a Material Navigation Drawer

Flutter_MaterialSheetAndNavigationDrawer If this project helped you reduce developement time or you just want to help me continue making useful tools

Bryan Cancel 30 Dec 4, 2021
A Flutter plugin to get location updates in the background for both Android and iOS

Background Location A Flutter plugin to get location updates in the background for both Android and iOS (Requires iOS 10.0+). Uses CoreLocation for iO

Ali Almoullim 181 Jan 4, 2023
A Basic Currency Converter made for both iOS and Android using the flutter.io platform

FlutterCurrencyConverter A Basic Currency Converter made for both iOS and Android using the flutter.io platform This app uses the ExchangeRate-API for

Carlo Gabriel Villalon Tapales 40 Nov 23, 2022
TicTacToe Using flutter. For both android and ios

mt_tictactoe A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Asim Sidd 3 Nov 27, 2022
Create flutter project with all needed configuration in two minutes (theme, localization, connect to firebase, FCM, local notifications, safe API call, error handling, animation..etc)

Flutter GetX Template Flutter Getx template to make starting project fast and easy . Introduction We all face the same problem when we want to start a

Emad Beltaje 150 Jan 7, 2023