Hi everybody.
In my app need a task auto run every 15min. I have successed with UWP background task.
But I have visit Xamarin Document of X.iOS and X.Android. I can not completed understand it.
Please make a simple sample about background task run every 15min in xamarin.forms
THANK YOU VERY MUCH.
Answers
Hi ,@NguyenLiem
In Android you can use the
AlarmManager
( under Android 4.4) orJobSchedulerService
( above Android 5.0) orTimer
(java Api). Maybe the FCM will help you.If there is an task auto run every 15 min , the app should be alive all the time . In android it can't be achieved , because it will consumes electricity very fast . Google doesn't advocate doing that.
I'm creating app for my company, In my app need 2 feature:
1. Send location to server every 15min (Or all time if can)
2. Send notification when server have new records of data.
Please suggest me the best way to do this!
Thank you!
Hi @NguyenLiem
Please use following code
http://arteksoftware.com/backgrounding-with-xamarin-forms/
Will it run without open app?
Hi > @NMackay said:
Use this code to run without even app open
I have seen this sample.
But I'm sorry, my english is terrible, I can not complete understand it.
Can you help explain in every row of code, thank you!
This link is very old and no longer works in Xamarin Forms. Is there an updated version or even an updated sample that you know of?
https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/services/
https://docs.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/introduction-to-backgrounding-in-ios
Try referring to the official documentation, it's very good.
Never used this but might give you some ideas, I'd check the lines provided to make sure your aware of each platforms limitations, this pluggin will have the same limitations, for old Android API levels, you'll need to see what's supported etc
https://github.com/winstongubantes/MatchaBackgroundService