Flutter Local Notifications

Поделиться
HTML-код
  • Опубликовано: 18 июн 2022
  • Hey Guys, in this Flutter video I will show you how to implement local notification in your Flutter app. You will learn how to implement notifications in Flutter, immediate notification and scheduled notification.
    You will also learn how to manage the payload of the notification and make actions based on it such as navigation to different screen.
    Learn how to use local notifications step by step in Flutter.
    For more Flutter content be sure to subscribe to the channel and turn on your notifications.
    Check out Flutter how-to videos:
    • Flutter Google Ads
    Check out my Flutter tutorial to become a Flutter hero: • Flutter Tutorial for B...
    Links:
    Don't click this: bit.ly/3dkJUNB
    local notification library: pub.dev/packages/flutter_loca...
    rxdart library: pub.dev/packages/rxdart/install
    timezone library: pub.dev/packages/timezone/ins...
    #flutter #flutter_notification #flutter_local_notifications

Комментарии • 149

  • @inselbergos
    @inselbergos Год назад

    Great! This video reduced my usual flutter approach: Reading uncommented code, for hours, in order to understand an flutter "component" to a minimum.

  • @Lmarso3
    @Lmarso3 Год назад +5

    if you're having problems with "onDidReceiveLocalNotification", just set "IOSInitializationSettings" to final instead of const

  • @user-xj7lh1ps1c
    @user-xj7lh1ps1c Год назад

    Thanks mahn, finally landed on a great tutorial... big up mahn 🤝

  • @Sarah-ne2lg
    @Sarah-ne2lg Год назад +1

    You are the king of notification explanation! thanks a lot

  • @omar0730
    @omar0730 Год назад

    Thank you @cordingorbit. This is a very helpful video. I implemented it and it works great. However when I try to schedule multiple notifications, it only delivers the last of the scheduled. I have tried to change the ID, and that doesn't seem to make a difference. Still, I only get the last of the several scheduled notifications. Any suggestions on what I am doing wrong or missing?

  • @elvistyron9120
    @elvistyron9120 2 года назад

    This is very helpful!. Thank you very much!👏👏👏👏

  • @krissyai
    @krissyai Год назад

    Thank you so much, this is the only tutorial that has managed to helped me and I can finally finish my app that is very late lol

  • @ShenderRamos
    @ShenderRamos Год назад

    thiis is great super simple and straight forward. demo it and get to work

  • @fldrone8521
    @fldrone8521 Год назад

    Thank you very much I was looking for days to see how to do that.

  • @huzeyfetas
    @huzeyfetas 2 года назад

    I also want to show the local notification on the lock screen and between the status bar and notifications. What route would you recommend I follow?

  • @andreatempestini
    @andreatempestini 2 года назад

    This is brilliant and very helpful! Thank you!

    • @codingorbit
      @codingorbit  2 года назад

      Most welcome!

    • @andreatempestini
      @andreatempestini 2 года назад

      @@codingorbit Just a question, if I would like to show a notification every day at the given hour. How could I do that?

    • @codingorbit
      @codingorbit  2 года назад

      You can schedule that notification on what days you want to show it and when check out the scheduled notification a bit more.

  • @natkasemmanirat1385
    @natkasemmanirat1385 2 года назад

    Thank you very much for this video

  • @samelobinna101
    @samelobinna101 2 года назад

    thanks for this video bro, wow it worked like magic

  • @RonelMontano-so4qc
    @RonelMontano-so4qc Год назад

    Thanks for this tutorial.

  • @ionolaru4086
    @ionolaru4086 Год назад

    That was such a cool expanation thank you.

  • @alibadawy4339
    @alibadawy4339 Год назад

    thank you very much i understand your lesson it's very helpful

  • @abuyusufsherakhmatov
    @abuyusufsherakhmatov Год назад

    Thank you bro, i appreciate it

  • @yaroslavborisov3284
    @yaroslavborisov3284 2 года назад

    Good work, bro! Appreciate for source code!

  • @primadmarcenaria4812
    @primadmarcenaria4812 Год назад

    Woah, great video mate!

  • @TrikNgonlen
    @TrikNgonlen 2 года назад

    LOVELY!

  • @abdokamhawy4589
    @abdokamhawy4589 Год назад

    thank you very much 😊😊

  • @nick8292
    @nick8292 Год назад

    Super job. Subbed.

  • @osmarbusch5893
    @osmarbusch5893 Год назад

    Super tks!

  • @aleszorc8126
    @aleszorc8126 Год назад +1

    Dude, this was hands down the best Flutter local notifications how-to I could find on the interwebs. Thanks a lot! 🙏Btw I loved your random laughs. 🤣

    • @codingorbit
      @codingorbit  Год назад

      Hahaha thank you so much. I really appreciate that 🫡

  • @fayezalle43
    @fayezalle43 Год назад

    Alhamdulillah.. thank you...

  • @trongnhannguyenle5941
    @trongnhannguyenle5941 Год назад

    Does flutter_local_notifications work to send notifications when the app has disabled multitasking and is running in the background? If not, please give me a way to do it.

  • @tanthokg
    @tanthokg Год назад

    Your tutorial is really good and well-explained. I have a small question, is using rxdart mandatory? If we need a Stream, can we use regular StreamController instead? Thank you

    • @codingorbit
      @codingorbit  Год назад +1

      Thank you, no that’s not mandatory you can use anything you like instead

  • @noahderebe
    @noahderebe Год назад

    nice one!!

  • @mudassirbit
    @mudassirbit Год назад

    OMG, searching searching searching.. Final landed on the right video.. This is the reason you deserve the Subscribe, this Subscribe is for my benefits 😀

  • @mohamedislem7578
    @mohamedislem7578 Год назад

    amazing, simple tut i've ever seen + worked from try 1. i cant thank you enough ❤

    • @codingorbit
      @codingorbit  Год назад +1

      Thank you i really appreciate that

  • @dianwijaya1604
    @dianwijaya1604 Год назад +1

    Great tutorial, thanks. Little question, can we show notifications like discount notifications without triggering the button and the app is closed?

    • @codingorbit
      @codingorbit  Год назад

      Yes, absolutely you can by scheduling the notification or by adding a remote functionality for it!

  • @luisrobertonavarro7581
    @luisrobertonavarro7581 Год назад +1

    The video is spectacular, very good and very grateful. Is there a way to make the notification run at a certain time and day?

    • @codingorbit
      @codingorbit  Год назад +1

      Thank you! For sure you can I've written some code for it in one of the comments but I couldn't mention you there, search for in the comments Proches Vara lol

  • @Ahme_Saeed
    @Ahme_Saeed 2 года назад

    very good

  • @mohtarifhossame
    @mohtarifhossame Год назад

    Best app 🥰

  • @patriciorivero22
    @patriciorivero22 Год назад

    I LOVE YOUUUUUUUUU

  • @crazy-man
    @crazy-man Год назад +1

    yes notifications work with payload, only one problem. If you schedule a notification and reboot the phone or just exit the application, the payload will already be null and the desired page is not loading, is there a solution?

    • @codingorbit
      @codingorbit  Год назад

      I'm not sure if it works but did you try to schedule a notification with a payload then close the app and check if it works

  • @templetonmeshack2816
    @templetonmeshack2816 2 года назад +1

    hello, how can I inform all my devices of changes in the database using local flutter notification instead of cloud_messaging in firebase?
    I did the local notification implimentation but it only notifies a single application (which is the one I'm using to send notification).

    • @codingorbit
      @codingorbit  2 года назад

      I don’t think its doable without other online notification service such as cloud_messaging

    • @templetonmeshack2816
      @templetonmeshack2816 2 года назад

      @@codingorbit I have seen how they do cloud messaging but none of them are doing it with an onclick even triggered within the application, could you please do a video on how that is done?
      for example, create a note and store it in firebase then notify all users of the created note.
      Please
      🙏

    • @codingorbit
      @codingorbit  2 года назад

      @@templetonmeshack2816 I am doing FlutterFire playlist which will result in something similar check out this video: ruclips.net/video/9V0usupGyEc/видео.html

  • @samiromerbegovic2720
    @samiromerbegovic2720 Год назад

    Is it possible to repeat notification daily but at specific time. For example (Every day at 8 a clock).
    Can we access payload when app is down. When you access payload app is already running. If I press notification (which is scheduled)when app is closed it will open app like running it from '' ic_launcher "(app icon) and I have no access to payload.

    • @codingorbit
      @codingorbit  Год назад

      Of course it’s possible i think in one of the comments below i wrote some code related to it

  • @itsahmed-dev
    @itsahmed-dev Год назад

    I get the notification in the status bar but not the banner on my android device. Why not a banner as well?

    • @codingorbit
      @codingorbit  Год назад +1

      Could you check if it’s a permission issue

  • @zainishfaq7442
    @zainishfaq7442 2 года назад

    Good one can you make the chat notifications video because thats hard to follow by with FirebaseFirestore

    • @codingorbit
      @codingorbit  2 года назад

      Sure maybe soon will create a video about firebase notifications

  • @ashleshkini2586
    @ashleshkini2586 2 месяца назад

    How to show local notification at a particular time like a remainder of a appointment??

  • @zuxxlo2109
    @zuxxlo2109 Год назад

    onSelectNotifications doesnt exist anymore
    + if the app is closed and you click on notification with payload will it open in that specific page ?

    • @codingorbit
      @codingorbit  Год назад

      I’m not sure if the app is completely closed if it will open it or you will need deep linking

  • @jeffersonmauricio9572
    @jeffersonmauricio9572 2 года назад

    I think that your video can save my life. Do you have this project on github? I follow the steps, but something is doing wrong.

    • @codingorbit
      @codingorbit  2 года назад +1

      Thank you! I still haven't pushed it, hopefully today 😅

    • @samelobinna101
      @samelobinna101 2 года назад

      @@codingorbit you have not publish it yet i guess

    • @codingorbit
      @codingorbit  2 года назад

      @@samelobinna101 Sorry its pinned now

  • @codingorbit
    @codingorbit  2 года назад +14

    You can find the project repo here: github.com/Coding-Orbit/flutter_local_notification
    Update: the code in this video is kinda outdated, you can check the new video that implements awesome notification instead here
    ruclips.net/video/uZvWY1VGnZU/видео.html

    • @laurentdelannoy2380
      @laurentdelannoy2380 2 года назад

      I have cloned your application and nothing happens when I press the buttons? Can you help me?

    • @codingorbit
      @codingorbit  Год назад

      @@laurentdelannoy2380 Check the permissions

  • @prochesvara2019
    @prochesvara2019 Год назад +1

    Absolutely crushing it bro 💯. Definately the creme de la creme tutorial I could find about flutter local notification.
    However, I'm new to flutter development and would like to implement local notification on weekdays only ie Monday to Friday at 6 AM.
    I'm kindly asking anyone to help modify this method from the tutorial so that when called, it will implement daily local notifications from Monday to Friday;
    Future showDailyAtATimeNotification({
    required int id,
    required String title,
    required String body,
    required seconds,
    required time,
    required String payload
    }) async
    {
    var time = const Time(06, 00, 0);
    final details = await _notificationDetails();
    await _localNotificationService.showDailyAtTime(
    id,
    title,
    body,
    time,
    details,
    payload: payload,
    );
    }

    • @codingorbit
      @codingorbit  Год назад

      I hope you fixed that by now, if not let me know

    • @prochesvara2019
      @prochesvara2019 Год назад

      @@codingorbit not yet 😅😇

    • @codingorbit
      @codingorbit  Год назад

      @@prochesvara2019 Alright I haven't tested this but I think it will work let me know if it does or not:
      Future showScheduledNotification({
      required int id,
      required String title,
      required String body,
      required int seconds,
      }) async {
      final details = await _notificationDetails();
      await _localNotificationService.zonedSchedule(
      id,
      title,
      body,
      _scheduledWeekly(
      time: const Time(6), days: [DateTime.monday, DateTime.tuesday]),
      details,
      androidAllowWhileIdle: true,
      uiLocalNotificationDateInterpretation:
      UILocalNotificationDateInterpretation.absoluteTime,
      matchDateTimeComponents: DateTimeComponents.dayOfWeekAndTime,
      );
      }
      tz.TZDateTime _scheduledDays({required Time time}) {
      final now = tz.TZDateTime.now(tz.local);
      final scheduledDate = tz.TZDateTime(
      tz.local,
      now.year,
      now.month,
      now.day,
      time.hour,
      time.minute,
      time.second,
      );
      return scheduledDate.isBefore(now)
      ? scheduledDate.add(const Duration(days: 1))
      : scheduledDate;
      }
      tz.TZDateTime _scheduledWeekly({
      required Time time,
      required List days,
      }) {
      final scheduleDate = _scheduledDays(time: time);
      while (!days.contains(scheduleDate.weekday)) {
      scheduleDate.add(const Duration(days: 1));
      }
      return scheduleDate;
      }

  • @stenlyrachmad
    @stenlyrachmad Год назад

    Hi.. Any example for setup on android?

    • @codingorbit
      @codingorbit  Год назад

      Check out the pub.dev library please

  • @asondubuisi5807
    @asondubuisi5807 Год назад +1

    Is there no setup required for android?

    • @codingorbit
      @codingorbit  Год назад +1

      You can add extra things for android such as permissions. Check out the library on pub.dev and you can find it there

  • @nadaabbas6329
    @nadaabbas6329 Год назад

    I checked the code multiple times and it still doesn't show any notifications. I really don't know where the problem is !! there isn't any errors though. can you help me please I followed the same steps exactly as the video !!!!

    • @codingorbit
      @codingorbit  Год назад

      Try checking the permissions fir the emulator or the device, it might be the issue

  • @qussaiqassim9912
    @qussaiqassim9912 Год назад

    👍🏾❤️

  • @user-kc1cu8tf2c
    @user-kc1cu8tf2c 11 месяцев назад

    Payload notifications when the app is terminated? How to do it??

  • @reardelt
    @reardelt Год назад

    Don't they use darwininitialization settings now?

    • @codingorbit
      @codingorbit  Год назад

      I guess my video is kinda outdated! should I make a new video using the new version!

  • @benamiabderrahimabdo
    @benamiabderrahimabdo Год назад

    was sowhere where I couldn't get my stuff. Now 3, I looked for help, watched video upon video after video and on and on. About a

    • @codingorbit
      @codingorbit  Год назад

      I didn't fully understand but I'm glad if it helped!

  • @munaretto_
    @munaretto_ Год назад

    I followed the instructions, step by step, but I couldn't run the code. Notifications do not appear on emulator screen (PIXEL 3, ANDROID API 29),. Can you help me?

    • @codingorbit
      @codingorbit  Год назад

      Can you please check if the permission is enabled. And there has been an update to the library check that too

  • @vladhunter1709
    @vladhunter1709 Год назад

    Привет! How to fix it so that it does not disappear

  • @KobeandNash2413
    @KobeandNash2413 Год назад

    I think parts of the tutorial have been deprecated already, for example there is no IOSInitializationSettings in the latest release of the library. Thanks for the tutorial though!

    • @codingorbit
      @codingorbit  Год назад

      Thats the beauty of flutter its quick progress and updates 😅

    • @dalalghesh1452
      @dalalghesh1452 Год назад

      hello
      iam getting errors on this part, do u now how i can solve it?

    • @codingorbit
      @codingorbit  Год назад +1

      @@dalalghesh1452 There are couple of things have to be changed but they aren't major changes. like using DarwinNotificationDetails instead of IOSNotificationDetails

  • @matheusfigueredo7543
    @matheusfigueredo7543 Год назад

    Hey there. My app is closgin when i click on show notification. Any idea why?

    • @codingorbit
      @codingorbit  Год назад +1

      What is the error you received getting

    • @matheusfigueredo7543
      @matheusfigueredo7543 Год назад

      ​@@codingorbit Just shows Lost Connection
      I noticed that when i remove this code from AppDelegate.swift:
      if #available(iOS 10.0, *) {
      UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
      }
      the notification works

    • @codingorbit
      @codingorbit  Год назад

      @@matheusfigueredo7543 In that case check out the library for update I guess that would solve it

  • @usynugroho4026
    @usynugroho4026 Год назад

    The named parameter 'onSelectNotification' isn't defined.
    can you help me to fix this problem?

    • @codingorbit
      @codingorbit  Год назад

      You can use instead "onDidReceiveNotificationResponse" and pass to the method "NotificationResponse" instead of "String"

    • @fsintegratesolution2461
      @fsintegratesolution2461 Год назад

      @@codingorbit Hi, Please what do you mean by this?

    • @fsintegratesolution2461
      @fsintegratesolution2461 Год назад

      @@codingorbit I'm having the same issue too

    • @codingorbit
      @codingorbit  Год назад

      @@fsintegratesolution2461 I mean the library has been updated so you need to change the code a little bit

    • @mrbeastwithnomoney
      @mrbeastwithnomoney Год назад

      @@fsintegratesolution2461 did you solve it

  • @abdelouahebbenouar6157
    @abdelouahebbenouar6157 2 года назад

    Can you give us the source code please?

  • @elcanpenahov4694
    @elcanpenahov4694 2 года назад

    Gives this error :/
    E/flutter ( 4318): #1 MethodChannel._invokeMethod (package:flutter/src/s
    platform_channel.dart:167:18)
    E/flutter ( 4318):
    E/flutter ( 4318): #2 FlutterLocalNotificationsPlugin.show (package:flut
    l_notifications/src/flutter_local_notifications_plugin.dart:215:7)
    E/flutter ( 4318):
    E/flutter ( 4318): #3 LocalNotificationService.showNotification (package
    ations/services.dart:64:5)
    E/flutter ( 4318):
    E/flutter ( 4318): #4 _HomePageState.build. (package:
    tions/homePage.dart:36:17)
    E/flutter ( 4318):

    • @codingorbit
      @codingorbit  2 года назад

      Hmm thats weird but make sure to initialise it first before calling the method. If it didn’t work check the source code on GitHub

  • @s-jobs
    @s-jobs Год назад

    your flutter code used for this video is out to date !

  • @keikusanagi99
    @keikusanagi99 9 месяцев назад

    good video but the volume and tone of your voice is soooooooooooo low that sometimes I almost fell asleep and had to return it :( sorry

    • @codingorbit
      @codingorbit  4 месяца назад

      Hahaha, yeah I was working on that

  • @prajeshkayastha9416
    @prajeshkayastha9416 Год назад

    I can't call IOSInitializationSettings() ,

    • @nick8292
      @nick8292 Год назад

      I'm at this stage too. Had to downgrade dependencies to match those in the video.

    • @prajeshkayastha9416
      @prajeshkayastha9416 Год назад

      @@nick8292 can you tell me the version of the dependencies you are using of flutter notification?

    • @codingorbit
      @codingorbit  Год назад

      I believe the library has been updated to a newer version

    • @prajeshkayastha9416
      @prajeshkayastha9416 Год назад

      @@codingorbit so what can we do now?

    • @nick8292
      @nick8292 Год назад

      @@prajeshkayastha9416 I have implemented the first part (local notification) with no problem copying the exact same code and dependencies as in the video.

  • @bagusandrewijaya
    @bagusandrewijaya Год назад

    your tutorial isnt uptodate can you make new tutorial

  • @ankansharma4897
    @ankansharma4897 Год назад

    AndroidNotificationDetails(
    'channel_id', 'channel_name',
    channelDescription: 'your channel description')
    What to pass in "channel_id","channel_name" ?

    • @codingorbit
      @codingorbit  Год назад

      You can pass in whatever you want.
      The Id is a unique String to identify each NotificationChannel and the name is viewable by the user in settings

  • @alfredoceci4208
    @alfredoceci4208 Год назад

    I copied the exact same code and it gives me -> LateError (LateInitializationError: Field '_local@326310200' has not been initialized.)

    • @codingorbit
      @codingorbit  Год назад

      You might be missing something, a late variable is being used without initializing

    • @alfredoceci4208
      @alfredoceci4208 Год назад

      @@codingorbit yeah, But in the code the late variable has been used only once. Right?

    • @alfredoceci4208
      @alfredoceci4208 Год назад

      @@codingorbit Now after "pub get" does not throw any error, but it does not show the notification when I press the button, how is that possible....?