diff --git a/README.md b/README.md index 63587c0..886c1a1 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,91 @@ Location Service Manager for Kotlin Multiplatform Mobile iOS and android - Dramatically reduce code to write - Common interface available on KMM Shared -## Requirements +## Usage + +### Register handlers for permissions + +- Android + + ```kotlin + ABCLocation + .onPermissionUpdated(this) { isGranted -> + println("onPermissionUpdated -> isGranted: $isGranted") + } + .onLocationUnavailable(this) { + println("onLocationUnavailable") + } + ``` + - iOS - - Deployment Target 10.0 or higher + + ```swift + ABCLocation.Companion() + .onPermissionUpdated(target: self) { isGranted -> + print("onPermissionUpdated -> isGranted: \(isGranted)") + } + .onLocationUnavailable(target: self) { + print("onLocationUnavailable") + } + .onAlwaysAllowsPermissionRequired(target: self) { + print("onAlwaysAllowsPermissionRequired") + } + ``` + +### To get current location just once + - Android - - minSdkVersion 21 + + ```kotlin + ABCLocation.currentLocation { data -> + println("currentLocation -> data: $data") + } + ``` + +- iOS + + ```swift + ABCLocation.Companion().currentLocation { data in + print("currentLocation -> data: \(data)") + } + ``` + +### To get current location whenever location changes + +- Android + + ```kotlin + ABCLocation + .onLocationUpdated(this) { data -> + println("onLocationUpdated -> data: $data") + } + .startLocationUpdating() + ``` + +- iOS + + ```swift + ABCLocation.Companion() + .onLocationUpdated(target: self) { data in + print("onLocationUpdated -> data: \(data)") + } + .startLocationUpdating() + ``` + +### To stop location updating + +- Android + + ```kotlin + ABCLocation.stopLocationUpdating() + ``` + +- iOS + + ```swift + ABCLocation.Companion().stopLocationUpdating() + ``` + ## Installation @@ -102,87 +182,9 @@ end ``` 2. Run command `pod install` on the terminal -## Usage - -### Register handlers for permissions - -- Android - - ```kotlin - ABCLocation - .onPermissionUpdated(this) { isGranted -> - println("onPermissionUpdated -> isGranted: $isGranted") - } - .onLocationUnavailable(this) { - println("onLocationUnavailable") - } - ``` - -- iOS - - ```swift - ABCLocation.Companion() - .onPermissionUpdated(target: self) { isGranted -> - print("onPermissionUpdated -> isGranted: \(isGranted)") - } - .onLocationUnavailable(target: self) { - print("onLocationUnavailable") - } - .onAlwaysAllowsPermissionRequired(target: self) { - print("onAlwaysAllowsPermissionRequired") - } - ``` - -### To get current location just once - -- Android - - ```kotlin - ABCLocation.currentLocation { data -> - println("currentLocation -> data: $data") - } - ``` - -- iOS - - ```swift - ABCLocation.Companion().currentLocation { data in - print("currentLocation -> data: \(data)") - } - ``` - -### To get current location whenever location changes - -- Android - - ```kotlin - ABCLocation - .onLocationUpdated(this) { data -> - println("onLocationUpdated -> data: $data") - } - .startLocationUpdating() - ``` +## Requirements - iOS - - ```swift - ABCLocation.Companion() - .onLocationUpdated(target: self) { data in - print("onLocationUpdated -> data: \(data)") - } - .startLocationUpdating() - ``` - -### To stop location updating - + - Deployment Target 10.0 or higher - Android - - ```kotlin - ABCLocation.stopLocationUpdating() - ``` - -- iOS - - ```swift - ABCLocation.Companion().stopLocationUpdating() - ``` + - minSdkVersion 21