Question

I have a simple app in Android, that uses some features like Services and Broadcast Receivers. It is a simple project, that uses SignalR to make a chat. A basic chat, where the service has the signalR connection and staying listening for any new messages or contact's status's updates.

Then, I have some broadcast receivers:

  • to start the service,
  • when receive a new message to add in the chatList
  • when receive a new contact online to update the contactList.

So it connects to a server that uses SignalR implementation, and do all the server job that is expected from a chatWebServer.

So, I'd like to re-write this app, using MvvmCross, so i could have a WindowsPhone, iOS and Android versions. I know the broadcast receiver could be changed for the Messages Services in MvvmCross, but the Android Services/ iOS Long Tasks/ WindowsBackgroundsTasks would be implemented as what in MvvmCross? Would be possible to have it implementation in Core project, so I can reuse it in all platforms? Can anyone help how would be it archtiecture?

Thanks in regard, Gabriel Bastos

Was it helpful?

Solution

You will still need to rely on what the platform has available for you. So on Android you would still need to have a BroadcastReceiver or at least a Service which has the SignalR connection, otherwise it will not survive if the application is closed.

iOS and Windows is a bit of a different story, there you are not allowed to have stuff running in the background. So here you would probably need to use push notifications to notify of new messages. Although on Windows Phone you can have Scheduled Tasks or also called Background Agents here I think you can do something every 60 seconds at most.

On iOS you are out of luck you simply can't do stuff in the background unless you are using the built in Location Services or something like that.

MvvmCross does not do anything magically, nor does it allow to create a service which does something the platform does not provide.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top