Search code examples
servicebackgroundxamarinmvvmcross

MvvmCross long running process


This may well be a stupid question, but, I'll ask it anyway.

I want to start a process which will run as long as the application is running. I want to detect network changes and sync data to the server.

So my question is how to I start a long running (background) service in a mobile app with MvvmCross

Or failing that how do I invoke a service when I detect a network change. This service may run for a long period of time.

Thanks in advance


Solution

  • For long running services and for responding to network changes you often need to drop to native features.

    On Android, for example, you will need to look at Intent broadcast receiver like that shown in Broadcast receiver for checking internet connection in android app

    You could wrap this functionality inside a plugin of some description within MvvmCross - but you may find that this area is best implemented as a little module natively on each platform you target - you may find that the platforms just don't have a similar "shape" to their APIs in this area.