react-native-nitro-geolocation 0.0.1 → 0.1.1

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 (79) hide show
  1. package/LICENSE +4 -1
  2. package/README.md +318 -0
  3. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/GetCurrentPosition.kt +341 -0
  4. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocation.kt +76 -5
  5. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/RequestAuthorization.kt +164 -0
  6. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/WatchPosition.kt +228 -0
  7. package/ios/LocationManager.swift +529 -0
  8. package/ios/NitroGeolocation.swift +96 -2
  9. package/nitrogen/generated/.gitattributes +1 -0
  10. package/nitrogen/generated/android/c++/JAuthorizationLevelInternal.hpp +62 -0
  11. package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
  12. package/nitrogen/generated/android/c++/JFunc_void_GeolocationError.hpp +77 -0
  13. package/nitrogen/generated/android/c++/JFunc_void_GeolocationResponse.hpp +79 -0
  14. package/nitrogen/generated/android/c++/JGeolocationCoordinates.hpp +77 -0
  15. package/nitrogen/generated/android/c++/JGeolocationError.hpp +69 -0
  16. package/nitrogen/generated/android/c++/JGeolocationOptions.hpp +77 -0
  17. package/nitrogen/generated/android/c++/JGeolocationResponse.hpp +59 -0
  18. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp +98 -0
  19. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.hpp +69 -0
  20. package/nitrogen/generated/android/c++/JLocationProviderInternal.hpp +62 -0
  21. package/nitrogen/generated/android/c++/JRNConfigurationInternal.hpp +69 -0
  22. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevelInternal.kt +22 -0
  23. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void.kt +81 -0
  24. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationError.kt +81 -0
  25. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationResponse.kt +81 -0
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationCoordinates.kt +47 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationError.kt +41 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationOptions.kt +47 -0
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationResponse.kt +32 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationSpec.kt +87 -0
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderInternal.kt +22 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/RNConfigurationInternal.kt +38 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/nitrogeolocationOnLoad.kt +35 -0
  34. package/nitrogen/generated/android/nitrogeolocation+autolinking.cmake +81 -0
  35. package/nitrogen/generated/android/nitrogeolocation+autolinking.gradle +27 -0
  36. package/nitrogen/generated/android/nitrogeolocationOnLoad.cpp +50 -0
  37. package/nitrogen/generated/android/nitrogeolocationOnLoad.hpp +25 -0
  38. package/nitrogen/generated/ios/NitroGeolocation+autolinking.rb +60 -0
  39. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.cpp +56 -0
  40. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp +252 -0
  41. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Umbrella.hpp +67 -0
  42. package/nitrogen/generated/ios/NitroGeolocationAutolinking.mm +33 -0
  43. package/nitrogen/generated/ios/NitroGeolocationAutolinking.swift +25 -0
  44. package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.cpp +11 -0
  45. package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.hpp +125 -0
  46. package/nitrogen/generated/ios/swift/AuthorizationLevelInternal.swift +44 -0
  47. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  48. package/nitrogen/generated/ios/swift/Func_void_GeolocationError.swift +47 -0
  49. package/nitrogen/generated/ios/swift/Func_void_GeolocationResponse.swift +47 -0
  50. package/nitrogen/generated/ios/swift/GeolocationCoordinates.swift +149 -0
  51. package/nitrogen/generated/ios/swift/GeolocationError.swift +79 -0
  52. package/nitrogen/generated/ios/swift/GeolocationOptions.swift +185 -0
  53. package/nitrogen/generated/ios/swift/GeolocationResponse.swift +46 -0
  54. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec.swift +54 -0
  55. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec_cxx.swift +236 -0
  56. package/nitrogen/generated/ios/swift/LocationProviderInternal.swift +44 -0
  57. package/nitrogen/generated/ios/swift/RNConfigurationInternal.swift +104 -0
  58. package/nitrogen/generated/shared/c++/AuthorizationLevelInternal.hpp +80 -0
  59. package/nitrogen/generated/shared/c++/GeolocationCoordinates.hpp +91 -0
  60. package/nitrogen/generated/shared/c++/GeolocationError.hpp +83 -0
  61. package/nitrogen/generated/shared/c++/GeolocationOptions.hpp +91 -0
  62. package/nitrogen/generated/shared/c++/GeolocationResponse.hpp +72 -0
  63. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp +26 -0
  64. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.hpp +79 -0
  65. package/nitrogen/generated/shared/c++/LocationProviderInternal.hpp +80 -0
  66. package/nitrogen/generated/shared/c++/RNConfigurationInternal.hpp +84 -0
  67. package/package.json +34 -10
  68. package/src/NitroGeolocation.nitro.ts +38 -3
  69. package/src/NitroGeolocationModule.ts +5 -0
  70. package/src/clearWatch.ts +13 -0
  71. package/src/getCurrentPosition.ts +14 -0
  72. package/src/index.tsx +32 -7
  73. package/src/requestAuthorization.ts +9 -0
  74. package/src/setRNConfiguration.ts +22 -0
  75. package/src/stopObserving.ts +12 -0
  76. package/src/types.ts +43 -0
  77. package/src/watchPosition.ts +26 -0
  78. package/nitro.json +0 -17
  79. package/turbo.json +0 -42
