Skip to content

Commit

Permalink
Merge pull request #1940 from OneSignal/fix/catch_exception_for_locat…
Browse files Browse the repository at this point in the history
…ion_lib

Fix: Catch IllegalStateException on call to Google's location library
  • Loading branch information
jennantilla authored and jinliu9508 committed Jan 31, 2024
2 parents 3b9e763 + 2a724bd commit d4b090b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,11 @@ internal class GmsLocationController(
googleApiClient: GoogleApiClient,
locationListener: LocationListener,
) {
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, locationListener)
if (googleApiClient.isConnected) {
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, locationListener)
} else {
Logging.warn("GoogleApiClient is not connected. Unable to cancel location updates.")
}
}

fun requestLocationUpdates(
Expand Down

0 comments on commit d4b090b

Please sign in to comment.