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

Commit 72447a0

Browse files
Need to cache locationmanager or dialog dissapears (#1072)
1 parent c7b4a54 commit 72447a0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Xamarin.Essentials/Permissions/Permissions.ios.tvos.watchos.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ internal static PermissionStatus GetLocationStatus(bool whenInUse)
125125
};
126126
}
127127

128+
static CLLocationManager locationManager;
129+
128130
internal static Task<PermissionStatus> RequestLocationAsync(bool whenInUse, Action<CLLocationManager> invokeRequest)
129131
{
130-
var locationManager = new CLLocationManager();
132+
locationManager = new CLLocationManager();
131133

132134
var tcs = new TaskCompletionSource<PermissionStatus>(locationManager);
133135

@@ -155,6 +157,8 @@ void LocationAuthCallback(object sender, CLAuthorizationChangedEventArgs e)
155157
{
156158
locationManager.AuthorizationChanged -= LocationAuthCallback;
157159
tcs.TrySetResult(GetLocationStatus(whenInUse));
160+
locationManager.Dispose();
161+
locationManager = null;
158162
}
159163
});
160164
return;
@@ -164,6 +168,8 @@ void LocationAuthCallback(object sender, CLAuthorizationChangedEventArgs e)
164168
locationManager.AuthorizationChanged -= LocationAuthCallback;
165169

166170
tcs.TrySetResult(GetLocationStatus(whenInUse));
171+
locationManager.Dispose();
172+
locationManager = null;
167173
}
168174
}
169175
}

0 commit comments

Comments
 (0)