react-native-nitro-geolocation 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/GetCurrentPosition.kt +4 -4
  2. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocation.kt +642 -50
  3. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocationCompat.kt +81 -0
  4. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/WatchPosition.kt +4 -4
  5. package/ios/LocationManager.swift +113 -128
  6. package/ios/NitroGeolocation.swift +546 -61
  7. package/ios/NitroGeolocationCompat.swift +109 -0
  8. package/nitrogen/generated/android/c++/JAuthorizationLevel.hpp +61 -0
  9. package/nitrogen/generated/android/c++/JAuthorizationLevelInternal.hpp +3 -4
  10. package/nitrogen/generated/android/c++/JFunc_void.hpp +2 -1
  11. package/nitrogen/generated/android/c++/JFunc_void_GeolocationError.hpp +2 -1
  12. package/nitrogen/generated/android/c++/JFunc_void_GeolocationResponse.hpp +6 -1
  13. package/nitrogen/generated/android/c++/JFunc_void_LocationError.hpp +78 -0
  14. package/nitrogen/generated/android/c++/JGeolocationCoordinates.hpp +25 -17
  15. package/nitrogen/generated/android/c++/JGeolocationError.hpp +5 -1
  16. package/nitrogen/generated/android/c++/JGeolocationOptions.hpp +5 -1
  17. package/nitrogen/generated/android/c++/JGeolocationResponse.hpp +9 -1
  18. package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.cpp +109 -0
  19. package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.hpp +70 -0
  20. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp +98 -42
  21. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.hpp +7 -5
  22. package/nitrogen/generated/android/c++/JLocationError.hpp +61 -0
  23. package/nitrogen/generated/android/c++/JLocationProvider.hpp +61 -0
  24. package/nitrogen/generated/android/c++/JLocationProviderInternal.hpp +3 -4
  25. package/nitrogen/generated/android/c++/JLocationRequestOptions.hpp +81 -0
  26. package/nitrogen/generated/android/c++/JModernGeolocationConfiguration.hpp +73 -0
  27. package/nitrogen/generated/android/c++/JNullableDouble.cpp +26 -0
  28. package/nitrogen/generated/android/c++/JNullableDouble.hpp +69 -0
  29. package/nitrogen/generated/android/c++/JPermissionStatus.hpp +64 -0
  30. package/nitrogen/generated/android/c++/JRNConfigurationInternal.hpp +5 -1
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevel.kt +24 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevelInternal.kt +2 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void.kt +0 -1
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationError.kt +0 -1
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationResponse.kt +0 -1
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_LocationError.kt +80 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationCoordinates.kt +34 -25
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationError.kt +27 -18
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationOptions.kt +33 -24
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationResponse.kt +18 -9
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationCompatSpec.kt +92 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationSpec.kt +17 -17
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationError.kt +41 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProvider.kt +24 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderInternal.kt +2 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationRequestOptions.kt +56 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/ModernGeolocationConfiguration.kt +47 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/NullableDouble.kt +59 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/PermissionStatus.kt +25 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/RNConfigurationInternal.kt +24 -15
  51. package/nitrogen/generated/android/nitrogeolocation+autolinking.cmake +3 -0
  52. package/nitrogen/generated/android/nitrogeolocationOnLoad.cpp +14 -2
  53. package/nitrogen/generated/ios/NitroGeolocation+autolinking.rb +1 -1
  54. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.cpp +55 -13
  55. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp +325 -68
  56. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Umbrella.hpp +26 -0
  57. package/nitrogen/generated/ios/NitroGeolocationAutolinking.mm +8 -0
  58. package/nitrogen/generated/ios/NitroGeolocationAutolinking.swift +15 -0
  59. package/nitrogen/generated/ios/c++/HybridNitroGeolocationCompatSpecSwift.cpp +11 -0
  60. package/nitrogen/generated/ios/c++/HybridNitroGeolocationCompatSpecSwift.hpp +130 -0
  61. package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.hpp +47 -26
  62. package/nitrogen/generated/ios/swift/AuthorizationLevel.swift +44 -0
  63. package/nitrogen/generated/ios/swift/Func_void.swift +1 -1
  64. package/nitrogen/generated/ios/swift/Func_void_GeolocationError.swift +1 -1
  65. package/nitrogen/generated/ios/swift/Func_void_GeolocationResponse.swift +1 -1
  66. package/nitrogen/generated/ios/swift/Func_void_LocationError.swift +47 -0
  67. package/nitrogen/generated/ios/swift/Func_void_PermissionStatus.swift +47 -0
  68. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
  69. package/nitrogen/generated/ios/swift/GeolocationCoordinates.swift +132 -93
  70. package/nitrogen/generated/ios/swift/GeolocationError.swift +11 -40
  71. package/nitrogen/generated/ios/swift/GeolocationOptions.swift +29 -98
  72. package/nitrogen/generated/ios/swift/GeolocationResponse.swift +5 -16
  73. package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec.swift +61 -0
  74. package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec_cxx.swift +244 -0
  75. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec.swift +13 -5
  76. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec_cxx.swift +66 -64
  77. package/nitrogen/generated/ios/swift/LocationError.swift +35 -0
  78. package/nitrogen/generated/ios/swift/LocationProvider.swift +44 -0
  79. package/nitrogen/generated/ios/swift/LocationRequestOptions.swift +116 -0
  80. package/nitrogen/generated/ios/swift/ModernGeolocationConfiguration.swift +83 -0
  81. package/nitrogen/generated/ios/swift/NullableDouble.swift +18 -0
  82. package/nitrogen/generated/ios/swift/PermissionStatus.swift +48 -0
  83. package/nitrogen/generated/ios/swift/RNConfigurationInternal.swift +16 -50
  84. package/nitrogen/generated/shared/c++/AuthorizationLevel.hpp +80 -0
  85. package/nitrogen/generated/shared/c++/GeolocationCoordinates.hpp +45 -27
  86. package/nitrogen/generated/shared/c++/GeolocationError.hpp +32 -16
  87. package/nitrogen/generated/shared/c++/GeolocationOptions.hpp +38 -22
  88. package/nitrogen/generated/shared/c++/GeolocationResponse.hpp +23 -7
  89. package/nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.cpp +26 -0
  90. package/nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.hpp +79 -0
  91. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp +4 -3
  92. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.hpp +22 -16
  93. package/nitrogen/generated/shared/c++/LocationError.hpp +87 -0
  94. package/nitrogen/generated/shared/c++/LocationProvider.hpp +80 -0
  95. package/nitrogen/generated/shared/c++/LocationRequestOptions.hpp +107 -0
  96. package/nitrogen/generated/shared/c++/ModernGeolocationConfiguration.hpp +100 -0
  97. package/nitrogen/generated/shared/c++/PermissionStatus.hpp +84 -0
  98. package/nitrogen/generated/shared/c++/RNConfigurationInternal.hpp +29 -13
  99. package/package.json +16 -7
  100. package/src/GeolocationClient.ts +116 -0
  101. package/src/NitroGeolocation.nitro.ts +177 -30
  102. package/src/NitroGeolocationCompat.nitro.ts +41 -0
  103. package/src/NitroGeolocationModule.ts +6 -0
  104. package/src/compat/clearWatch.ts +9 -0
  105. package/src/{getCurrentPosition.ts → compat/getCurrentPosition.ts} +7 -3
  106. package/src/compat/index.tsx +34 -0
  107. package/src/compat/requestAuthorization.ts +9 -0
  108. package/src/{setRNConfiguration.ts → compat/setRNConfiguration.ts} +6 -4
  109. package/src/{stopObserving.ts → compat/stopObserving.ts} +4 -2
  110. package/src/{watchPosition.ts → compat/watchPosition.ts} +7 -6
  111. package/src/components/GeolocationProvider.tsx +91 -0
  112. package/src/components/index.ts +13 -0
  113. package/src/hooks/index.ts +9 -0
  114. package/src/hooks/useCheckPermission.ts +46 -0
  115. package/src/hooks/useGetCurrentPosition.ts +44 -0
  116. package/src/hooks/useRequestPermission.ts +38 -0
  117. package/src/hooks/useWatchPosition.ts +127 -0
  118. package/src/index.tsx +72 -27
  119. package/src/types.ts +32 -4
  120. package/src/utils/cache.ts +25 -0
  121. package/src/utils/config.ts +93 -0
  122. package/src/utils/errors.ts +82 -0
  123. package/src/utils/index.ts +27 -0
  124. package/src/utils/provider.ts +61 -0
  125. package/src/utils/quality.ts +98 -0
  126. package/README.md +0 -318
  127. package/src/clearWatch.ts +0 -13
  128. package/src/requestAuthorization.ts +0 -9
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// JPermissionStatus.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "PermissionStatus.hpp"
12
+
13
+ namespace margelo::nitro::nitrogeolocation {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "PermissionStatus" and the the Kotlin enum "PermissionStatus".
19
+ */
20
+ struct JPermissionStatus final: public jni::JavaClass<JPermissionStatus> {
21
+ public:
22
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/PermissionStatus;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum PermissionStatus.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ PermissionStatus toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<PermissionStatus>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JPermissionStatus> fromCpp(PermissionStatus value) {
43
+ static const auto clazz = javaClassStatic();
44
+ switch (value) {
45
+ case PermissionStatus::GRANTED:
46
+ static const auto fieldGRANTED = clazz->getStaticField<JPermissionStatus>("GRANTED");
47
+ return clazz->getStaticFieldValue(fieldGRANTED);
48
+ case PermissionStatus::DENIED:
49
+ static const auto fieldDENIED = clazz->getStaticField<JPermissionStatus>("DENIED");
50
+ return clazz->getStaticFieldValue(fieldDENIED);
51
+ case PermissionStatus::RESTRICTED:
52
+ static const auto fieldRESTRICTED = clazz->getStaticField<JPermissionStatus>("RESTRICTED");
53
+ return clazz->getStaticFieldValue(fieldRESTRICTED);
54
+ case PermissionStatus::UNDETERMINED:
55
+ static const auto fieldUNDETERMINED = clazz->getStaticField<JPermissionStatus>("UNDETERMINED");
56
+ return clazz->getStaticFieldValue(fieldUNDETERMINED);
57
+ default:
58
+ std::string stringValue = std::to_string(static_cast<int>(value));
59
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
60
+ }
61
+ }
62
+ };
63
+
64
+ } // namespace margelo::nitro::nitrogeolocation
@@ -57,7 +57,11 @@ namespace margelo::nitro::nitrogeolocation {
57
57
  */
58
58
  [[maybe_unused]]
59
59
  static jni::local_ref<JRNConfigurationInternal::javaobject> fromCpp(const RNConfigurationInternal& value) {
60
- return newInstance(
60
+ using JSignature = JRNConfigurationInternal(jboolean, jni::alias_ref<JAuthorizationLevelInternal>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JLocationProviderInternal>);
61
+ static const auto clazz = javaClassStatic();
62
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
63
+ return create(
64
+ clazz,
61
65
  value.skipPermissionRequests,
62
66
  value.authorizationLevel.has_value() ? JAuthorizationLevelInternal::fromCpp(value.authorizationLevel.value()) : nullptr,
63
67
  value.enableBackgroundLocationUpdates.has_value() ? jni::JBoolean::valueOf(value.enableBackgroundLocationUpdates.value()) : nullptr,
@@ -0,0 +1,24 @@
1
+ ///
2
+ /// AuthorizationLevel.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitrogeolocation
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "AuthorizationLevel".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class AuthorizationLevel(@DoNotStrip @Keep val value: Int) {
19
+ ALWAYS(0),
20
+ WHENINUSE(1),
21
+ AUTO(2);
22
+
23
+ companion object
24
+ }
@@ -19,4 +19,6 @@ enum class AuthorizationLevelInternal(@DoNotStrip @Keep val value: Int) {
19
19
  ALWAYS(0),
20
20
  WHENINUSE(1),
21
21
  AUTO(2);
22
+
23
+ companion object
22
24
  }
@@ -10,7 +10,6 @@ package com.margelo.nitro.nitrogeolocation
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import com.margelo.nitro.core.*
14
13
  import dalvik.annotation.optimization.FastNative
15
14
 
16
15
 
@@ -10,7 +10,6 @@ package com.margelo.nitro.nitrogeolocation
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import com.margelo.nitro.core.*
14
13
  import dalvik.annotation.optimization.FastNative
15
14
 
16
15
 
@@ -10,7 +10,6 @@ package com.margelo.nitro.nitrogeolocation
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import com.margelo.nitro.core.*
14
13
  import dalvik.annotation.optimization.FastNative
15
14
 
16
15
 
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// Func_void_LocationError.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitrogeolocation
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import dalvik.annotation.optimization.FastNative
14
+
15
+
16
+ /**
17
+ * Represents the JavaScript callback `(error: struct) => void`.
18
+ * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19
+ * or in Kotlin/Java (in which case it is a native callback).
20
+ */
21
+ @DoNotStrip
22
+ @Keep
23
+ @Suppress("ClassName", "RedundantUnitReturnType")
24
+ fun interface Func_void_LocationError: (LocationError) -> Unit {
25
+ /**
26
+ * Call the given JS callback.
27
+ * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28
+ */
29
+ @DoNotStrip
30
+ @Keep
31
+ override fun invoke(error: LocationError): Unit
32
+ }
33
+
34
+ /**
35
+ * Represents the JavaScript callback `(error: struct) => void`.
36
+ * This is implemented in C++, via a `std::function<...>`.
37
+ * The callback might be coming from JS.
38
+ */
39
+ @DoNotStrip
40
+ @Keep
41
+ @Suppress(
42
+ "KotlinJniMissingFunction", "unused",
43
+ "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44
+ "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45
+ )
46
+ class Func_void_LocationError_cxx: Func_void_LocationError {
47
+ @DoNotStrip
48
+ @Keep
49
+ private val mHybridData: HybridData
50
+
51
+ @DoNotStrip
52
+ @Keep
53
+ private constructor(hybridData: HybridData) {
54
+ mHybridData = hybridData
55
+ }
56
+
57
+ @DoNotStrip
58
+ @Keep
59
+ override fun invoke(error: LocationError): Unit
60
+ = invoke_cxx(error)
61
+
62
+ @FastNative
63
+ private external fun invoke_cxx(error: LocationError): Unit
64
+ }
65
+
66
+ /**
67
+ * Represents the JavaScript callback `(error: struct) => void`.
68
+ * This is implemented in Java/Kotlin, via a `(LocationError) -> Unit`.
69
+ * The callback is always coming from native.
70
+ */
71
+ @DoNotStrip
72
+ @Keep
73
+ @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74
+ class Func_void_LocationError_java(private val function: (LocationError) -> Unit): Func_void_LocationError {
75
+ @DoNotStrip
76
+ @Keep
77
+ override fun invoke(error: LocationError): Unit {
78
+ return this.function(error)
79
+ }
80
+ }
@@ -9,39 +9,48 @@ package com.margelo.nitro.nitrogeolocation
9
9
 
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.proguard.annotations.DoNotStrip
12
- import com.margelo.nitro.core.*
13
-
12
+ import com.margelo.nitro.core.NullType
14
13
 
15
14
  /**
16
15
  * Represents the JavaScript object/struct "GeolocationCoordinates".
17
16
  */
18
17
  @DoNotStrip
19
18
  @Keep
20
- data class GeolocationCoordinates
19
+ data class GeolocationCoordinates(
21
20
  @DoNotStrip
22
21
  @Keep
23
- constructor(
24
- @DoNotStrip
25
- @Keep
26
- val latitude: Double,
27
- @DoNotStrip
28
- @Keep
29
- val longitude: Double,
30
- @DoNotStrip
31
- @Keep
32
- val altitude: Double?,
33
- @DoNotStrip
34
- @Keep
35
- val accuracy: Double,
36
- @DoNotStrip
37
- @Keep
38
- val altitudeAccuracy: Double?,
39
- @DoNotStrip
40
- @Keep
41
- val heading: Double?,
22
+ val latitude: Double,
23
+ @DoNotStrip
24
+ @Keep
25
+ val longitude: Double,
26
+ @DoNotStrip
27
+ @Keep
28
+ val altitude: NullableDouble?,
29
+ @DoNotStrip
30
+ @Keep
31
+ val accuracy: Double,
32
+ @DoNotStrip
33
+ @Keep
34
+ val altitudeAccuracy: NullableDouble?,
35
+ @DoNotStrip
36
+ @Keep
37
+ val heading: NullableDouble?,
38
+ @DoNotStrip
39
+ @Keep
40
+ val speed: NullableDouble?
41
+ ) {
42
+ /* primary constructor */
43
+
44
+ companion object {
45
+ /**
46
+ * Constructor called from C++
47
+ */
42
48
  @DoNotStrip
43
49
  @Keep
44
- val speed: Double?
45
- ) {
46
- /* main constructor */
50
+ @Suppress("unused")
51
+ @JvmStatic
52
+ private fun fromCpp(latitude: Double, longitude: Double, altitude: NullableDouble?, accuracy: Double, altitudeAccuracy: NullableDouble?, heading: NullableDouble?, speed: NullableDouble?): GeolocationCoordinates {
53
+ return GeolocationCoordinates(latitude, longitude, altitude, accuracy, altitudeAccuracy, heading, speed)
54
+ }
55
+ }
47
56
  }
@@ -9,7 +9,6 @@ package com.margelo.nitro.nitrogeolocation
9
9
 
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.proguard.annotations.DoNotStrip
12
- import com.margelo.nitro.core.*
13
12
 
14
13
 
15
14
  /**
@@ -17,25 +16,35 @@ import com.margelo.nitro.core.*
17
16
  */
18
17
  @DoNotStrip
19
18
  @Keep
20
- data class GeolocationError
19
+ data class GeolocationError(
21
20
  @DoNotStrip
22
21
  @Keep
23
- constructor(
24
- @DoNotStrip
25
- @Keep
26
- val code: Double,
27
- @DoNotStrip
28
- @Keep
29
- val message: String,
30
- @DoNotStrip
31
- @Keep
32
- val PERMISSION_DENIED: Double,
33
- @DoNotStrip
34
- @Keep
35
- val POSITION_UNAVAILABLE: Double,
22
+ val code: Double,
23
+ @DoNotStrip
24
+ @Keep
25
+ val message: String,
26
+ @DoNotStrip
27
+ @Keep
28
+ val PERMISSION_DENIED: Double,
29
+ @DoNotStrip
30
+ @Keep
31
+ val POSITION_UNAVAILABLE: Double,
32
+ @DoNotStrip
33
+ @Keep
34
+ val TIMEOUT: Double
35
+ ) {
36
+ /* primary constructor */
37
+
38
+ companion object {
39
+ /**
40
+ * Constructor called from C++
41
+ */
36
42
  @DoNotStrip
37
43
  @Keep
38
- val TIMEOUT: Double
39
- ) {
40
- /* main constructor */
44
+ @Suppress("unused")
45
+ @JvmStatic
46
+ private fun fromCpp(code: Double, message: String, PERMISSION_DENIED: Double, POSITION_UNAVAILABLE: Double, TIMEOUT: Double): GeolocationError {
47
+ return GeolocationError(code, message, PERMISSION_DENIED, POSITION_UNAVAILABLE, TIMEOUT)
48
+ }
49
+ }
41
50
  }
@@ -9,7 +9,6 @@ package com.margelo.nitro.nitrogeolocation
9
9
 
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.proguard.annotations.DoNotStrip
12
- import com.margelo.nitro.core.*
13
12
 
14
13
 
15
14
  /**
@@ -17,31 +16,41 @@ import com.margelo.nitro.core.*
17
16
  */
18
17
  @DoNotStrip
19
18
  @Keep
20
- data class GeolocationOptions
19
+ data class GeolocationOptions(
21
20
  @DoNotStrip
22
21
  @Keep
23
- constructor(
24
- @DoNotStrip
25
- @Keep
26
- val timeout: Double?,
27
- @DoNotStrip
28
- @Keep
29
- val maximumAge: Double?,
30
- @DoNotStrip
31
- @Keep
32
- val enableHighAccuracy: Boolean?,
33
- @DoNotStrip
34
- @Keep
35
- val interval: Double?,
36
- @DoNotStrip
37
- @Keep
38
- val fastestInterval: Double?,
39
- @DoNotStrip
40
- @Keep
41
- val distanceFilter: Double?,
22
+ val timeout: Double?,
23
+ @DoNotStrip
24
+ @Keep
25
+ val maximumAge: Double?,
26
+ @DoNotStrip
27
+ @Keep
28
+ val enableHighAccuracy: Boolean?,
29
+ @DoNotStrip
30
+ @Keep
31
+ val interval: Double?,
32
+ @DoNotStrip
33
+ @Keep
34
+ val fastestInterval: Double?,
35
+ @DoNotStrip
36
+ @Keep
37
+ val distanceFilter: Double?,
38
+ @DoNotStrip
39
+ @Keep
40
+ val useSignificantChanges: Boolean?
41
+ ) {
42
+ /* primary constructor */
43
+
44
+ companion object {
45
+ /**
46
+ * Constructor called from C++
47
+ */
42
48
  @DoNotStrip
43
49
  @Keep
44
- val useSignificantChanges: Boolean?
45
- ) {
46
- /* main constructor */
50
+ @Suppress("unused")
51
+ @JvmStatic
52
+ private fun fromCpp(timeout: Double?, maximumAge: Double?, enableHighAccuracy: Boolean?, interval: Double?, fastestInterval: Double?, distanceFilter: Double?, useSignificantChanges: Boolean?): GeolocationOptions {
53
+ return GeolocationOptions(timeout, maximumAge, enableHighAccuracy, interval, fastestInterval, distanceFilter, useSignificantChanges)
54
+ }
55
+ }
47
56
  }
@@ -9,7 +9,6 @@ package com.margelo.nitro.nitrogeolocation
9
9
 
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.proguard.annotations.DoNotStrip
12
- import com.margelo.nitro.core.*
13
12
 
14
13
 
15
14
  /**
@@ -17,16 +16,26 @@ import com.margelo.nitro.core.*
17
16
  */
18
17
  @DoNotStrip
19
18
  @Keep
20
- data class GeolocationResponse
19
+ data class GeolocationResponse(
21
20
  @DoNotStrip
22
21
  @Keep
23
- constructor(
24
- @DoNotStrip
25
- @Keep
26
- val coords: GeolocationCoordinates,
22
+ val coords: GeolocationCoordinates,
23
+ @DoNotStrip
24
+ @Keep
25
+ val timestamp: Double
26
+ ) {
27
+ /* primary constructor */
28
+
29
+ companion object {
30
+ /**
31
+ * Constructor called from C++
32
+ */
27
33
  @DoNotStrip
28
34
  @Keep
29
- val timestamp: Double
30
- ) {
31
- /* main constructor */
35
+ @Suppress("unused")
36
+ @JvmStatic
37
+ private fun fromCpp(coords: GeolocationCoordinates, timestamp: Double): GeolocationResponse {
38
+ return GeolocationResponse(coords, timestamp)
39
+ }
40
+ }
32
41
  }
@@ -0,0 +1,92 @@
1
+ ///
2
+ /// HybridNitroGeolocationCompatSpec.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitrogeolocation
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import com.margelo.nitro.core.HybridObject
14
+
15
+ /**
16
+ * A Kotlin class representing the NitroGeolocationCompat HybridObject.
17
+ * Implement this abstract class to create Kotlin-based instances of NitroGeolocationCompat.
18
+ */
19
+ @DoNotStrip
20
+ @Keep
21
+ @Suppress(
22
+ "KotlinJniMissingFunction", "unused",
23
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25
+ )
26
+ abstract class HybridNitroGeolocationCompatSpec: HybridObject() {
27
+ @DoNotStrip
28
+ private var mHybridData: HybridData = initHybrid()
29
+
30
+ init {
31
+ super.updateNative(mHybridData)
32
+ }
33
+
34
+ override fun updateNative(hybridData: HybridData) {
35
+ mHybridData = hybridData
36
+ super.updateNative(hybridData)
37
+ }
38
+
39
+ // Default implementation of `HybridObject.toString()`
40
+ override fun toString(): String {
41
+ return "[HybridObject NitroGeolocationCompat]"
42
+ }
43
+
44
+ // Properties
45
+
46
+
47
+ // Methods
48
+ @DoNotStrip
49
+ @Keep
50
+ abstract fun setRNConfiguration(config: RNConfigurationInternal): Unit
51
+
52
+ abstract fun requestAuthorization(success: (() -> Unit)?, error: ((error: GeolocationError) -> Unit)?): Unit
53
+
54
+ @DoNotStrip
55
+ @Keep
56
+ private fun requestAuthorization_cxx(success: Func_void?, error: Func_void_GeolocationError?): Unit {
57
+ val __result = requestAuthorization(success?.let { it }, error?.let { it })
58
+ return __result
59
+ }
60
+
61
+ abstract fun getCurrentPosition(success: (position: GeolocationResponse) -> Unit, error: ((error: GeolocationError) -> Unit)?, options: GeolocationOptions?): Unit
62
+
63
+ @DoNotStrip
64
+ @Keep
65
+ private fun getCurrentPosition_cxx(success: Func_void_GeolocationResponse, error: Func_void_GeolocationError?, options: GeolocationOptions?): Unit {
66
+ val __result = getCurrentPosition(success, error?.let { it }, options)
67
+ return __result
68
+ }
69
+
70
+ abstract fun watchPosition(success: (position: GeolocationResponse) -> Unit, error: ((error: GeolocationError) -> Unit)?, options: GeolocationOptions?): Double
71
+
72
+ @DoNotStrip
73
+ @Keep
74
+ private fun watchPosition_cxx(success: Func_void_GeolocationResponse, error: Func_void_GeolocationError?, options: GeolocationOptions?): Double {
75
+ val __result = watchPosition(success, error?.let { it }, options)
76
+ return __result
77
+ }
78
+
79
+ @DoNotStrip
80
+ @Keep
81
+ abstract fun clearWatch(watchId: Double): Unit
82
+
83
+ @DoNotStrip
84
+ @Keep
85
+ abstract fun stopObserving(): Unit
86
+
87
+ private external fun initHybrid(): HybridData
88
+
89
+ companion object {
90
+ protected const val TAG = "HybridNitroGeolocationCompatSpec"
91
+ }
92
+ }
@@ -10,7 +10,8 @@ package com.margelo.nitro.nitrogeolocation
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import com.margelo.nitro.core.*
13
+ import com.margelo.nitro.core.Promise
14
+ import com.margelo.nitro.core.HybridObject
14
15
 
15
16
  /**
16
17
  * A Kotlin class representing the NitroGeolocation HybridObject.
@@ -36,44 +37,43 @@ abstract class HybridNitroGeolocationSpec: HybridObject() {
36
37
  super.updateNative(hybridData)
37
38
  }
38
39
 
40
+ // Default implementation of `HybridObject.toString()`
41
+ override fun toString(): String {
42
+ return "[HybridObject NitroGeolocation]"
43
+ }
44
+
39
45
  // Properties
40
46
 
41
47
 
42
48
  // Methods
43
49
  @DoNotStrip
44
50
  @Keep
45
- abstract fun setRNConfiguration(config: RNConfigurationInternal): Unit
46
-
47
- abstract fun requestAuthorization(success: (() -> Unit)?, error: ((error: GeolocationError) -> Unit)?): Unit
51
+ abstract fun setConfiguration(config: ModernGeolocationConfiguration): Unit
48
52
 
49
53
  @DoNotStrip
50
54
  @Keep
51
- private fun requestAuthorization_cxx(success: Func_void?, error: Func_void_GeolocationError?): Unit {
52
- val __result = requestAuthorization(success?.let { it }, error?.let { it })
53
- return __result
54
- }
55
+ abstract fun checkPermission(): Promise<PermissionStatus>
55
56
 
56
- abstract fun getCurrentPosition(success: (position: GeolocationResponse) -> Unit, error: ((error: GeolocationError) -> Unit)?, options: GeolocationOptions?): Unit
57
+ @DoNotStrip
58
+ @Keep
59
+ abstract fun requestPermission(): Promise<PermissionStatus>
57
60
 
58
61
  @DoNotStrip
59
62
  @Keep
60
- private fun getCurrentPosition_cxx(success: Func_void_GeolocationResponse, error: Func_void_GeolocationError?, options: GeolocationOptions?): Unit {
61
- val __result = getCurrentPosition(success, error?.let { it }, options)
62
- return __result
63
- }
63
+ abstract fun getCurrentPosition(options: LocationRequestOptions?): Promise<GeolocationResponse>
64
64
 
65
- abstract fun watchPosition(success: (position: GeolocationResponse) -> Unit, error: ((error: GeolocationError) -> Unit)?, options: GeolocationOptions?): Double
65
+ abstract fun watchPosition(success: (position: GeolocationResponse) -> Unit, error: ((error: LocationError) -> Unit)?, options: LocationRequestOptions?): String
66
66
 
67
67
  @DoNotStrip
68
68
  @Keep
69
- private fun watchPosition_cxx(success: Func_void_GeolocationResponse, error: Func_void_GeolocationError?, options: GeolocationOptions?): Double {
69
+ private fun watchPosition_cxx(success: Func_void_GeolocationResponse, error: Func_void_LocationError?, options: LocationRequestOptions?): String {
70
70
  val __result = watchPosition(success, error?.let { it }, options)
71
71
  return __result
72
72
  }
73
73
 
74
74
  @DoNotStrip
75
75
  @Keep
76
- abstract fun clearWatch(watchId: Double): Unit
76
+ abstract fun unwatch(token: String): Unit
77
77
 
78
78
  @DoNotStrip
79
79
  @Keep
@@ -82,6 +82,6 @@ abstract class HybridNitroGeolocationSpec: HybridObject() {
82
82
  private external fun initHybrid(): HybridData
83
83
 
84
84
  companion object {
85
- private const val TAG = "HybridNitroGeolocationSpec"
85
+ protected const val TAG = "HybridNitroGeolocationSpec"
86
86
  }
87
87
  }
@@ -0,0 +1,41 @@
1
+ ///
2
+ /// LocationError.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.nitrogeolocation
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+
14
+ /**
15
+ * Represents the JavaScript object/struct "LocationError".
16
+ */
17
+ @DoNotStrip
18
+ @Keep
19
+ data class LocationError(
20
+ @DoNotStrip
21
+ @Keep
22
+ val code: Double,
23
+ @DoNotStrip
24
+ @Keep
25
+ val message: String
26
+ ) {
27
+ /* primary constructor */
28
+
29
+ companion object {
30
+ /**
31
+ * Constructor called from C++
32
+ */
33
+ @DoNotStrip
34
+ @Keep
35
+ @Suppress("unused")
36
+ @JvmStatic
37
+ private fun fromCpp(code: Double, message: String): LocationError {
38
+ return LocationError(code, message)
39
+ }
40
+ }
41
+ }