Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.

Commit 2919357

Browse files
authored
Use manual selectors for new APIs (#1606)
This will allow the code to build in older VS versions Fixes #1589
1 parent 5b00532 commit 2919357

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Xamarin.Essentials/Types/LocationExtensions.ios.tvos.watchos.macos.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace Xamarin.Essentials
88
{
99
public static partial class LocationExtensions
1010
{
11+
[System.Runtime.InteropServices.DllImport(ObjCRuntime.Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSend")]
12+
public static extern CLAuthorizationStatus CLAuthorizationStatus_objc_msgSend(IntPtr receiver, IntPtr selector);
13+
1114
internal static Location ToLocation(this CLPlacemark placemark) =>
1215
new Location
1316
{
@@ -52,15 +55,19 @@ internal static DateTimeOffset ToDateTime(this NSDate timestamp)
5255

5356
internal static CLAuthorizationStatus GetAuthorizationStatus(this CLLocationManager locationManager)
5457
{
55-
#if !__MACOS__ // this is coming in macOS 11
56-
#if __WATCHOS__
58+
#if __MACOS__
59+
if (DeviceInfo.Version >= new Version(11, 0))
60+
#elif __WATCHOS__
5761
if (Platform.HasOSVersion(7, 0))
5862
#else
5963
if (Platform.HasOSVersion(14, 0))
6064
#endif
61-
return locationManager.AuthorizationStatus;
65+
{
66+
// return locationManager.AuthorizationStatus;
6267

63-
#endif
68+
var sel = ObjCRuntime.Selector.GetHandle("authorizationStatus");
69+
return CLAuthorizationStatus_objc_msgSend(locationManager.Handle, sel);
70+
}
6471

6572
return CLLocationManager.Status;
6673
}

0 commit comments

Comments
 (0)