Book Image

iOS Development with Xamarin Cookbook

By : Dimitrios Tavlikos (USD)
Book Image

iOS Development with Xamarin Cookbook

By: Dimitrios Tavlikos (USD)

Overview of this book

Table of Contents (22 chapters)
iOS Development with Xamarin Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using a significant-change location service


In this chapter, we will learn how to use the significant location change monitoring feature.

Getting ready

Create a new Single View Application in Xamarin Studio and name it SLCApp. Add a label and two buttons on the view of the controller.

How to do it...

Perform the following steps:

  1. Add the following ViewDidLoad method in the SLCAppViewController class:

    private CLLocationManager locationManager;
    public override void ViewDidLoad ()
    {
      base.ViewDidLoad ();
      
      // Perform any additional setup after loading the view, typically from a nib.
      this.locationManager = new CLLocationManager();
      this.locationManager.LocationsUpdated += LocationManager_LocationsUpdated;
      this.btnStart.TouchUpInside += (s, e) => {
        this.lblOutput.Text = "Starting monitoring significant location changes...";
        this.locationManager.StartMonitoringSignificantLocationChanges();
      } ;
      this.btnStop.TouchUpInside += (s, e) => {
        this.locationManager.StopMonitoringSignificantLocationChanges...