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

Commit

Permalink
Use manual selectors for new APIs (#1606)
Browse files Browse the repository at this point in the history
This will allow the code to build in older VS versions
Fixes #1589
  • Loading branch information
mattleibow authored Dec 26, 2020
1 parent 5b00532 commit 2919357
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace Xamarin.Essentials
{
public static partial class LocationExtensions
{
[System.Runtime.InteropServices.DllImport(ObjCRuntime.Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSend")]
public static extern CLAuthorizationStatus CLAuthorizationStatus_objc_msgSend(IntPtr receiver, IntPtr selector);

internal static Location ToLocation(this CLPlacemark placemark) =>
new Location
{
Expand Down Expand Up @@ -52,15 +55,19 @@ internal static DateTimeOffset ToDateTime(this NSDate timestamp)

internal static CLAuthorizationStatus GetAuthorizationStatus(this CLLocationManager locationManager)
{
#if !__MACOS__ // this is coming in macOS 11
#if __WATCHOS__
#if __MACOS__
if (DeviceInfo.Version >= new Version(11, 0))
#elif __WATCHOS__
if (Platform.HasOSVersion(7, 0))
#else
if (Platform.HasOSVersion(14, 0))
#endif
return locationManager.AuthorizationStatus;
{
// return locationManager.AuthorizationStatus;

#endif
var sel = ObjCRuntime.Selector.GetHandle("authorizationStatus");
return CLAuthorizationStatus_objc_msgSend(locationManager.Handle, sel);
}

return CLLocationManager.Status;
}
Expand Down

0 comments on commit 2919357

Please sign in to comment.