I'm making a timer app, so backgrounding is super important. The way I am doing it is through this method outlined in this link. https://robgibbens.com/backgrounding-with-xamarin-forms/ Basically a loop of Ticked messages and updating the view.
The issue is I want to have multiple timers running at once. This confuses my program and the timers start receiving eachothers' messages. Any idea how you can send messages privately in the message center between one class and the AppDelegate.cs and MainActivity.cs classes?
Thanks
You can set different message names for
MessagingCenter, like following code. One Message calledOneMessage, the other message calledTwoMessage,When we recevice the MessagingCenter, we can use MessageName to distinguish them
Here is running gif.
Here is my demo.
https://github.com/851265601/MessageCenterDemo
I notice you want to make the background service always running. Due to Android 8.0 limiation. Normal service will be killed if Application in the background. So I advice you to use Foreground service to keep the service always running.
https://learn.microsoft.com/en-us/xamarin/android/app-fundamentals/services/foreground-services
Here is my demo about foreground service.
https://github.com/851265601/ForeGroundService