Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# outsystems-geolocation
# capacitor-geolocation

3 changes: 1 addition & 2 deletions packages/capacitor-plugin/CapacitorGeolocation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ Pod::Spec.new do |s|
s.author = package['author']
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
s.vendored_frameworks = 'ios/Sources/GeolocationPlugin/OSGeolocationLib.xcframework'
s.ios.deployment_target = '14.0'
s.dependency 'Capacitor'
#s.dependency 'OSGeolocationLib'
s.dependency 'IONGeolocationLib', spec='~> 1.0'
s.swift_version = '5.1'
end
2 changes: 1 addition & 1 deletion packages/capacitor-plugin/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ repositories {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation("io.ionic.libs:osgeolocation-android:1.0.0")
implementation("io.ionic.libs:iongeolocation-android:1.0.0")
implementation project(':capacitor-android')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"

Expand Down
3 changes: 0 additions & 3 deletions packages/capacitor-plugin/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
include ':capacitor-android'
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')

include ':osgeolocationlib'
project(':osgeolocationlib').projectDir = new File('../../android-lib')
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package com.capacitorjs.plugins.geolocation
object GeolocationErrors {

private fun formatErrorCode(number: Int): String {
return "OS-PLUG-GLOC-" + number.toString().padStart(4, '0')
return "CAP-PLUGIN-GLOC-" + number.toString().padStart(4, '0')
}

data class ErrorInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import com.getcapacitor.annotation.CapacitorPlugin
import com.getcapacitor.annotation.Permission
import com.getcapacitor.annotation.PermissionCallback
import com.google.android.gms.location.LocationServices
import io.ionic.libs.osgeolocationlib.controller.OSGLOCController
import io.ionic.libs.osgeolocationlib.model.OSGLOCException
import io.ionic.libs.osgeolocationlib.model.OSGLOCLocationOptions
import io.ionic.libs.osgeolocationlib.model.OSGLOCLocationResult
import io.ionic.libs.iongeolocationlib.controller.IONGLOCController
import io.ionic.libs.iongeolocationlib.model.IONGLOCException
import io.ionic.libs.iongeolocationlib.model.IONGLOCLocationOptions
import io.ionic.libs.iongeolocationlib.model.IONGLOCLocationResult
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
Expand All @@ -33,7 +33,7 @@ import kotlinx.coroutines.launch
)
class GeolocationPlugin : Plugin() {

private lateinit var controller: OSGLOCController
private lateinit var controller: IONGLOCController
private lateinit var coroutineScope: CoroutineScope
private val watchingCalls: MutableMap<String, PluginCall> = mutableMapOf()

Expand All @@ -54,7 +54,7 @@ class GeolocationPlugin : Plugin() {
}
}

this.controller = OSGLOCController(
this.controller = IONGLOCController(
LocationServices.getFusedLocationProviderClient(context),
activityLauncher
)
Expand Down Expand Up @@ -246,11 +246,11 @@ class GeolocationPlugin : Plugin() {
}

/**
* Helper function to convert OSGLOCLocationResult object into the format accepted by the Capacitor bridge
* @param locationResult OSGLOCLocationResult object with the location to convert
* Helper function to convert IONGLOCLocationResult object into the format accepted by the Capacitor bridge
* @param locationResult IONGLOCLocationResult object with the location to convert
* @return JSObject with converted JSON object
*/
private fun getJSObjectForLocation(locationResult: OSGLOCLocationResult): JSObject {
private fun getJSObjectForLocation(locationResult: IONGLOCLocationResult): JSObject {
val coords = JSObject().apply {
put("latitude", locationResult.latitude)
put("longitude", locationResult.longitude)
Expand All @@ -273,23 +273,23 @@ class GeolocationPlugin : Plugin() {
*/
private fun onLocationError(exception: Throwable?, call: PluginCall) {
when (exception) {
is OSGLOCException.OSGLOCRequestDeniedException -> {
is IONGLOCException.IONGLOCRequestDeniedException -> {
call.sendError(GeolocationErrors.LOCATION_ENABLE_REQUEST_DENIED)
}
is OSGLOCException.OSGLOCSettingsException -> {
is IONGLOCException.IONGLOCSettingsException -> {
call.sendError(GeolocationErrors.LOCATION_SETTINGS_ERROR)
}
is OSGLOCException.OSGLOCInvalidTimeoutException -> {
is IONGLOCException.IONGLOCInvalidTimeoutException -> {
call.sendError(GeolocationErrors.INVALID_TIMEOUT)
}
is OSGLOCException.OSGLOCGoogleServicesException -> {
is IONGLOCException.IONGLOCGoogleServicesException -> {
if (exception.resolvable) {
call.sendError(GeolocationErrors.GOOGLE_SERVICES_RESOLVABLE)
} else {
call.sendError(GeolocationErrors.GOOGLE_SERVICES_ERROR)
}
}
is OSGLOCException.OSGLOCLocationRetrievalTimeoutException -> {
is IONGLOCException.IONGLOCLocationRetrievalTimeoutException -> {
call.sendError(GeolocationErrors.GET_LOCATION_TIMEOUT)
}
else -> {
Expand Down Expand Up @@ -323,15 +323,15 @@ class GeolocationPlugin : Plugin() {
/**
* Creates the location options to pass to the native controller
* @param call the plugin call
* @return OSGLOCLocationOptions object
* @return IONGLOCLocationOptions object
*/
private fun createOptions(call: PluginCall): OSGLOCLocationOptions {
private fun createOptions(call: PluginCall): IONGLOCLocationOptions {
val timeout = call.getLong("timeout", 10000) ?: 10000
val maximumAge = call.getLong("maximumAge", 0) ?: 0
val enableHighAccuracy = call.getBoolean("enableHighAccuracy", false) ?: false
val minimumUpdateInterval = call.getLong("minimumUpdateInterval", 5000) ?: 5000

val locationOptions = OSGLOCLocationOptions(timeout, maximumAge, enableHighAccuracy, minimumUpdateInterval)
val locationOptions = IONGLOCLocationOptions(timeout, maximumAge, enableHighAccuracy, minimumUpdateInterval)

return locationOptions
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Capacitor
import OSGeolocationLib
import IONGeolocationLib

private enum GeolocationCallbackType {
case location
Expand Down Expand Up @@ -69,7 +69,7 @@ final class GeolocationCallbackManager {
call.resolve(data)
}

func sendSuccess(with position: OSGLOCPositionModel) {
func sendSuccess(with position: IONGLOCPositionModel) {
createPluginResult(status: .success(position.toJSObject()))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
enum OSGeolocationMethod: String {
enum GeolocationMethod: String {
case getCurrentPosition
case watchPosition
case clearWatch
Expand All @@ -9,10 +9,10 @@ enum GeolocationError: Error {
case permissionDenied
case permissionRestricted
case positionUnavailable
case inputArgumentsIssue(target: OSGeolocationMethod)
case inputArgumentsIssue(target: GeolocationMethod)

func toCodeMessagePair() -> (String, String) {
("OS-PLUG-GLOC-\(String(format: "%04d", code))", description)
("CAP-PLUGIN-GLOC-\(String(format: "%04d", code))", description)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Capacitor
import OSGeolocationLib
import IONGeolocationLib

import Combine

Expand All @@ -15,13 +15,13 @@ public class GeolocationPlugin: CAPPlugin, CAPBridgedPlugin {
.init(name: "requestPermissions", returnType: CAPPluginReturnPromise)
]

private var locationService: (any OSGLOCService)?
private var locationService: (any IONGLOCService)?
private var cancellables = Set<AnyCancellable>()
private var callbackManager: GeolocationCallbackManager?
private var isInitialised: Bool = false

public override func load() {
self.locationService = OSGLOCManagerWrapper()
self.locationService = IONGLOCManagerWrapper()
self.callbackManager = .init(capacitorBridge: bridge)
}

Expand Down Expand Up @@ -118,7 +118,7 @@ private extension GeolocationPlugin {
.store(in: &cancellables)
}

func requestLocationAuthorisation(type requestType: OSGLOCAuthorisationRequestType) {
func requestLocationAuthorisation(type requestType: IONGLOCAuthorisationRequestType) {
DispatchQueue.global(qos: .background).async {
self.checkIfLocationServicesAreEnabled()
self.locationService?.requestAuthorisation(withType: requestType)
Expand Down Expand Up @@ -146,7 +146,7 @@ private extension GeolocationPlugin {
}

func handleLocationRequest(_ enableHighAccuracy: Bool, watchUUID: String? = nil, call: CAPPluginCall) {
let configurationModel = OSGLOCConfigurationModel(enableHighAccuracy: enableHighAccuracy)
let configurationModel = IONGLOCConfigurationModel(enableHighAccuracy: enableHighAccuracy)
locationService?.updateConfiguration(configurationModel)

if let watchUUID {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Capacitor
import OSGeolocationLib
import IONGeolocationLib

extension OSGLOCPositionModel {
extension IONGLOCPositionModel {
func toJSObject() -> JSObject {
[
Constants.Position.timestamp: timestamp,
Expand Down

This file was deleted.

Loading