locked
Xamarin Forms Android Fixed Notification RRS feed

  • Question

  • User383479 posted

    Hi all,

    I want fixed notification xamarin forms on android. I mean like music app or love counter app notifications unremovable and updateable.

    Also the notification package should be able to do them. Even if Android restarts, it should not be affected. The application should notify even if it is closed.

    Is this possible?

    Thanks in advance

    Monday, June 17, 2019 4:51 PM

Answers

  • User379860 posted

    You can achieve it with dependence service, then achieve a foreground service, pop up the notification in this foreground service like this link.https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/services/foreground-services,I a have achieved a forground services in xamarin forms, you can see this link.https://stackoverflow.com/questions/55752147/how-to-create-service-doing-work-at-period-time-in-xamarin-forms/55757316#55757316

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, June 18, 2019 8:11 AM

All replies

  • User379860 posted

    You can achieve it with dependence service, then achieve a foreground service, pop up the notification in this foreground service like this link.https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/services/foreground-services,I a have achieved a forground services in xamarin forms, you can see this link.https://stackoverflow.com/questions/55752147/how-to-create-service-doing-work-at-period-time-in-xamarin-forms/55757316#55757316

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, June 18, 2019 8:11 AM
  • User379860 posted

    Are there any updates for this issue? If the reply is helpful, please try to mark it as an answer, it will help others who have similar issue.

    Wednesday, June 19, 2019 9:05 AM
  • User383479 posted

    @LeonLu said: Are there any updates for this issue? If the reply is helpful, please try to mark it as an answer, it will help others who have similar issue.

    Hi LeonLu,

    Thanks for replies and sharing. I examined code and trying sample. yes fixed notification worked as service. How do I update it on the PCL (sharing code) side instantly? Do you have sample code for this?

    Note: I'm removed channell id code and worked on android 5.0. var notification = new Notification.Builder(this, "10111") remove 10111

    Thursday, June 20, 2019 12:04 PM
  • User379860 posted

    If you just use it in android 5.0, you can remove channel id, but if you want to use notification in android 8.0 or later, you should create an notification channel and unique channel id.

    How do I update it on the PCL (sharing code) side instantly? Do you have sample code for this?

    You can use MessageCenter send information between PCL and android .You can refer to this link. https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/messaging-center

    Friday, June 21, 2019 7:09 AM
  • User383479 posted

    Hi LeonLu,

    Thanks for messaging center suggestion. It seems to be working right now. I keep testing. My last question is how do I catch the click on the notification. For example, to the homepage.

    Friday, June 21, 2019 1:02 PM
  • User383479 posted

    Hi @LeonLu

    Everything is working ok with your help. I noticed something. I resend new value every second. This works. But after a while it slows down. For example, after 1 hour, it is progressing to 2 seconds. Very slow in app. Is Android auto slowing down my app? Extend the timer time for solution? Or How can we fix this?

    Thanks

    Sunday, June 23, 2019 12:59 PM
  • User383479 posted

    Hi @LeonLu

    I increased timer tick value to 10 minutes. But device reboot killing foreground notification. How can startforeground notification on boot completed ?

    Thanks

    Tuesday, June 25, 2019 6:15 AM