I am new to Windows 10 and currently working on Location based apps. My requirement is to track user locations for a particular time interval and send data to the server every 10 minutes. Can someone suggest whether this is possible in Windows 10 or not? I am not aware of this.
Update
I also want to do the above in when the app is in the background also.I tried below code
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
if (e.NavigationMode == NavigationMode.New)
{
var extendedSession = new ExtendedExecutionSession();
extendedSession.Reason = ExtendedExecutionReason.LocationTracking;
extendedSession.Description = "Location tracking";
ExtendedExecutionResult result = await extendedSession.RequestExtensionAsync();
if (result == ExtendedExecutionResult.Allowed)
{
Debug.WriteLine("Background execution approved");
}
else
{
Debug.WriteLine("Background execution denied");
}
Geolocator locator = new Geolocator();
locator.DesiredAccuracyInMeters = 0;
locator.MovementThreshold = 500;
locator.DesiredAccuracy = PositionAccuracy.High;
locator.PositionChanged += Locator_PositionChanged;
}
}
private void Locator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
Debug.WriteLine(args.Position.Coordinate.Latitude.ToString("0.00000000") + " " + args.Position.Coordinate.Longitude.ToString("0.00000000"));
if (MCSManager.Instance.userDetails != null && MCSManager.Instance.userDetails.LOC_TRACK_ENABLED.Equals("1") && userSettings.Values.ContainsKey(Constants.USER_ID))
{
DatabaseManager dbManager = new DatabaseManager();
Location_Tracking location_tracking = WebserviceED.StoreLocationData(args.Position.Coordinate.Latitude.ToString(),
args.Position.Coordinate.Longitude.ToString(), WebserviceED.getTimestamp(), args.Position.Coordinate.Accuracy.ToString());
var insertSuccessfull = dbManager.insertSingleRecord(location_tracking);
}
}
in these, I only get location details when the app is in the foreground or minimized. If I kill the app, it doesn't give me location details. Also, please help me how to used this in Background Tasks and how to fire a time trigger to send data to a server even if user kills the app?
Also, can we use more than one Background Tasks? I want to use one for TimeTrigger to send data to a server and another one for Push Notification purpose.