React-native-background-geolocation: [iOS] Crash when start the app

Created on 5 Apr 2017  路  2Comments  路  Source: mauron85/react-native-background-geolocation

Environment

  • Plugin version: 0.2.0-alpha.7
  • Platform: iOS
  • OS version: 10.2
  • Device manufacturer and model: iPhone 5 (simulator)
  • React Native version: 0.42

Context

When I start the app the line 112 of LocationManager.m throw a error

The line:

locationManager.allowsBackgroundLocationUpdates = YES;

The error:

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient)'

* First throw call stack:
(
0 CoreFoundation 0x06139bf2 __exceptionPreprocess + 194
1 libobjc.A.dylib 0x04c38e66 objc_exception_throw + 52
2 CoreFoundation 0x0613dd12 +[NSException raise:format:arguments:] + 130
3 Foundation 0x04838af4 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 94
4 CoreLocation 0x01880ad8 CLClientGetCapabilities + 12072
7 libobjc.A.dylib 0x04c4e36b +[NSObject new] + 69prepareModulesWithDispatchGroup:]_block_invoke + 139
13 libdispatch.dylib 0x06f7d396 _dispatch_call_block_and_release + 15
14 libdispatch.dylib 0x06fa8cc3 _dispatch_client_callout + 14
15 libdispatch.dylib 0x06f87c55 _dispatch_main_queue_callback_4CF + 662
16 CoreFoundation 0x060fa05e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
17 CoreFoundation 0x060bc8df __CFRunLoopRun + 2319
18 CoreFoundation 0x060bbd5b CFRunLoopRunSpecific + 395
19 CoreFoundation 0x060bbbbb CFRunLoopRunInMode + 123
20 GraphicsServices 0x0927ab4c GSEventRunModal + 177
21 GraphicsServices 0x0927a9c7 GSEventRun + 80
22 UIKit 0x02ebbff3 UIApplicationMain + 148
24 libdyld.dylib 0x06fe3799 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Most helpful comment

You need to add following into your projects Info.plist file

UIBackgroundModes "location"
NSLocationAlwaysUsageDescription "your description"

UIBackgroundModes must be an array of strings, where one string is required - "location", so source code of Info.plist should look like:

...

<key>UIBackgroundModes</key>
<array>
  <string>location</string>
</array>

...

<key>NSLocationAlwaysUsageDescription</key>
<string>App requires background tracking</string>

...

All 2 comments

You need to add following into your projects Info.plist file

UIBackgroundModes "location"
NSLocationAlwaysUsageDescription "your description"

UIBackgroundModes must be an array of strings, where one string is required - "location", so source code of Info.plist should look like:

...

<key>UIBackgroundModes</key>
<array>
  <string>location</string>
</array>

...

<key>NSLocationAlwaysUsageDescription</key>
<string>App requires background tracking</string>

...

This is already mentioned in README section iOS Setup.

Was this page helpful?
0 / 5 - 0 ratings