Search code examples
iosgoogle-mapscocoa-touchcore-locationgoogle-maps-sdk-ios

iOS Google Maps SDK - Using location in background


I am utilizing the Google Maps iOS SDK in my app and am utilizing a GMSMapView with myLocationEnabled = TRUE. The user has authorized for location usage in app.

The problem is that when a user opens the screen with the map, then closes the app with that screen visible, the map continues to use the user's location, even if the user only allowed location usage "While Using the App". This is a huge problem as it is a big drain on battery, and have no clue how to fix it.

I am using the latest version of the SDK (1.11.1).

Any ideas?


Solution

  • It might help to stop the location updates:

    [[[CLLocationManager alloc] init] stopUpdatingLocation];
    

    You can restart requesting for updates using this

    [[[CLLocationManager alloc] init] startUpdatingLocation];
    

    Please replace the location manager with your instance if you have already instantiated them.