react-native-nitro-geolocation 1.1.4 → 1.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.
- package/README.md +74 -8
- package/android/build.gradle +6 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/AndroidAccuracy.kt +105 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/AndroidHeadingManager.kt +313 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/AndroidLocationSettings.kt +313 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/GetCurrentPosition.kt +46 -45
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/LocationMetadata.kt +26 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/LocationValues.kt +31 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocation.kt +1025 -140
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocationCompat.kt +11 -11
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/RequestAuthorization.kt +6 -6
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/WatchPosition.kt +46 -45
- package/ios/CLLocation+GeolocationMetadata.swift +32 -0
- package/ios/LocationManager.swift +205 -51
- package/ios/NitroGeolocation.swift +949 -110
- package/ios/NitroGeolocationCompat.swift +7 -7
- package/nitrogen/generated/android/c++/JAccuracyAuthorization.hpp +61 -0
- package/nitrogen/generated/android/c++/JAndroidAccuracyPreset.hpp +64 -0
- package/nitrogen/generated/android/c++/JAndroidGranularity.hpp +61 -0
- package/nitrogen/generated/android/c++/{JRNConfigurationInternal.hpp → JCompatGeolocationConfigurationInternal.hpp} +10 -10
- package/nitrogen/generated/android/c++/{JGeolocationError.hpp → JCompatGeolocationError.hpp} +10 -10
- package/nitrogen/generated/android/c++/JCompatGeolocationOptions.hpp +105 -0
- package/nitrogen/generated/android/c++/JCompatGeolocationResponse.hpp +67 -0
- package/nitrogen/generated/android/c++/JFunc_void_AccuracyAuthorization.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_CompatGeolocationError.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_CompatGeolocationResponse.hpp +84 -0
- package/nitrogen/generated/android/c++/JFunc_void_GeolocationResponse.hpp +2 -0
- package/nitrogen/generated/android/c++/JFunc_void_Heading.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_LocationProviderStatus.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_PermissionStatus.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_GeocodedLocation_.hpp +97 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_ReverseGeocodedAddress_.hpp +98 -0
- package/nitrogen/generated/android/c++/JGeocodedLocation.hpp +65 -0
- package/nitrogen/generated/android/c++/JGeocodingCoordinates.hpp +61 -0
- package/nitrogen/generated/android/c++/{JModernGeolocationConfiguration.hpp → JGeolocationConfiguration.hpp} +10 -10
- package/nitrogen/generated/android/c++/JGeolocationResponse.hpp +13 -3
- package/nitrogen/generated/android/c++/JHeading.hpp +69 -0
- package/nitrogen/generated/android/c++/JHeadingOptions.hpp +57 -0
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.cpp +46 -30
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.hpp +4 -4
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp +169 -33
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.hpp +14 -3
- package/nitrogen/generated/android/c++/JIOSAccuracyPreset.hpp +73 -0
- package/nitrogen/generated/android/c++/JIOSActivityType.hpp +67 -0
- package/nitrogen/generated/android/c++/JLocationAccuracyOptions.hpp +65 -0
- package/nitrogen/generated/android/c++/JLocationAvailability.hpp +62 -0
- package/nitrogen/generated/android/c++/JLocationProviderStatus.hpp +77 -0
- package/nitrogen/generated/android/c++/JLocationProviderUsed.hpp +67 -0
- package/nitrogen/generated/android/c++/JLocationRequestOptions.hpp +49 -3
- package/nitrogen/generated/android/c++/{JGeolocationOptions.hpp → JLocationSettingsOptions.hpp} +28 -22
- package/nitrogen/generated/android/c++/JReverseGeocodedAddress.hpp +82 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AccuracyAuthorization.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AndroidAccuracyPreset.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AndroidGranularity.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{RNConfigurationInternal.kt → CompatGeolocationConfigurationInternal.kt} +5 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{GeolocationError.kt → CompatGeolocationError.kt} +5 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/CompatGeolocationOptions.kt +68 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/CompatGeolocationResponse.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_AccuracyAuthorization.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{Func_void_GeolocationError.kt → Func_void_CompatGeolocationError.kt} +9 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_CompatGeolocationResponse.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_Heading.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_LocationProviderStatus.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_PermissionStatus.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_std__vector_GeocodedLocation_.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_std__vector_ReverseGeocodedAddress_.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeocodedLocation.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeocodingCoordinates.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{ModernGeolocationConfiguration.kt → GeolocationConfiguration.kt} +5 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationResponse.kt +9 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Heading.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HeadingOptions.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationCompatSpec.kt +7 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationSpec.kt +92 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/IOSAccuracyPreset.kt +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/IOSActivityType.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationAccuracyOptions.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationAvailability.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderStatus.kt +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderUsed.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationRequestOptions.kt +30 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/{GeolocationOptions.kt → LocationSettingsOptions.kt} +11 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/ReverseGeocodedAddress.kt +56 -0
- package/nitrogen/generated/android/nitrogeolocationOnLoad.cpp +18 -4
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.cpp +76 -12
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp +519 -77
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Umbrella.hpp +61 -12
- package/nitrogen/generated/ios/c++/HybridNitroGeolocationCompatSpecSwift.hpp +28 -16
- package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.hpp +131 -13
- package/nitrogen/generated/ios/swift/AccuracyAuthorization.swift +44 -0
- package/nitrogen/generated/ios/swift/AndroidAccuracyPreset.swift +48 -0
- package/nitrogen/generated/ios/swift/AndroidGranularity.swift +44 -0
- package/nitrogen/generated/ios/swift/{RNConfigurationInternal.swift → CompatGeolocationConfigurationInternal.swift} +5 -5
- package/nitrogen/generated/ios/swift/{GeolocationError.swift → CompatGeolocationError.swift} +5 -5
- package/nitrogen/generated/ios/swift/CompatGeolocationOptions.swift +208 -0
- package/nitrogen/generated/ios/swift/CompatGeolocationResponse.swift +34 -0
- package/nitrogen/generated/ios/swift/Func_void_AccuracyAuthorization.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_CompatGeolocationError.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_CompatGeolocationResponse.swift +46 -0
- package/nitrogen/generated/ios/swift/{Func_void_GeolocationError.swift → Func_void_Heading.swift} +11 -11
- package/nitrogen/generated/ios/swift/Func_void_LocationAvailability.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_LocationProviderStatus.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_GeocodedLocation_.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_ReverseGeocodedAddress_.swift +46 -0
- package/nitrogen/generated/ios/swift/GeocodedLocation.swift +52 -0
- package/nitrogen/generated/ios/swift/GeocodingCoordinates.swift +34 -0
- package/nitrogen/generated/ios/swift/{ModernGeolocationConfiguration.swift → GeolocationConfiguration.swift} +5 -5
- package/nitrogen/generated/ios/swift/GeolocationResponse.swift +31 -2
- package/nitrogen/generated/ios/swift/Heading.swift +70 -0
- package/nitrogen/generated/ios/swift/HeadingOptions.swift +42 -0
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec.swift +4 -4
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec_cxx.swift +28 -28
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec.swift +14 -3
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec_cxx.swift +318 -15
- package/nitrogen/generated/ios/swift/IOSAccuracyPreset.swift +60 -0
- package/nitrogen/generated/ios/swift/IOSActivityType.swift +52 -0
- package/nitrogen/generated/ios/swift/LocationAccuracyOptions.swift +46 -0
- package/nitrogen/generated/ios/swift/LocationAvailability.swift +47 -0
- package/nitrogen/generated/ios/swift/LocationProviderStatus.swift +106 -0
- package/nitrogen/generated/ios/swift/LocationProviderUsed.swift +52 -0
- package/nitrogen/generated/ios/swift/LocationRequestOptions.swift +142 -1
- package/nitrogen/generated/ios/swift/{GeolocationOptions.swift → LocationSettingsOptions.swift} +39 -46
- package/nitrogen/generated/ios/swift/ReverseGeocodedAddress.swift +150 -0
- package/nitrogen/generated/shared/c++/AccuracyAuthorization.hpp +80 -0
- package/nitrogen/generated/shared/c++/AndroidAccuracyPreset.hpp +84 -0
- package/nitrogen/generated/shared/c++/AndroidGranularity.hpp +80 -0
- package/nitrogen/generated/shared/c++/{RNConfigurationInternal.hpp → CompatGeolocationConfigurationInternal.hpp} +11 -11
- package/nitrogen/generated/shared/c++/{GeolocationError.hpp → CompatGeolocationError.hpp} +11 -11
- package/nitrogen/generated/shared/c++/CompatGeolocationOptions.hpp +128 -0
- package/nitrogen/generated/shared/c++/CompatGeolocationResponse.hpp +88 -0
- package/nitrogen/generated/shared/c++/GeocodedLocation.hpp +91 -0
- package/nitrogen/generated/shared/c++/GeocodingCoordinates.hpp +87 -0
- package/nitrogen/generated/shared/c++/{ModernGeolocationConfiguration.hpp → GeolocationConfiguration.hpp} +11 -11
- package/nitrogen/generated/shared/c++/GeolocationResponse.hpp +14 -2
- package/nitrogen/generated/shared/c++/Heading.hpp +95 -0
- package/nitrogen/generated/shared/c++/HeadingOptions.hpp +83 -0
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.hpp +16 -16
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp +11 -0
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.hpp +51 -12
- package/nitrogen/generated/shared/c++/IOSAccuracyPreset.hpp +96 -0
- package/nitrogen/generated/shared/c++/IOSActivityType.hpp +88 -0
- package/nitrogen/generated/shared/c++/LocationAccuracyOptions.hpp +92 -0
- package/nitrogen/generated/shared/c++/LocationAvailability.hpp +88 -0
- package/nitrogen/generated/shared/c++/LocationProviderStatus.hpp +103 -0
- package/nitrogen/generated/shared/c++/LocationProviderUsed.hpp +88 -0
- package/nitrogen/generated/shared/c++/LocationRequestOptions.hpp +47 -3
- package/nitrogen/generated/shared/c++/{GeolocationOptions.hpp → LocationSettingsOptions.hpp} +26 -24
- package/nitrogen/generated/shared/c++/ReverseGeocodedAddress.hpp +108 -0
- package/package.json +1 -1
- package/src/NitroGeolocation.nitro.ts +291 -17
- package/src/NitroGeolocationCompat.nitro.ts +12 -12
- package/src/api/geocode.ts +18 -0
- package/src/api/getAccuracyAuthorization.ts +12 -0
- package/src/api/getCurrentPosition.ts +5 -3
- package/src/api/getHeading.ts +13 -0
- package/src/api/getLastKnownPosition.ts +28 -0
- package/src/api/getLocationAvailability.ts +11 -0
- package/src/api/getProviderStatus.ts +16 -0
- package/src/api/hasServicesEnabled.ts +13 -0
- package/src/api/index.ts +11 -0
- package/src/api/requestLocationSettings.ts +29 -0
- package/src/api/requestPermission.ts +3 -1
- package/src/api/requestTemporaryFullAccuracy.ts +21 -0
- package/src/api/reverseGeocode.ts +23 -0
- package/src/api/setConfiguration.ts +8 -4
- package/src/api/watchHeading.ts +19 -0
- package/src/api/watchPosition.ts +2 -2
- package/src/compat/getCurrentPosition.ts +7 -7
- package/src/compat/index.tsx +5 -5
- package/src/compat/requestAuthorization.ts +2 -2
- package/src/compat/setRNConfiguration.ts +7 -5
- package/src/compat/watchPosition.ts +7 -7
- package/src/devtools/getCurrentPosition.ts +5 -3
- package/src/devtools/index.ts +1 -1
- package/src/devtools/watchPosition.ts +6 -7
- package/src/hooks/useWatchPosition.ts +2 -2
- package/src/index.tsx +35 -6
- package/src/publicTypes.ts +96 -0
- package/src/types.ts +113 -37
- package/src/utils/errors.test.ts +65 -0
- package/src/utils/errors.ts +45 -18
- package/src/utils/index.ts +2 -2
- package/src/utils/provider.test.ts +172 -1
- package/src/utils/provider.ts +50 -5
- package/nitrogen/generated/android/c++/JFunc_void_GeolocationError.hpp +0 -78
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ReverseGeocodedAddress.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#include <string>
|
|
34
|
+
#include <optional>
|
|
35
|
+
|
|
36
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A struct which can be represented as a JavaScript object (ReverseGeocodedAddress).
|
|
40
|
+
*/
|
|
41
|
+
struct ReverseGeocodedAddress final {
|
|
42
|
+
public:
|
|
43
|
+
std::optional<std::string> country SWIFT_PRIVATE;
|
|
44
|
+
std::optional<std::string> region SWIFT_PRIVATE;
|
|
45
|
+
std::optional<std::string> city SWIFT_PRIVATE;
|
|
46
|
+
std::optional<std::string> district SWIFT_PRIVATE;
|
|
47
|
+
std::optional<std::string> street SWIFT_PRIVATE;
|
|
48
|
+
std::optional<std::string> postalCode SWIFT_PRIVATE;
|
|
49
|
+
std::optional<std::string> formattedAddress SWIFT_PRIVATE;
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
ReverseGeocodedAddress() = default;
|
|
53
|
+
explicit ReverseGeocodedAddress(std::optional<std::string> country, std::optional<std::string> region, std::optional<std::string> city, std::optional<std::string> district, std::optional<std::string> street, std::optional<std::string> postalCode, std::optional<std::string> formattedAddress): country(country), region(region), city(city), district(district), street(street), postalCode(postalCode), formattedAddress(formattedAddress) {}
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
friend bool operator==(const ReverseGeocodedAddress& lhs, const ReverseGeocodedAddress& rhs) = default;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
60
|
+
|
|
61
|
+
namespace margelo::nitro {
|
|
62
|
+
|
|
63
|
+
// C++ ReverseGeocodedAddress <> JS ReverseGeocodedAddress (object)
|
|
64
|
+
template <>
|
|
65
|
+
struct JSIConverter<margelo::nitro::nitrogeolocation::ReverseGeocodedAddress> final {
|
|
66
|
+
static inline margelo::nitro::nitrogeolocation::ReverseGeocodedAddress fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
67
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
68
|
+
return margelo::nitro::nitrogeolocation::ReverseGeocodedAddress(
|
|
69
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "country"))),
|
|
70
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "region"))),
|
|
71
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "city"))),
|
|
72
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "district"))),
|
|
73
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "street"))),
|
|
74
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "postalCode"))),
|
|
75
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "formattedAddress")))
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrogeolocation::ReverseGeocodedAddress& arg) {
|
|
79
|
+
jsi::Object obj(runtime);
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "country"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.country));
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "region"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.region));
|
|
82
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "city"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.city));
|
|
83
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "district"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.district));
|
|
84
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "street"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.street));
|
|
85
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "postalCode"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.postalCode));
|
|
86
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "formattedAddress"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.formattedAddress));
|
|
87
|
+
return obj;
|
|
88
|
+
}
|
|
89
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
90
|
+
if (!value.isObject()) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
jsi::Object obj = value.getObject(runtime);
|
|
94
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "country")))) return false;
|
|
98
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "region")))) return false;
|
|
99
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "city")))) return false;
|
|
100
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "district")))) return false;
|
|
101
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "street")))) return false;
|
|
102
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "postalCode")))) return false;
|
|
103
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "formattedAddress")))) return false;
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
} // namespace margelo::nitro
|
package/package.json
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import type { HybridObject } from "react-native-nitro-modules";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
AccuracyAuthorization,
|
|
4
|
+
AndroidGranularity,
|
|
5
|
+
GeocodedLocation,
|
|
6
|
+
GeocodingCoordinates,
|
|
7
|
+
GeolocationResponse,
|
|
8
|
+
Heading,
|
|
9
|
+
HeadingOptions,
|
|
10
|
+
IOSActivityType,
|
|
11
|
+
LocationAccuracyOptions,
|
|
12
|
+
LocationAvailability,
|
|
13
|
+
LocationProviderStatus,
|
|
14
|
+
ReverseGeocodedAddress
|
|
15
|
+
} from "./types";
|
|
3
16
|
|
|
4
17
|
/**
|
|
5
18
|
* Permission status for location services.
|
|
@@ -24,13 +37,14 @@ export type LocationProvider = "playServices" | "android_platform" | "auto";
|
|
|
24
37
|
|
|
25
38
|
/**
|
|
26
39
|
* Global configuration for geolocation services.
|
|
27
|
-
*
|
|
40
|
+
* Apply once at app startup with `setConfiguration()`.
|
|
28
41
|
*/
|
|
29
|
-
export interface
|
|
42
|
+
export interface GeolocationConfiguration {
|
|
30
43
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
44
|
+
* @deprecated This option is accepted for backward compatibility only.
|
|
45
|
+
* `setConfiguration()` does not request permission. Call
|
|
46
|
+
* `requestPermission()` explicitly when your app is ready to show the native
|
|
47
|
+
* permission prompt.
|
|
34
48
|
* @default false
|
|
35
49
|
*/
|
|
36
50
|
autoRequestPermission?: boolean;
|
|
@@ -68,9 +82,26 @@ export interface LocationRequestOptions {
|
|
|
68
82
|
/** Maximum age of cached location in milliseconds (default: 0) */
|
|
69
83
|
maximumAge?: number;
|
|
70
84
|
|
|
71
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Enable high accuracy mode (GPS).
|
|
87
|
+
*
|
|
88
|
+
* @deprecated Since v1.2, use `accuracy` for explicit platform-native
|
|
89
|
+
* presets. This remains available for v1 compatibility and is planned for
|
|
90
|
+
* removal from the Modern API in v2.
|
|
91
|
+
*/
|
|
72
92
|
enableHighAccuracy?: boolean;
|
|
73
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Platform-specific accuracy preset.
|
|
96
|
+
*
|
|
97
|
+
* Available since v1.2.
|
|
98
|
+
*
|
|
99
|
+
* When provided, this takes precedence over `enableHighAccuracy` on the
|
|
100
|
+
* matching platform while keeping `enableHighAccuracy` available for the
|
|
101
|
+
* legacy true/false contract.
|
|
102
|
+
*/
|
|
103
|
+
accuracy?: LocationAccuracyOptions;
|
|
104
|
+
|
|
74
105
|
/** Minimum time interval between updates in milliseconds (watch only) */
|
|
75
106
|
interval?: number;
|
|
76
107
|
|
|
@@ -80,23 +111,134 @@ export interface LocationRequestOptions {
|
|
|
80
111
|
/** Minimum distance change in meters for updates (watch only) */
|
|
81
112
|
distanceFilter?: number;
|
|
82
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Android-only location granularity.
|
|
116
|
+
*
|
|
117
|
+
* Available since v1.2.
|
|
118
|
+
*
|
|
119
|
+
* `permission` follows the granted permission level, `coarse` prevents fine
|
|
120
|
+
* GPS-only requests from being used, and `fine` requires fine location
|
|
121
|
+
* permission.
|
|
122
|
+
*/
|
|
123
|
+
granularity?: AndroidGranularity;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Android-only option for high-accuracy initial updates.
|
|
127
|
+
*
|
|
128
|
+
* Available since v1.2.
|
|
129
|
+
*/
|
|
130
|
+
waitForAccurateLocation?: boolean;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Android-only maximum age for an initial update in milliseconds.
|
|
134
|
+
*
|
|
135
|
+
* Available since v1.2.
|
|
136
|
+
*/
|
|
137
|
+
maxUpdateAge?: number;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Android-only maximum batching delay in milliseconds.
|
|
141
|
+
*
|
|
142
|
+
* Available since v1.2.
|
|
143
|
+
*/
|
|
144
|
+
maxUpdateDelay?: number;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Android-only maximum number of updates before a watch stops itself.
|
|
148
|
+
*
|
|
149
|
+
* Available since v1.2.
|
|
150
|
+
*/
|
|
151
|
+
maxUpdates?: number;
|
|
152
|
+
|
|
83
153
|
/** Use significant location changes mode (iOS watch only) */
|
|
84
154
|
useSignificantChanges?: boolean;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* iOS-only activity type used to tune Core Location behavior.
|
|
158
|
+
*
|
|
159
|
+
* Available since v1.2.
|
|
160
|
+
*/
|
|
161
|
+
activityType?: IOSActivityType;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* iOS-only setting for automatic pausing of location updates.
|
|
165
|
+
*
|
|
166
|
+
* Available since v1.2.
|
|
167
|
+
*/
|
|
168
|
+
pausesLocationUpdatesAutomatically?: boolean;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* iOS-only setting for the background location indicator.
|
|
172
|
+
*
|
|
173
|
+
* Requires background location capability and is ignored by Android.
|
|
174
|
+
*
|
|
175
|
+
* Available since v1.2.
|
|
176
|
+
*/
|
|
177
|
+
showsBackgroundLocationIndicator?: boolean;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Android-only location settings request options.
|
|
182
|
+
*
|
|
183
|
+
* Used by `requestLocationSettings()` on Android to build the native
|
|
184
|
+
* `LocationSettingsRequest`. On iOS these options are ignored because iOS does
|
|
185
|
+
* not provide an equivalent system settings resolution dialog.
|
|
186
|
+
*/
|
|
187
|
+
export interface LocationSettingsOptions {
|
|
188
|
+
/**
|
|
189
|
+
* Request high accuracy Android location settings.
|
|
190
|
+
* Defaults to true because this API is primarily used before user-facing
|
|
191
|
+
* precise location flows.
|
|
192
|
+
*
|
|
193
|
+
* @deprecated Since v1.2, use `accuracy.android` for explicit Android
|
|
194
|
+
* settings priorities. This remains available for v1 compatibility and is
|
|
195
|
+
* planned for removal from the Modern API in v2.
|
|
196
|
+
*/
|
|
197
|
+
enableHighAccuracy?: boolean;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Platform-specific accuracy preset for settings checks.
|
|
201
|
+
*
|
|
202
|
+
* Available since v1.2.
|
|
203
|
+
*
|
|
204
|
+
* Android uses `accuracy.android` to map to the native location request
|
|
205
|
+
* priority. iOS ignores this option because iOS has no equivalent settings
|
|
206
|
+
* resolution dialog.
|
|
207
|
+
*/
|
|
208
|
+
accuracy?: LocationAccuracyOptions;
|
|
209
|
+
|
|
210
|
+
/** Desired update interval in milliseconds. */
|
|
211
|
+
interval?: number;
|
|
212
|
+
|
|
213
|
+
/** Fastest acceptable update interval in milliseconds. */
|
|
214
|
+
fastestInterval?: number;
|
|
215
|
+
|
|
216
|
+
/** Minimum distance change in meters. */
|
|
217
|
+
distanceFilter?: number;
|
|
218
|
+
|
|
219
|
+
/** Ask Android to always show the resolution dialog when possible. */
|
|
220
|
+
alwaysShow?: boolean;
|
|
221
|
+
|
|
222
|
+
/** Require BLE availability for the location settings request. */
|
|
223
|
+
needBle?: boolean;
|
|
85
224
|
}
|
|
86
225
|
|
|
87
226
|
/**
|
|
88
227
|
* Location error structure.
|
|
89
228
|
*/
|
|
90
229
|
export interface LocationError {
|
|
91
|
-
|
|
230
|
+
// -1: INTERNAL_ERROR, 1: PERMISSION_DENIED, 2: POSITION_UNAVAILABLE,
|
|
231
|
+
// 3: TIMEOUT, 4: PLAY_SERVICE_NOT_AVAILABLE, 5: SETTINGS_NOT_SATISFIED
|
|
232
|
+
code: number;
|
|
92
233
|
message: string;
|
|
93
234
|
}
|
|
94
235
|
|
|
95
236
|
/**
|
|
96
|
-
*
|
|
237
|
+
* Geolocation Nitro Module.
|
|
97
238
|
*
|
|
98
239
|
* Key Features:
|
|
99
|
-
* -
|
|
240
|
+
* - Public async APIs are wrapped in JS Promises
|
|
241
|
+
* - Native sends structured LocationError callbacks
|
|
100
242
|
* - First-class function callbacks for continuous updates
|
|
101
243
|
* - Token-based subscriptions (internal use only)
|
|
102
244
|
* - Type-safe across JS ↔ Native boundary
|
|
@@ -105,11 +247,11 @@ export interface NitroGeolocation
|
|
|
105
247
|
extends HybridObject<{ ios: "swift"; android: "kotlin" }> {
|
|
106
248
|
/**
|
|
107
249
|
* Set global geolocation configuration.
|
|
108
|
-
* Should be called once at app startup
|
|
250
|
+
* Should be called once at app startup before location requests.
|
|
109
251
|
*
|
|
110
252
|
* @param config - Platform-specific configuration
|
|
111
253
|
*/
|
|
112
|
-
setConfiguration(config:
|
|
254
|
+
setConfiguration(config: GeolocationConfiguration): void;
|
|
113
255
|
|
|
114
256
|
/**
|
|
115
257
|
* Check current location permission status.
|
|
@@ -123,9 +265,82 @@ export interface NitroGeolocation
|
|
|
123
265
|
* Request location permission from the user.
|
|
124
266
|
* Shows system permission dialog if not yet determined.
|
|
125
267
|
*
|
|
126
|
-
*
|
|
268
|
+
* Internal native contract. The public JS API wraps this in a Promise so
|
|
269
|
+
* native remains the source of truth for structured LocationError objects.
|
|
270
|
+
*/
|
|
271
|
+
requestPermission(
|
|
272
|
+
success: (status: PermissionStatus) => void,
|
|
273
|
+
error?: (error: LocationError) => void
|
|
274
|
+
): void;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Check whether device-level location services are enabled.
|
|
278
|
+
*
|
|
279
|
+
* Android: checks Android system location/provider state.
|
|
280
|
+
* iOS: maps to `CLLocationManager.locationServicesEnabled()`.
|
|
281
|
+
*/
|
|
282
|
+
hasServicesEnabled(): Promise<boolean>;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Get native provider/settings state.
|
|
286
|
+
*
|
|
287
|
+
* Android: returns Android provider availability and Google Location Accuracy
|
|
288
|
+
* state when available.
|
|
289
|
+
*
|
|
290
|
+
* iOS: returns Core Location service availability and app background location
|
|
291
|
+
* mode only. Android-specific provider fields are `undefined`.
|
|
292
|
+
*/
|
|
293
|
+
getProviderStatus(): Promise<LocationProviderStatus>;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Get whether the current platform is likely to deliver location updates.
|
|
297
|
+
*
|
|
298
|
+
* Android: uses Fused Location availability when the configured provider is
|
|
299
|
+
* Play Services, otherwise falls back to platform provider/service checks.
|
|
300
|
+
*
|
|
301
|
+
* iOS: maps Core Location service and authorization state.
|
|
127
302
|
*/
|
|
128
|
-
|
|
303
|
+
getLocationAvailability(): Promise<LocationAvailability>;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Android-only settings resolution API.
|
|
307
|
+
*
|
|
308
|
+
* Android: checks whether current device settings satisfy the requested
|
|
309
|
+
* location requirements and shows the native settings resolution dialog when
|
|
310
|
+
* Android can resolve the mismatch.
|
|
311
|
+
*
|
|
312
|
+
* iOS: does not show a settings dialog and ignores `options`. It resolves
|
|
313
|
+
* with `locationServicesEnabled`, `backgroundModeEnabled`, and `undefined`
|
|
314
|
+
* Android-specific provider fields.
|
|
315
|
+
*/
|
|
316
|
+
requestLocationSettings(
|
|
317
|
+
success: (status: LocationProviderStatus) => void,
|
|
318
|
+
error?: (error: LocationError) => void,
|
|
319
|
+
options?: LocationSettingsOptions
|
|
320
|
+
): void;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Get current platform location accuracy authorization.
|
|
324
|
+
*
|
|
325
|
+
* iOS: maps Core Location full/reduced accuracy authorization.
|
|
326
|
+
* Android: maps fine permission to `full` and coarse-only permission to
|
|
327
|
+
* `reduced`.
|
|
328
|
+
*/
|
|
329
|
+
getAccuracyAuthorization(): Promise<AccuracyAuthorization>;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* iOS-only temporary full accuracy request.
|
|
333
|
+
*
|
|
334
|
+
* iOS: calls Core Location temporary full accuracy authorization with the
|
|
335
|
+
* provided Info.plist purpose key.
|
|
336
|
+
* Android: resolves with the current accuracy authorization without showing
|
|
337
|
+
* a prompt.
|
|
338
|
+
*/
|
|
339
|
+
requestTemporaryFullAccuracy(
|
|
340
|
+
purposeKey: string,
|
|
341
|
+
success: (authorization: AccuracyAuthorization) => void,
|
|
342
|
+
error?: (error: LocationError) => void
|
|
343
|
+
): void;
|
|
129
344
|
|
|
130
345
|
/**
|
|
131
346
|
* Get current location (one-time request).
|
|
@@ -135,13 +350,72 @@ export interface NitroGeolocation
|
|
|
135
350
|
* 2. Request fresh location from GPS/Network
|
|
136
351
|
* 3. Timeout after specified duration
|
|
137
352
|
*
|
|
353
|
+
* Internal native contract. The public JS API wraps this in a Promise so
|
|
354
|
+
* native remains the source of truth for structured LocationError objects.
|
|
355
|
+
*
|
|
356
|
+
* @param success - Called with the current position
|
|
357
|
+
* @param error - Called with native-classified LocationError
|
|
138
358
|
* @param options - Location request options
|
|
139
|
-
* @returns Promise resolving to current position
|
|
140
|
-
* @throws LocationError if permission denied, timeout, or unavailable
|
|
141
359
|
*/
|
|
142
360
|
getCurrentPosition(
|
|
361
|
+
success: (position: GeolocationResponse) => void,
|
|
362
|
+
error?: (error: LocationError) => void,
|
|
143
363
|
options?: LocationRequestOptions
|
|
144
|
-
):
|
|
364
|
+
): void;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Get the best cached location without starting a fresh location request.
|
|
368
|
+
*
|
|
369
|
+
* Returns `POSITION_UNAVAILABLE` when no cached location satisfies `options`.
|
|
370
|
+
*/
|
|
371
|
+
getLastKnownPosition(
|
|
372
|
+
success: (position: GeolocationResponse) => void,
|
|
373
|
+
error?: (error: LocationError) => void,
|
|
374
|
+
options?: LocationRequestOptions
|
|
375
|
+
): void;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Convert a human-readable address into candidate coordinates.
|
|
379
|
+
*
|
|
380
|
+
* Uses the platform geocoder: Android `Geocoder` and iOS `CLGeocoder`.
|
|
381
|
+
* Results and availability depend on platform networking/geocoder services.
|
|
382
|
+
*/
|
|
383
|
+
geocode(
|
|
384
|
+
address: string,
|
|
385
|
+
success: (locations: GeocodedLocation[]) => void,
|
|
386
|
+
error?: (error: LocationError) => void
|
|
387
|
+
): void;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Convert coordinates into candidate human-readable addresses.
|
|
391
|
+
*
|
|
392
|
+
* Uses the platform geocoder: Android `Geocoder` and iOS `CLGeocoder`.
|
|
393
|
+
* Results and availability depend on platform networking/geocoder services.
|
|
394
|
+
*/
|
|
395
|
+
reverseGeocode(
|
|
396
|
+
coords: GeocodingCoordinates,
|
|
397
|
+
success: (addresses: ReverseGeocodedAddress[]) => void,
|
|
398
|
+
error?: (error: LocationError) => void
|
|
399
|
+
): void;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Get one heading reading from the platform heading sensor.
|
|
403
|
+
*/
|
|
404
|
+
getHeading(
|
|
405
|
+
success: (heading: Heading) => void,
|
|
406
|
+
error?: (error: LocationError) => void
|
|
407
|
+
): void;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Start watching heading updates.
|
|
411
|
+
*
|
|
412
|
+
* Use `unwatch(token)` to stop a heading watch.
|
|
413
|
+
*/
|
|
414
|
+
watchHeading(
|
|
415
|
+
success: (heading: Heading) => void,
|
|
416
|
+
error?: (error: LocationError) => void,
|
|
417
|
+
options?: HeadingOptions
|
|
418
|
+
): string;
|
|
145
419
|
|
|
146
420
|
/**
|
|
147
421
|
* Start watching for continuous location updates.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { HybridObject } from "react-native-nitro-modules";
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
CompatGeolocationError,
|
|
4
|
+
CompatGeolocationOptions,
|
|
5
|
+
CompatGeolocationResponse
|
|
6
6
|
} from "./types";
|
|
7
7
|
|
|
8
8
|
// Configuration - Internal (for C++ codegen, avoiding ANDROID macro conflict)
|
|
@@ -12,7 +12,7 @@ export type LocationProviderInternal =
|
|
|
12
12
|
| "android_platform"
|
|
13
13
|
| "auto";
|
|
14
14
|
|
|
15
|
-
export interface
|
|
15
|
+
export interface CompatGeolocationConfigurationInternal {
|
|
16
16
|
skipPermissionRequests: boolean;
|
|
17
17
|
authorizationLevel?: AuthorizationLevelInternal;
|
|
18
18
|
enableBackgroundLocationUpdates?: boolean;
|
|
@@ -21,20 +21,20 @@ export interface RNConfigurationInternal {
|
|
|
21
21
|
|
|
22
22
|
export interface NitroGeolocationCompat
|
|
23
23
|
extends HybridObject<{ ios: "swift"; android: "kotlin" }> {
|
|
24
|
-
setRNConfiguration(config:
|
|
24
|
+
setRNConfiguration(config: CompatGeolocationConfigurationInternal): void;
|
|
25
25
|
requestAuthorization(
|
|
26
26
|
success?: () => void,
|
|
27
|
-
error?: (error:
|
|
27
|
+
error?: (error: CompatGeolocationError) => void
|
|
28
28
|
): void;
|
|
29
29
|
getCurrentPosition(
|
|
30
|
-
success: (position:
|
|
31
|
-
error?: (error:
|
|
32
|
-
options?:
|
|
30
|
+
success: (position: CompatGeolocationResponse) => void,
|
|
31
|
+
error?: (error: CompatGeolocationError) => void,
|
|
32
|
+
options?: CompatGeolocationOptions
|
|
33
33
|
): void;
|
|
34
34
|
watchPosition(
|
|
35
|
-
success: (position:
|
|
36
|
-
error?: (error:
|
|
37
|
-
options?:
|
|
35
|
+
success: (position: CompatGeolocationResponse) => void,
|
|
36
|
+
error?: (error: CompatGeolocationError) => void,
|
|
37
|
+
options?: CompatGeolocationOptions
|
|
38
38
|
): number;
|
|
39
39
|
clearWatch(watchId: number): void;
|
|
40
40
|
stopObserving(): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
2
|
+
import type { GeocodedLocation } from "../publicTypes";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Convert a human-readable address into candidate coordinates.
|
|
6
|
+
*
|
|
7
|
+
* Uses the platform geocoder: Android `Geocoder` and iOS `CLGeocoder`.
|
|
8
|
+
* Results and availability depend on platform networking/geocoder services.
|
|
9
|
+
*
|
|
10
|
+
* @param address - Human-readable address or place query
|
|
11
|
+
* @returns Promise resolving to matching coordinate candidates
|
|
12
|
+
* @throws LocationError if input is invalid or the platform geocoder fails
|
|
13
|
+
*/
|
|
14
|
+
export function geocode(address: string): Promise<GeocodedLocation[]> {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
NitroGeolocationHybridObject.geocode(address, resolve, reject);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
2
|
+
import type { AccuracyAuthorization } from "../publicTypes";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get current platform location accuracy authorization.
|
|
6
|
+
*
|
|
7
|
+
* iOS maps Core Location full/reduced accuracy authorization. Android maps
|
|
8
|
+
* fine permission to `full` and coarse-only permission to `reduced`.
|
|
9
|
+
*/
|
|
10
|
+
export function getAccuracyAuthorization(): Promise<AccuracyAuthorization> {
|
|
11
|
+
return NitroGeolocationHybridObject.getAccuracyAuthorization();
|
|
12
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { LocationRequestOptions } from "../NitroGeolocation.nitro";
|
|
|
2
2
|
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
3
3
|
import { isDevtoolsEnabled } from "../devtools";
|
|
4
4
|
import { getDevtoolsCurrentPosition } from "../devtools/getCurrentPosition";
|
|
5
|
-
import type { GeolocationResponse } from "../
|
|
5
|
+
import type { GeolocationResponse } from "../publicTypes";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Get current location (one-time request).
|
|
@@ -21,7 +21,7 @@ import type { GeolocationResponse } from "../types";
|
|
|
21
21
|
*
|
|
22
22
|
* try {
|
|
23
23
|
* const position = await getCurrentPosition({
|
|
24
|
-
*
|
|
24
|
+
* accuracy: { android: "high", ios: "best" },
|
|
25
25
|
* timeout: 15000
|
|
26
26
|
* });
|
|
27
27
|
* console.log(position.coords.latitude, position.coords.longitude);
|
|
@@ -39,5 +39,7 @@ export function getCurrentPosition(
|
|
|
39
39
|
return devtoolsResult;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
return
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
NitroGeolocationHybridObject.getCurrentPosition(resolve, reject, options);
|
|
44
|
+
});
|
|
43
45
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
2
|
+
import type { Heading } from "../publicTypes";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get one platform heading reading.
|
|
6
|
+
*
|
|
7
|
+
* @returns Promise resolving to magnetic/true heading data.
|
|
8
|
+
*/
|
|
9
|
+
export function getHeading(): Promise<Heading> {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
NitroGeolocationHybridObject.getHeading(resolve, reject);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { LocationRequestOptions } from "../NitroGeolocation.nitro";
|
|
2
|
+
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
3
|
+
import { isDevtoolsEnabled } from "../devtools";
|
|
4
|
+
import { getDevtoolsCurrentPosition } from "../devtools/getCurrentPosition";
|
|
5
|
+
import type { GeolocationResponse } from "../publicTypes";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get the best cached location without starting a fresh native location
|
|
9
|
+
* request.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Cache filtering and provider selection options
|
|
12
|
+
* @returns Promise resolving to a cached position
|
|
13
|
+
* @throws LocationError if permission is denied or no cached location exists
|
|
14
|
+
*/
|
|
15
|
+
export function getLastKnownPosition(
|
|
16
|
+
options?: LocationRequestOptions
|
|
17
|
+
): Promise<GeolocationResponse> {
|
|
18
|
+
if (isDevtoolsEnabled()) {
|
|
19
|
+
const devtoolsResult = getDevtoolsCurrentPosition();
|
|
20
|
+
if (devtoolsResult) {
|
|
21
|
+
return devtoolsResult;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
NitroGeolocationHybridObject.getLastKnownPosition(resolve, reject, options);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
2
|
+
import type { LocationAvailability } from "../publicTypes";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Check whether the current platform is likely to deliver location updates.
|
|
6
|
+
*
|
|
7
|
+
* @returns Promise resolving to availability state plus an optional reason.
|
|
8
|
+
*/
|
|
9
|
+
export function getLocationAvailability(): Promise<LocationAvailability> {
|
|
10
|
+
return NitroGeolocationHybridObject.getLocationAvailability();
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NitroGeolocationHybridObject } from "../NitroGeolocationModule";
|
|
2
|
+
import type { LocationProviderStatus } from "../publicTypes";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get native provider/settings status for the current device.
|
|
6
|
+
*
|
|
7
|
+
* Android: returns device-level service state plus provider availability
|
|
8
|
+
* (`gpsAvailable`, `networkAvailable`, `passiveAvailable`) and Google Location
|
|
9
|
+
* Accuracy state when Google Play Services exposes it.
|
|
10
|
+
*
|
|
11
|
+
* iOS: returns Core Location service availability and whether the app declares
|
|
12
|
+
* background location mode. Android-specific provider fields are `undefined`.
|
|
13
|
+
*/
|
|
14
|
+
export function getProviderStatus(): Promise<LocationProviderStatus> {
|
|
15
|
+
return NitroGeolocationHybridObject.getProviderStatus();
|
|
16
|
+
}
|