Skip to content

Commit fbfd000

Browse files
Merge pull request jamesmontemagno#12 from JasonBro/Fix_For_bug_#6
Checks to ensure that backgroundModes is not null before using it.
2 parents b56e57e + d155f35 commit fbfd000

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)