0

Premise:

  • Mobile Client uses Xamarin Native as a technology.
  • I have a Mobile Client which uses a PCL that performs the socket connection to remote server.
  • All communications to the remote server are only thru the PCL’s socket based connection.

Requirement:

  1. The Mobile client needs to maintain the connection to the remote server whether its in the foreground or the background

  2. The reason it needs the connection when it is in background is to update the Remote Server about its geo-position.

Current Problem:

Once the app goes into the background, the app loses the socket connection.

Suggestion Required for :

  1. What is the best way to keep the connection active to the remote server, even when the Mobile Client is in the background.
  2. How should I implement this solution for the best performance?
  3. Any code snippets will help?
Kashi
  • 234
  • 2
  • 5
  • On Android, you will need to "move" your socket code into a native `Service`. On iOS, you will need to re-architect your design (unless it is a VoIP app) as you will not be able to maintain a constant socket connection in a backgrounded app: https://developer.xamarin.com/guides/ios/application_fundamentals/backgrounding/introduction_to_backgrounding_in_ios/ – SushiHangover Dec 26 '17 at 22:04

2 Answers2

0

try to look at silence push notification

Also you can use Background fetch on iOS.

Anton
  • 13
  • 5
0

This is what was done.

  1. Socket connection was disconnected when the app goes into the background.
  2. For Location updates from device, a REST API call was made to the server.
  3. If the server wanted to communicate to the Mobile Client, it was using Push Notifications.

Once the app comes into foreground, socket connection was opened as usual.

Kashi
  • 234
  • 2
  • 5