Skip to content

Commit 85689d8

Browse files
committed
Update cancelLocationUpdates to check for googleApiClient connection instead of try/catch
1 parent ebc7ea2 commit 85689d8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

OneSignalSDK/onesignal/location/src/main/java/com/onesignal/location/internal/controller/impl/GmsLocationController.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ internal class GmsLocationController(
231231
googleApiClient: GoogleApiClient,
232232
locationListener: LocationListener,
233233
) {
234-
try {
234+
if (googleApiClient.isConnected) {
235235
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, locationListener)
236-
} catch (e: IllegalStateException) {
237-
Logging.warn("Caught IllegalStateException in cancelLocationUpdates", e)
236+
} else {
237+
Logging.warn("GoogleApiClient is not connected. Unable to cancel location updates.")
238238
}
239239
}
240240

0 commit comments

Comments
 (0)