Implement Push Notification In .NET MAUI (Android)

Поділитися
Вставка
  • Опубліковано 13 січ 2025

КОМЕНТАРІ • 161

  • @doctorj1607
    @doctorj1607 Рік тому +3

    The Token Is only retrieved on first install of the App. if a mistake is made you need to uninstall the app and try again. Works good. excellent video.

  • @abhayprince
    @abhayprince 2 роки тому +4

    was looking for this. Thank you Pragnesh for this amazing To the point tutorial

  • @Robinbura
    @Robinbura 2 роки тому +4

    Great Pragnesh....Thanks for your help..... Expecting future video on background tasks in maui...Thanks........

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      Thank you Robin, and sure I will create video for it in future.

    • @christianzaragoza7575
      @christianzaragoza7575 2 роки тому

      Seria genial eso

    • @kelvinkirwa4887
      @kelvinkirwa4887 Рік тому

      can we have a google meeting with you please.the notifications are not working for me when the app is in the background mode.THANKS.

    • @nguyenquangphong1660
      @nguyenquangphong1660 11 місяців тому

      Have you solved the problem yet?@@kelvinkirwa4887

  • @dean2525
    @dean2525 Рік тому +4

    I dont see the part in the video where the FirebaseApp and authentication is created... ? My OnNewToken is never executed? What are the contains of the admin_sdk.json, since I can't tell what fields are needed to authenticate to FCM before getting a PNS handle. Thanks

  • @yoriichi28
    @yoriichi28 Рік тому

    Wah pragnesh bhai wah mast che....

  • @nishantkumar681
    @nishantkumar681 Рік тому +2

    after adding all three plugins still not getting the option Googleplay services Json???Also not adding json file directly in android we need to put it in a folder.

  • @edward30525
    @edward30525 Рік тому +1

    Thank you for sharing! I have a question at 26:39, I got success response, however my device dosn't receive any notification (in top notification bar), do you know what possibly went wrong?

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  Рік тому

      Did you allowed push notification permission from device setting?, because in newer android device we need to set push notification permission.

  • @jeff-uq2sz
    @jeff-uq2sz Рік тому

    Thank you Pragnesh this was immensely helpful!

  • @abhayprince
    @abhayprince 2 роки тому +3

    Hi Pragnesh, I tried to implement this but somehow FirebaseService class is not getting hit, so its not creating device token. Then I cloned your repo and its same for that as well. FirebaseService is not getting hit. Any thoughts?
    fyi - I have added my google service json and fcm server key. project is building and running but firebase service is not working

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому +1

      HI Abhay, Can you check bundle identifier is matching with google service json package name & also Build Action of google service json set to GoogleServiceJson,
      And if you are testing my project in your system, then add application with this package name "com.companyname.pushnotificationdemomaui" in your firebase console and then download google service json and try to test it.

    • @abhayprince
      @abhayprince 2 роки тому

      @@ProgrammingWithPragnesh Buil action i already changed. let me check for package in service json

    • @MrRKYDA
      @MrRKYDA 2 роки тому

      @@ProgrammingWithPragnesh I have the same problem. FirebaseService never gets hit, so not creating device token. My google-service.json is set to GoogleServiceJson and the package name is well defined on Firebase

    • @nekkke
      @nekkke 2 роки тому +3

      I had the same issue, firebase service seems to be called once first time install app on device, if you clear the preferences and delete the token, firebase no ask a new token, so everytime i have uninstalled application and redeploy it, i tested it in debug mode, and Firebase will be called only first time you open the app..

    • @mohammadsalah716
      @mohammadsalah716 Рік тому +1

      Did you find any solution for this? I have the same issue

  • @Dave_Castle
    @Dave_Castle Рік тому +2

    Hi Pragnesh, 38:28 at this time i am facing the same error when i click on the notification message on the foreground
    please let me know. how can i resolve this problem.

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  Рік тому

      Hi, I didn't tried in lates .NE7 7 MAUI Project, I will check and let you know.

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  Рік тому

      Hi, i fixed the crash issue of notification. You can go through my latest video Implement push notification in .net maui part 2

    • @Dave_Castle
      @Dave_Castle Рік тому

      @@ProgrammingWithPragnesh thank u

  • @alessandrolanzoni1109
    @alessandrolanzoni1109 2 роки тому +4

    Thanks for all videos that you share, they really helpful. Will you do the IOS part for Push Notifications too? Best regards

  • @santiagoc93
    @santiagoc93 7 місяців тому

    Great! I added topics to your example and it works!

  • @imthelonedubber
    @imthelonedubber Рік тому +2

    When I install my app notifications are disabled. How can I enable them or prompt the user to enable them? If I don't enable them notifications are not shown, but if I enable them manually (Settings -> Notifications) it works.

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  Рік тому

      I think from android 13 you can request runtime permission for push notification.
      add this in androidmanifest.xaml file and target android version to android 13

  • @nagendrababu3291
    @nagendrababu3291 Рік тому +1

    Hi, it's very helpful for me but I am looking for schedule notifications like (day wise ,alternative ,weekly ,monthly).
    Can you please give me any suggestion for this how can I implement the notification

  • @ced888
    @ced888 2 роки тому +1

    nice tuto.
    Thank you.
    Have you found the way to fix application crash when open notification while application is open?

    • @kelvinkirwa4887
      @kelvinkirwa4887 Рік тому

      hey ? are you able to receive the notification when the app is not running , i mean when you've not opened it ? thank you.

  • @brendoeduardo4555
    @brendoeduardo4555 Рік тому

    Muito bom o video, implementei em um projeto Maui Blazor e funcionou perfeitamente !

    • @duartebeck
      @duartebeck Рік тому

      Funcionou para o framework 7 ?

    • @brendoeduardo4555
      @brendoeduardo4555 Рік тому +1

      @@duartebeck não sei dizer, eu implementei em um projeto Maui blazor Android

  • @alfaqeehamer2823
    @alfaqeehamer2823 10 місяців тому

    Thanks for helping and supporting

  • @hungnqqa613
    @hungnqqa613 2 роки тому +1

    Hi! i have a question, how i make a background service in maui (android) project?
    my Idea is that i base on background service to get data from database, and then push notification to maui android. How i can do that? i have just stuck at "how make my maui app running background", even enduser do not open my maui app. Any else help me! thanks so much

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      Hi, I have created one video on foreground service (application run even entire app is closed) but that in Xamarin not in .NET Maui, You can follow the step and try to implement in Maui/Platform/Android.
      Here is the video link : ua-cam.com/video/0hp-yGCyHh8/v-deo.html

    • @hungnqqa613
      @hungnqqa613 2 роки тому

      @@ProgrammingWithPragnesh thank you so much

    • @hungnqqa613
      @hungnqqa613 2 роки тому

      @@ProgrammingWithPragnesh i did that on maui android. But can i ask one more question. How i can pass context ( using EF core) to foreground service? my purpose is access to database and then do some logical. Hopefuly receive your answer.

  • @HandleDead
    @HandleDead Рік тому +1

    is it still topical? i can't set google services in file options, that option is missing for me

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  Рік тому

      Hi you need to install Xamarin.Google,Dagger plugin in your android platform then just rebuild or close and re-open visual studio.

    • @HandleDead
      @HandleDead Рік тому

      yeah i did all of that and nothing maybe its cuz i have the newest VS studio. So i don't know what to do i was hopping on this notifications

  • @SamiJinzo
    @SamiJinzo Рік тому +1

    Hi. Thanks for the gr8 content.
    I've a problem when I try to Add The Logic Related To Send Notification..
    The "PushNotificationRequest" is not exist, even I did import all the required plugins, what seems to be the problem? and how can I fix it ? which namespace/pakckage that I need to import in order to solve this problem.. :D

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  Рік тому +1

      public class PushNotificationRequest
      {
      public List registration_ids { get; set; } = new List();
      public NotificationMessageBody notification { get; set; }
      public object data { get; set; }
      }
      public class NotificationMessageBody
      {
      public string title { get; set; }
      public string body { get; set; }
      }

  • @chrisdungo1088
    @chrisdungo1088 Рік тому

    Hi Pragnesh, when I clone your project, it can't find the dependencies for the AndroidX and Firebase namespaces, which are used to call the service. Do you have any suggestions on this? Thanks

  • @orlandotorres1285
    @orlandotorres1285 Рік тому

    Great Content!!! How do you make the notification pop up?

  • @CoderboyPB
    @CoderboyPB Рік тому +1

    The firebase service has changed, I always get on this version an authorized failed status.

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  Рік тому

      Hi, you need to use http v1 for sending firebase push notification. or need to enable legacy http call for firebase.
      firebase.google.com/docs/cloud-messaging/migrate-v1

  • @RajeshKumar-io6nd
    @RajeshKumar-io6nd Рік тому

    Hi Its working fine withing one devices ,msg is not coming on another devices , I wanted to implement msg apear in all devices which is using same channel ? How this concept works. or poeple login with same username in mobile app notitication comes to that group?

  • @aspnet-y8y
    @aspnet-y8y 9 місяців тому

    It works, thank you very much

    • @ducvunguyen5607
      @ducvunguyen5607 9 місяців тому

      bạn ơi, cho mình hỏi chút về cái này với ạ?

    • @aspnet-y8y
      @aspnet-y8y 9 місяців тому

      @@ducvunguyen5607 bạn hỏi gì nhỉ

  • @FnOTradingLearner
    @FnOTradingLearner Рік тому +1

    Does this sample works directly or need to modify on our machine?

  • @Robinbura
    @Robinbura 2 роки тому +1

    HI, Pragnesh... this is in regards to the error we are facing on clicking the notification.....
    If we change the MainPage = new AppShell(); from AppShell() to some other page... it is working. Could you please check this out. There is some problem with the routing

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      Thank you so much robin, i will check this. and notification implementation working for you right?

  • @franciscofernandezcasas7924
    @franciscofernandezcasas7924 2 роки тому +1

    That is awesome thank you, Can you make an example for IOS please?

  • @jmp6494
    @jmp6494 2 роки тому +1

    Thanks Pragnesh. Do you/anyone know why it crashes when Notification Clicked? Error at MainActivity.cs base.OnCreate(saveInstanceState); Error message - Java.Lang.IllegalStateException: 'FragmentManager has been destroyed' Thanks in advance.

  • @muks8398
    @muks8398 Рік тому

    Hi, do you have a Huawei Push Kit example ? This works perfectly on Android devices that's not Huawei.

  • @chintanbug
    @chintanbug Рік тому

    Hi, thank you for detailed video.
    I have one issue.. if the App is not running and then i send notification via PostMan then it doesn't pop. Can you please help on this?

  • @sangachidam3219
    @sangachidam3219 2 роки тому +1

    Excellent videos. can you do this for IOS please

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      Hi, I am not able to run iOS app in real device with push notification configuration.
      I have created blog about implementing notification in iOS, You can take a look at this:
      xamarincodingtutorial.blogspot.com/2022/10/implement-push-notification-in-net-maui.html

  • @chapuen
    @chapuen 2 роки тому +1

    Hi Pragnesh! Thanks for the video. I tried to set the Build Action of google service json to GoogleServiceJson but the option never appear on list. Thanks

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому +1

      HI, You need to Install Xamarin.Google.Dagger Plugin in Your Android Dependency, In video I shown about installing package from 4:25

    • @chapuen
      @chapuen 2 роки тому +1

      I follow all the steps in the video. Restarted Visual Sudio and it doesn't appear. Do you think I am missing something?

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому +1

      I m not sure bro, you can download my git repo from description and check for that GoogleServiceJson option.
      and also the list of plugin i installed.

    • @chapuen
      @chapuen 2 роки тому

      I will!

    • @chapuen
      @chapuen 2 роки тому +1

      @@ProgrammingWithPragnesh I think I found the problem. In the .csproj file I have a line called false because in VS 17.4 preview Microsoft.Maui crash on splash after execute the project. I installed the 17.3 (not preview) and removed this line. Thanks!

  • @shamabraham
    @shamabraham 9 місяців тому

    FCM token is not getting genrated in FirebaseService.

  • @kelvinkirwa4887
    @kelvinkirwa4887 Рік тому

    hello sir, thanks first for this.However , the notifications are only working for me when the app is in the foreground mode .When inactive(that is , i completely close the app ), the app fails to receive the push notifications.How can we fix that ? thank you.

  • @christianzaragoza7575
    @christianzaragoza7575 Рік тому

    Hola gracias por tu aporte, en net6 funciona bien, en net8 no habilita el permiso de notificaciones, si le doy el permiso a la app funciona, pero no lo hace de forma automática, sabes que pudo haber cambiado de net6 a net8 en lo que refiere a permisos? muchas gracias

    • @Nahuel-223
      @Nahuel-223 Рік тому

      in inglish

    • @christianzaragoza7575
      @christianzaragoza7575 Рік тому

      Hello, thanks for your contribution, in net6 it works fine, in net8 it doesn't enable the notifications permission, if I give permission to the app it works, but it doesn't do it automatically, you know that it could have changed from net6 to net8 in what Do you mean permissions? thank you so much@@Nahuel-223

  • @SergKoshelev
    @SergKoshelev Рік тому

    how to get token? i can login with email and passwork to firebase to get it

  • @richardbatsbak8868
    @richardbatsbak8868 Рік тому

    Hi, does the device token have a lifetime?

  • @Sriaadhira
    @Sriaadhira 2 роки тому +1

    Firebase Console is free for unlimited ?

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому +1

      Push Notification & Crashlytic is free and for other you can see pricing here : firebase.google.com/pricing

    • @Sriaadhira
      @Sriaadhira 2 роки тому

      @@ProgrammingWithPragnesh Do you have push notification sample for both android , ios . I can pay you

  • @PramodKumarBal-g1q
    @PramodKumarBal-g1q Місяць тому

    I am facing the issues FirebaseService not executing and not creating the token. Project Package Id and google-services.json package id also same can you guide me what is the exact issues?

  • @yousefsayed5909
    @yousefsayed5909 2 роки тому

    I have a problem when I try to send the notification from the app it shows me unauthorized. But it is being sent from the site. can you help

  • @treasurenkonyana2745
    @treasurenkonyana2745 2 роки тому

    Hi thank you, this works great. Any plans to do iOS?

    • @kelvinkirwa4887
      @kelvinkirwa4887 Рік тому

      hello ? are you able to receive the notification even when the app is not actively running ?

  • @ysonmencidor6834
    @ysonmencidor6834 9 місяців тому

    does it work in .net 8?

  • @Birb-
    @Birb- 2 роки тому

    i keep getting [FirebaseInstanceId] Failed to get FIS auth token
    any way to resolve this?

  • @abdullahberber2538
    @abdullahberber2538 2 роки тому +1

    Thank you

  • @natureandfun62
    @natureandfun62 2 роки тому

    in my case once i click on the button it shows notification send but i can't see any notification ... can u plx help

    • @natureandfun62
      @natureandfun62 2 роки тому

      actually the token was null. now i fixed token issue ...but i am getting an exception a long one which says
      Java.Lang.IllegalArgumentException .... something flag_immutable or flag_mutable in firebase service ... sendNotification method line no. 47 pendingIndent

  • @geraldcanlubo2365
    @geraldcanlubo2365 2 роки тому +1

    Did someone figured out the error on Notification Clicked? Thank you in advance

    • @jmp6494
      @jmp6494 2 роки тому

      Thanks Gerald. Did you get any solution of this?

  • @cissemy
    @cissemy 2 роки тому +1

    Hi Pragnesh
    How to implement push notification in .NET MAUI (ios) ?
    Thanks

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      Hi Mohamed Cisse , I have created a blog for push notification in iOS you can go through this.
      xamarincodingtutorial.blogspot.com/2022/10/implement-push-notification-in-net-maui.html
      I am not able to test push notification on real device due to that I didn't recorded video.

    • @cissemy
      @cissemy 2 роки тому +1

      @@ProgrammingWithPragnesh
      Thanks

  • @hexoter
    @hexoter Рік тому +1

    in net7 not working at all

  • @madraven37
    @madraven37 2 роки тому +1

    Waiting for iOS 💕💕💕💕💕💕

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      Hi, I have created blog related to implementing in push notification in iOS: xamarincodingtutorial.blogspot.com/2022/10/implement-push-notification-in-net-maui.html

  • @muks8398
    @muks8398 2 роки тому

    Hi , please assist with this error: Java.Lang.IllegalArgumentException: 'com.companyname.pushnotificationdemomaui: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE

    • @muks8398
      @muks8398 2 роки тому

      Please kindly assist

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      Hi , at 31:55 min in video i m creating pending intent there can you try to pass flag like mutable or immutabls

    • @muks8398
      @muks8398 2 роки тому +1

      @@ProgrammingWithPragnesh please reply with code example 🙌

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      var pendingIntent = PendingIntent.GetActivity(this,
      MainActivity.NotificationID, intent, PendingIntentFlags.UpdateCurrent |PendingIntentFlags.Immutable);

    • @muks8398
      @muks8398 2 роки тому +1

      @@ProgrammingWithPragnesh Thank you so much , it's working now.

  • @keisoft7257
    @keisoft7257 2 роки тому +1

    Thank you!

  • @b0wl0rd
    @b0wl0rd 2 роки тому

    Did anyone figured out how to solve that app crush when notification clicked and app is opened?

  • @bishalpoudel1396
    @bishalpoudel1396 Рік тому

    can you please provide tutorial to do this for targeted framework net7.0-android

    • @leonardocardosodasilveira3251
      @leonardocardosodasilveira3251 Рік тому

      I use this with .net 8, what is your problem ?

    • @eneskoc6525
      @eneskoc6525 5 місяців тому

      @@leonardocardosodasilveira3251 .While trying to implement it in .net 8, I get a conflict error between packages when I download the mentioned packages. How did you overcome this?

  • @ketankumargodhani7519
    @ketankumargodhani7519 2 роки тому +1

    Never execute Android > Services > FirebaseService > OnNewToken() this method never called,
    Is there any specific config for it. like register that service anywhere? or will it execute only on the actual android device not in an emularor.

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      HI Ketan, Can you check in real device and let me know it's working or not?

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      Hi Ketan, I have tested in android emulator too it's working for me, can you use my project, and also can you add app in firebase console with this identifier "com.companyname.pushnotificationdemomaui" and that service json content add in google-service.json file. and try to test it.

    • @ketankumargodhani7519
      @ketankumargodhani7519 2 роки тому

      @@ProgrammingWithPragnesh Thanks for the quick response, let me try it. again using your project.

    • @ttb1988
      @ttb1988 2 роки тому

      @@ProgrammingWithPragnesh OnnewToken never hit, although change package name to mine. does it need to add service to MauiProgram.cs?

    • @ttb1988
      @ttb1988 2 роки тому

      Just check, device token is not null in emlator but null in real device, push notification is not hit

  • @VerskoFirebase
    @VerskoFirebase Рік тому

    Has anyone actually got this to compile under .Net 7 and Maui?

  • @natureandfun62
    @natureandfun62 2 роки тому

    but this is missing API part , can u plxx create one video ...... To send push notification from api ..... to android or ios

    • @natureandfun62
      @natureandfun62 2 роки тому +1

      i did that thing by myself ... now can u tell me how to send notification to all users or devices

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      @@natureandfun62 Hi, There are two way you can send notification to multiple devices, One You can Use FirebaseAdminSDK Or
      other just pass list of device tokenIDs here in registration_ids property of PushNotificationRequest class.
      public class PushNotificationRequest
      {
      public List registration_ids { get; set; } = new List();
      public NotificationMessageBody notification { get; set; }
      public object data { get; set; }
      }
      public class NotificationMessageBody
      {
      public string title { get; set; }
      public string body { get; set; }
      }

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      FirebaseAdminSDK will be easy to send notification to both android & ios devices

    • @natureandfun62
      @natureandfun62 2 роки тому

      @@ProgrammingWithPragnesh btw where can i get these registration ids... or how can i get these

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  2 роки тому

      @@natureandfun62 You need to save device token In your Server Side DB Like SQL,
      So when user install and launch the app you will get the device toke, Save that token in your DB. And later on use that for sending notifications.

  • @sandrocirlinisa
    @sandrocirlinisa Рік тому

    notificationManager.Notify(MainActivity.NotificationID, notificationBuilder.Build()); not show notification

  • @rafaelparenza8678
    @rafaelparenza8678 Рік тому

    fiz igual, mas minha notificação não chega D:Fiz o mesmo, mas minha notificação não chega :D:

  • @TSHORYUKEN
    @TSHORYUKEN Рік тому +1

    Great video ! By the way i just begin develop an API but when i use post httpclient my app crashes immediatly , any ideas . ?

    • @ProgrammingWithPragnesh
      @ProgrammingWithPragnesh  Рік тому +1

      Hi, if you are using http url then try to add android:usesCleartextTraffic="true" in manifest file.

    • @TSHORYUKEN
      @TSHORYUKEN Рік тому

      @@ProgrammingWithPragnesh you're the best ! Thanks so much !!!

  • @franciscofernandezcasas7924
    @franciscofernandezcasas7924 2 роки тому +1

    Thanks!