@@ -0,0 +1,74 @@
1
+ ///
2
+ /// JFunc_void.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 <functional>
12
+
13
+ #include <functional>
14
+
15
+ namespace margelo::nitro::nitrogeolocation {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * Represents the Java/Kotlin callback `() -> Unit`.
21
+ * This can be passed around between C++ and Java/Kotlin.
22
+ */
23
+ struct JFunc_void: public jni::JavaClass<JFunc_void> {
24
+ public:
25
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/Func_void;";
26
+
27
+ public:
28
+ /**
29
+ * Invokes the function this `JFunc_void` instance holds through JNI.
30
+ */
31
+ void invoke() const {
32
+ static const auto method = javaClassStatic()->getMethod<void()>("invoke");
33
+ method(self());
34
+ }
35
+ };
36
+
37
+ /**
38
+ * An implementation of Func_void that is backed by a C++ implementation (using `std::function<...>`)
39
+ */
40
+ struct JFunc_void_cxx final: public jni::HybridClass<JFunc_void_cxx, JFunc_void> {
41
+ public:
42
+ static jni::local_ref<JFunc_void::javaobject> fromCpp(const std::function<void()>& func) {
43
+ return JFunc_void_cxx::newObjectCxxArgs(func);
44
+ }
45
+
46
+ public:
47
+ /**
48
+ * Invokes the C++ `std::function<...>` this `JFunc_void_cxx` instance holds.
49
+ */
50
+ void invoke_cxx() {
51
+ _func();
52
+ }
53
+
54
+ public:
55
+ [[nodiscard]]
56
+ inline const std::function<void()>& getFunction() const {
57
+ return _func;
58
+ }
59
+
60
+ public:
61
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/Func_void_cxx;";
62
+ static void registerNatives() {
63
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)});
64
+ }
65
+
66
+ private:
67
+ explicit JFunc_void_cxx(const std::function<void()>& func): _func(func) { }
68
+
69
+ private:
70
+ friend HybridBase;
71
+ std::function<void()> _func;
72
+ };
73
+
74
+ } // namespace margelo::nitro::nitrogeolocation
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// JFunc_void_GeolocationError.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 <functional>
12
+
13
+ #include "GeolocationError.hpp"
14
+ #include <functional>
15
+ #include "JGeolocationError.hpp"
16
+ #include <string>
17
+
18
+ namespace margelo::nitro::nitrogeolocation {
19
+
20
+ using namespace facebook;
21
+
22
+ /**
23
+ * Represents the Java/Kotlin callback `(error: GeolocationError) -> Unit`.
24
+ * This can be passed around between C++ and Java/Kotlin.
25
+ */
26
+ struct JFunc_void_GeolocationError: public jni::JavaClass<JFunc_void_GeolocationError> {
27
+ public:
28
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/Func_void_GeolocationError;";
29
+
30
+ public:
31
+ /**
32
+ * Invokes the function this `JFunc_void_GeolocationError` instance holds through JNI.
33
+ */
34
+ void invoke(const GeolocationError& error) const {
35
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JGeolocationError> /* error */)>("invoke");
36
+ method(self(), JGeolocationError::fromCpp(error));
37
+ }
38
+ };
39
+
40
+ /**
41
+ * An implementation of Func_void_GeolocationError that is backed by a C++ implementation (using `std::function<...>`)
42
+ */
43
+ struct JFunc_void_GeolocationError_cxx final: public jni::HybridClass<JFunc_void_GeolocationError_cxx, JFunc_void_GeolocationError> {
44
+ public:
45
+ static jni::local_ref<JFunc_void_GeolocationError::javaobject> fromCpp(const std::function<void(const GeolocationError& /* error */)>& func) {
46
+ return JFunc_void_GeolocationError_cxx::newObjectCxxArgs(func);
47
+ }
48
+
49
+ public:
50
+ /**
51
+ * Invokes the C++ `std::function<...>` this `JFunc_void_GeolocationError_cxx` instance holds.
52
+ */
53
+ void invoke_cxx(jni::alias_ref<JGeolocationError> error) {
54
+ _func(error->toCpp());
55
+ }
56
+
57
+ public:
58
+ [[nodiscard]]
59
+ inline const std::function<void(const GeolocationError& /* error */)>& getFunction() const {
60
+ return _func;
61
+ }
62
+
63
+ public:
64
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/Func_void_GeolocationError_cxx;";
65
+ static void registerNatives() {
66
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_GeolocationError_cxx::invoke_cxx)});
67
+ }
68
+
69
+ private:
70
+ explicit JFunc_void_GeolocationError_cxx(const std::function<void(const GeolocationError& /* error */)>& func): _func(func) { }
71
+
72
+ private:
73
+ friend HybridBase;
74
+ std::function<void(const GeolocationError& /* error */)> _func;
75
+ };
76
+
77
+ } // namespace margelo::nitro::nitrogeolocation
@@ -0,0 +1,79 @@
1
+ ///
2
+ /// JFunc_void_GeolocationResponse.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 <functional>
12
+
13
+ #include "GeolocationResponse.hpp"
14
+ #include <functional>
15
+ #include "JGeolocationResponse.hpp"
16
+ #include "GeolocationCoordinates.hpp"
17
+ #include "JGeolocationCoordinates.hpp"
18
+ #include <optional>
19
+
20
+ namespace margelo::nitro::nitrogeolocation {
21
+
22
+ using namespace facebook;
23
+
24
+ /**
25
+ * Represents the Java/Kotlin callback `(position: GeolocationResponse) -> Unit`.
26
+ * This can be passed around between C++ and Java/Kotlin.
27
+ */
28
+ struct JFunc_void_GeolocationResponse: public jni::JavaClass<JFunc_void_GeolocationResponse> {
29
+ public:
30
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/Func_void_GeolocationResponse;";
31
+
32
+ public:
33
+ /**
34
+ * Invokes the function this `JFunc_void_GeolocationResponse` instance holds through JNI.
35
+ */
36
+ void invoke(const GeolocationResponse& position) const {
37
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JGeolocationResponse> /* position */)>("invoke");
38
+ method(self(), JGeolocationResponse::fromCpp(position));
39
+ }
40
+ };
41
+
42
+ /**
43
+ * An implementation of Func_void_GeolocationResponse that is backed by a C++ implementation (using `std::function<...>`)
44
+ */
45
+ struct JFunc_void_GeolocationResponse_cxx final: public jni::HybridClass<JFunc_void_GeolocationResponse_cxx, JFunc_void_GeolocationResponse> {
46
+ public:
47
+ static jni::local_ref<JFunc_void_GeolocationResponse::javaobject> fromCpp(const std::function<void(const GeolocationResponse& /* position */)>& func) {
48
+ return JFunc_void_GeolocationResponse_cxx::newObjectCxxArgs(func);
49
+ }
50
+
51
+ public:
52
+ /**
53
+ * Invokes the C++ `std::function<...>` this `JFunc_void_GeolocationResponse_cxx` instance holds.
54
+ */
55
+ void invoke_cxx(jni::alias_ref<JGeolocationResponse> position) {
56
+ _func(position->toCpp());
57
+ }
58
+
59
+ public:
60
+ [[nodiscard]]
61
+ inline const std::function<void(const GeolocationResponse& /* position */)>& getFunction() const {
62
+ return _func;
63
+ }
64
+
65
+ public:
66
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/Func_void_GeolocationResponse_cxx;";
67
+ static void registerNatives() {
68
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_GeolocationResponse_cxx::invoke_cxx)});
69
+ }
70
+
71
+ private:
72
+ explicit JFunc_void_GeolocationResponse_cxx(const std::function<void(const GeolocationResponse& /* position */)>& func): _func(func) { }
73
+
74
+ private:
75
+ friend HybridBase;
76
+ std::function<void(const GeolocationResponse& /* position */)> _func;
77
+ };
78
+
79
+ } // namespace margelo::nitro::nitrogeolocation
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// JGeolocationCoordinates.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 "GeolocationCoordinates.hpp"
12
+
13
+ #include <optional>
14
+
15
+ namespace margelo::nitro::nitrogeolocation {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "GeolocationCoordinates" and the the Kotlin data class "GeolocationCoordinates".
21
+ */
22
+ struct JGeolocationCoordinates final: public jni::JavaClass<JGeolocationCoordinates> {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/GeolocationCoordinates;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct GeolocationCoordinates by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ GeolocationCoordinates toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldLatitude = clazz->getField<double>("latitude");
35
+ double latitude = this->getFieldValue(fieldLatitude);
36
+ static const auto fieldLongitude = clazz->getField<double>("longitude");
37
+ double longitude = this->getFieldValue(fieldLongitude);
38
+ static const auto fieldAltitude = clazz->getField<jni::JDouble>("altitude");
39
+ jni::local_ref<jni::JDouble> altitude = this->getFieldValue(fieldAltitude);
40
+ static const auto fieldAccuracy = clazz->getField<double>("accuracy");
41
+ double accuracy = this->getFieldValue(fieldAccuracy);
42
+ static const auto fieldAltitudeAccuracy = clazz->getField<jni::JDouble>("altitudeAccuracy");
43
+ jni::local_ref<jni::JDouble> altitudeAccuracy = this->getFieldValue(fieldAltitudeAccuracy);
44
+ static const auto fieldHeading = clazz->getField<jni::JDouble>("heading");
45
+ jni::local_ref<jni::JDouble> heading = this->getFieldValue(fieldHeading);
46
+ static const auto fieldSpeed = clazz->getField<jni::JDouble>("speed");
47
+ jni::local_ref<jni::JDouble> speed = this->getFieldValue(fieldSpeed);
48
+ return GeolocationCoordinates(
49
+ latitude,
50
+ longitude,
51
+ altitude != nullptr ? std::make_optional(altitude->value()) : std::nullopt,
52
+ accuracy,
53
+ altitudeAccuracy != nullptr ? std::make_optional(altitudeAccuracy->value()) : std::nullopt,
54
+ heading != nullptr ? std::make_optional(heading->value()) : std::nullopt,
55
+ speed != nullptr ? std::make_optional(speed->value()) : std::nullopt
56
+ );
57
+ }
58
+
59
+ public:
60
+ /**
61
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
62
+ */
63
+ [[maybe_unused]]
64
+ static jni::local_ref<JGeolocationCoordinates::javaobject> fromCpp(const GeolocationCoordinates& value) {
65
+ return newInstance(
66
+ value.latitude,
67
+ value.longitude,
68
+ value.altitude.has_value() ? jni::JDouble::valueOf(value.altitude.value()) : nullptr,
69
+ value.accuracy,
70
+ value.altitudeAccuracy.has_value() ? jni::JDouble::valueOf(value.altitudeAccuracy.value()) : nullptr,
71
+ value.heading.has_value() ? jni::JDouble::valueOf(value.heading.value()) : nullptr,
72
+ value.speed.has_value() ? jni::JDouble::valueOf(value.speed.value()) : nullptr
73
+ );
74
+ }
75
+ };
76
+
77
+ } // namespace margelo::nitro::nitrogeolocation
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// JGeolocationError.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 "GeolocationError.hpp"
12
+
13
+ #include <string>
14
+
15
+ namespace margelo::nitro::nitrogeolocation {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "GeolocationError" and the the Kotlin data class "GeolocationError".
21
+ */
22
+ struct JGeolocationError final: public jni::JavaClass<JGeolocationError> {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/GeolocationError;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct GeolocationError by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ GeolocationError toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldCode = clazz->getField<double>("code");
35
+ double code = this->getFieldValue(fieldCode);
36
+ static const auto fieldMessage = clazz->getField<jni::JString>("message");
37
+ jni::local_ref<jni::JString> message = this->getFieldValue(fieldMessage);
38
+ static const auto fieldPERMISSION_DENIED = clazz->getField<double>("PERMISSION_DENIED");
39
+ double PERMISSION_DENIED = this->getFieldValue(fieldPERMISSION_DENIED);
40
+ static const auto fieldPOSITION_UNAVAILABLE = clazz->getField<double>("POSITION_UNAVAILABLE");
41
+ double POSITION_UNAVAILABLE = this->getFieldValue(fieldPOSITION_UNAVAILABLE);
42
+ static const auto fieldTIMEOUT = clazz->getField<double>("TIMEOUT");
43
+ double TIMEOUT = this->getFieldValue(fieldTIMEOUT);
44
+ return GeolocationError(
45
+ code,
46
+ message->toStdString(),
47
+ PERMISSION_DENIED,
48
+ POSITION_UNAVAILABLE,
49
+ TIMEOUT
50
+ );
51
+ }
52
+
53
+ public:
54
+ /**
55
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
56
+ */
57
+ [[maybe_unused]]
58
+ static jni::local_ref<JGeolocationError::javaobject> fromCpp(const GeolocationError& value) {
59
+ return newInstance(
60
+ value.code,
61
+ jni::make_jstring(value.message),
62
+ value.PERMISSION_DENIED,
63
+ value.POSITION_UNAVAILABLE,
64
+ value.TIMEOUT
65
+ );
66
+ }
67
+ };
68
+
69
+ } // namespace margelo::nitro::nitrogeolocation
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// JGeolocationOptions.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 "GeolocationOptions.hpp"
12
+
13
+ #include <optional>
14
+
15
+ namespace margelo::nitro::nitrogeolocation {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "GeolocationOptions" and the the Kotlin data class "GeolocationOptions".
21
+ */
22
+ struct JGeolocationOptions final: public jni::JavaClass<JGeolocationOptions> {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/GeolocationOptions;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct GeolocationOptions by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ GeolocationOptions toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldTimeout = clazz->getField<jni::JDouble>("timeout");
35
+ jni::local_ref<jni::JDouble> timeout = this->getFieldValue(fieldTimeout);
36
+ static const auto fieldMaximumAge = clazz->getField<jni::JDouble>("maximumAge");
37
+ jni::local_ref<jni::JDouble> maximumAge = this->getFieldValue(fieldMaximumAge);
38
+ static const auto fieldEnableHighAccuracy = clazz->getField<jni::JBoolean>("enableHighAccuracy");
39
+ jni::local_ref<jni::JBoolean> enableHighAccuracy = this->getFieldValue(fieldEnableHighAccuracy);
40
+ static const auto fieldInterval = clazz->getField<jni::JDouble>("interval");
41
+ jni::local_ref<jni::JDouble> interval = this->getFieldValue(fieldInterval);
42
+ static const auto fieldFastestInterval = clazz->getField<jni::JDouble>("fastestInterval");
43
+ jni::local_ref<jni::JDouble> fastestInterval = this->getFieldValue(fieldFastestInterval);
44
+ static const auto fieldDistanceFilter = clazz->getField<jni::JDouble>("distanceFilter");
45
+ jni::local_ref<jni::JDouble> distanceFilter = this->getFieldValue(fieldDistanceFilter);
46
+ static const auto fieldUseSignificantChanges = clazz->getField<jni::JBoolean>("useSignificantChanges");
47
+ jni::local_ref<jni::JBoolean> useSignificantChanges = this->getFieldValue(fieldUseSignificantChanges);
48
+ return GeolocationOptions(
49
+ timeout != nullptr ? std::make_optional(timeout->value()) : std::nullopt,
50
+ maximumAge != nullptr ? std::make_optional(maximumAge->value()) : std::nullopt,
51
+ enableHighAccuracy != nullptr ? std::make_optional(static_cast<bool>(enableHighAccuracy->value())) : std::nullopt,
52
+ interval != nullptr ? std::make_optional(interval->value()) : std::nullopt,
53
+ fastestInterval != nullptr ? std::make_optional(fastestInterval->value()) : std::nullopt,
54
+ distanceFilter != nullptr ? std::make_optional(distanceFilter->value()) : std::nullopt,
55
+ useSignificantChanges != nullptr ? std::make_optional(static_cast<bool>(useSignificantChanges->value())) : std::nullopt
56
+ );
57
+ }
58
+
59
+ public:
60
+ /**
61
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
62
+ */
63
+ [[maybe_unused]]
64
+ static jni::local_ref<JGeolocationOptions::javaobject> fromCpp(const GeolocationOptions& value) {
65
+ return newInstance(
66
+ value.timeout.has_value() ? jni::JDouble::valueOf(value.timeout.value()) : nullptr,
67
+ value.maximumAge.has_value() ? jni::JDouble::valueOf(value.maximumAge.value()) : nullptr,
68
+ value.enableHighAccuracy.has_value() ? jni::JBoolean::valueOf(value.enableHighAccuracy.value()) : nullptr,
69
+ value.interval.has_value() ? jni::JDouble::valueOf(value.interval.value()) : nullptr,
70
+ value.fastestInterval.has_value() ? jni::JDouble::valueOf(value.fastestInterval.value()) : nullptr,
71
+ value.distanceFilter.has_value() ? jni::JDouble::valueOf(value.distanceFilter.value()) : nullptr,
72
+ value.useSignificantChanges.has_value() ? jni::JBoolean::valueOf(value.useSignificantChanges.value()) : nullptr
73
+ );
74
+ }
75
+ };
76
+
77
+ } // namespace margelo::nitro::nitrogeolocation
@@ -0,0 +1,59 @@
1
+ ///
2
+ /// JGeolocationResponse.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 "GeolocationResponse.hpp"
12
+
13
+ #include "GeolocationCoordinates.hpp"
14
+ #include "JGeolocationCoordinates.hpp"
15
+ #include <optional>
16
+
17
+ namespace margelo::nitro::nitrogeolocation {
18
+
19
+ using namespace facebook;
20
+
21
+ /**
22
+ * The C++ JNI bridge between the C++ struct "GeolocationResponse" and the the Kotlin data class "GeolocationResponse".
23
+ */
24
+ struct JGeolocationResponse final: public jni::JavaClass<JGeolocationResponse> {
25
+ public:
26
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/GeolocationResponse;";
27
+
28
+ public:
29
+ /**
30
+ * Convert this Java/Kotlin-based struct to the C++ struct GeolocationResponse by copying all values to C++.
31
+ */
32
+ [[maybe_unused]]
33
+ [[nodiscard]]
34
+ GeolocationResponse toCpp() const {
35
+ static const auto clazz = javaClassStatic();
36
+ static const auto fieldCoords = clazz->getField<JGeolocationCoordinates>("coords");
37
+ jni::local_ref<JGeolocationCoordinates> coords = this->getFieldValue(fieldCoords);
38
+ static const auto fieldTimestamp = clazz->getField<double>("timestamp");
39
+ double timestamp = this->getFieldValue(fieldTimestamp);
40
+ return GeolocationResponse(
41
+ coords->toCpp(),
42
+ timestamp
43
+ );
44
+ }
45
+
46
+ public:
47
+ /**
48
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
49
+ */
50
+ [[maybe_unused]]
51
+ static jni::local_ref<JGeolocationResponse::javaobject> fromCpp(const GeolocationResponse& value) {
52
+ return newInstance(
53
+ JGeolocationCoordinates::fromCpp(value.coords),
54
+ value.timestamp
55
+ );
56
+ }
57
+ };
58
+
59
+ } // namespace margelo::nitro::nitrogeolocation
@@ -0,0 +1,98 @@
1
+ ///
2
+ /// JHybridNitroGeolocationSpec.cpp
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
+ #include "JHybridNitroGeolocationSpec.hpp"
9
+
10
+ // Forward declaration of `RNConfigurationInternal` to properly resolve imports.
11
+ namespace margelo::nitro::nitrogeolocation { struct RNConfigurationInternal; }
12
+ // Forward declaration of `AuthorizationLevelInternal` to properly resolve imports.
13
+ namespace margelo::nitro::nitrogeolocation { enum class AuthorizationLevelInternal; }
14
+ // Forward declaration of `LocationProviderInternal` to properly resolve imports.
15
+ namespace margelo::nitro::nitrogeolocation { enum class LocationProviderInternal; }
16
+ // Forward declaration of `GeolocationError` to properly resolve imports.
17
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationError; }
18
+ // Forward declaration of `GeolocationResponse` to properly resolve imports.
19
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationResponse; }
20
+ // Forward declaration of `GeolocationCoordinates` to properly resolve imports.
21
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationCoordinates; }
22
+ // Forward declaration of `GeolocationOptions` to properly resolve imports.
23
+ namespace margelo::nitro::nitrogeolocation { struct GeolocationOptions; }
24
+
25
+ #include "RNConfigurationInternal.hpp"
26
+ #include "JRNConfigurationInternal.hpp"
27
+ #include "AuthorizationLevelInternal.hpp"
28
+ #include <optional>
29
+ #include "JAuthorizationLevelInternal.hpp"
30
+ #include "LocationProviderInternal.hpp"
31
+ #include "JLocationProviderInternal.hpp"
32
+ #include <functional>
33
+ #include "JFunc_void.hpp"
34
+ #include "GeolocationError.hpp"
35
+ #include "JFunc_void_GeolocationError.hpp"
36
+ #include "JGeolocationError.hpp"
37
+ #include <string>
38
+ #include "GeolocationResponse.hpp"
39
+ #include "JFunc_void_GeolocationResponse.hpp"
40
+ #include "JGeolocationResponse.hpp"
41
+ #include "GeolocationCoordinates.hpp"
42
+ #include "JGeolocationCoordinates.hpp"
43
+ #include "GeolocationOptions.hpp"
44
+ #include "JGeolocationOptions.hpp"
45
+
46
+ namespace margelo::nitro::nitrogeolocation {
47
+
48
+ jni::local_ref<JHybridNitroGeolocationSpec::jhybriddata> JHybridNitroGeolocationSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
49
+ return makeCxxInstance(jThis);
50
+ }
51
+
52
+ void JHybridNitroGeolocationSpec::registerNatives() {
53
+ registerHybrid({
54
+ makeNativeMethod("initHybrid", JHybridNitroGeolocationSpec::initHybrid),
55
+ });
56
+ }
57
+
58
+ size_t JHybridNitroGeolocationSpec::getExternalMemorySize() noexcept {
59
+ static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
60
+ return method(_javaPart);
61
+ }
62
+
63
+ void JHybridNitroGeolocationSpec::dispose() noexcept {
64
+ static const auto method = javaClassStatic()->getMethod<void()>("dispose");
65
+ method(_javaPart);
66
+ }
67
+
68
+ // Properties
69
+
70
+
71
+ // Methods
72
+ void JHybridNitroGeolocationSpec::setRNConfiguration(const RNConfigurationInternal& config) {
73
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JRNConfigurationInternal> /* config */)>("setRNConfiguration");
74
+ method(_javaPart, JRNConfigurationInternal::fromCpp(config));
75
+ }
76
+ void JHybridNitroGeolocationSpec::requestAuthorization(const std::optional<std::function<void()>>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error) {
77
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void::javaobject> /* success */, jni::alias_ref<JFunc_void_GeolocationError::javaobject> /* error */)>("requestAuthorization_cxx");
78
+ method(_javaPart, success.has_value() ? JFunc_void_cxx::fromCpp(success.value()) : nullptr, error.has_value() ? JFunc_void_GeolocationError_cxx::fromCpp(error.value()) : nullptr);
79
+ }
80
+ void JHybridNitroGeolocationSpec::getCurrentPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error, const std::optional<GeolocationOptions>& options) {
81
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_GeolocationResponse::javaobject> /* success */, jni::alias_ref<JFunc_void_GeolocationError::javaobject> /* error */, jni::alias_ref<JGeolocationOptions> /* options */)>("getCurrentPosition_cxx");
82
+ method(_javaPart, JFunc_void_GeolocationResponse_cxx::fromCpp(success), error.has_value() ? JFunc_void_GeolocationError_cxx::fromCpp(error.value()) : nullptr, options.has_value() ? JGeolocationOptions::fromCpp(options.value()) : nullptr);
83
+ }
84
+ double JHybridNitroGeolocationSpec::watchPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const GeolocationError& /* error */)>>& error, const std::optional<GeolocationOptions>& options) {
85
+ static const auto method = javaClassStatic()->getMethod<double(jni::alias_ref<JFunc_void_GeolocationResponse::javaobject> /* success */, jni::alias_ref<JFunc_void_GeolocationError::javaobject> /* error */, jni::alias_ref<JGeolocationOptions> /* options */)>("watchPosition_cxx");
86
+ auto __result = method(_javaPart, JFunc_void_GeolocationResponse_cxx::fromCpp(success), error.has_value() ? JFunc_void_GeolocationError_cxx::fromCpp(error.value()) : nullptr, options.has_value() ? JGeolocationOptions::fromCpp(options.value()) : nullptr);
87
+ return __result;
88
+ }
89
+ void JHybridNitroGeolocationSpec::clearWatch(double watchId) {
90
+ static const auto method = javaClassStatic()->getMethod<void(double /* watchId */)>("clearWatch");
91
+ method(_javaPart, watchId);
92
+ }
93
+ void JHybridNitroGeolocationSpec::stopObserving() {
94
+ static const auto method = javaClassStatic()->getMethod<void()>("stopObserving");
95
+ method(_javaPart);
96
+ }
97
+
98
+ } // namespace margelo::nitro::nitrogeolocation