Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pisces authored Nov 18, 2021
1 parent d12146b commit 60bfa06
Showing 1 changed file with 86 additions and 84 deletions.
170 changes: 86 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

0 comments on commit 60bfa06

Please sign in to comment.