Skip to content

Commit d155f35

Browse files
committed
Checks to ensure that backgroundModes is not null before using it.
1 parent b56e57e commit d155f35

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Geolocator.Plugin.iOS/GeolocatorImplementation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public Task<Position> GetPositionAsync(int timeoutMilliseconds = Timeout.Infinit
149149
if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0))
150150
{
151151
NSArray backgroundModes = NSBundle.MainBundle.InfoDictionary[(NSString)"UIBackgroundModes"] as NSArray;
152-
m.AllowsBackgroundLocationUpdates = backgroundModes.Contains((NSString)"Location") || backgroundModes.Contains((NSString)"location");
152+
m.AllowsBackgroundLocationUpdates = backgroundModes != null && (backgroundModes.Contains((NSString)"Location") || backgroundModes.Contains((NSString)"location"));
153153
}
154154

155155
// always prevent location update pausing since we're only listening for a single update.

0 commit comments

Comments
 (0)