transistorsoft / nativescript-background-geolocation-lt

Sophisticated, battery-conscious, cross-platform background-geolocation with motion-detection and geofencing
MIT License
73 stars 24 forks source link

App crashes if location permissions are denied #120

Closed bradseefeld closed 6 years ago

bradseefeld commented 6 years ago

Your Environment

Expected Behavior

App does not crash

Actual Behavior

App crashes

Steps to Reproduce

  1. Boot app and call .ready
  2. Device will prompt if you want to grant location permission. Choose Deny
  3. App will crash

Context

I believe the issue is caused by this line: https://github.com/transistorsoft/nativescript-background-geolocation-lt/blob/c7d18619b2dbee8a986e933c47a0beea24a37441/src/api.android.ts#L169 or https://github.com/transistorsoft/nativescript-background-geolocation-lt/blob/c7d18619b2dbee8a986e933c47a0beea24a37441/src/api.android.ts#L153

I believe these should be defined as onFailure. All other instances of TSCallback are using onFailure as far as I can tell.

Debug logs

07-22 08:44:57.305  8412  8412 E AndroidRuntime:     com.tns.Runtime.callJSMethodNative(Native Method)
07-22 08:44:57.305  8412  8412 E AndroidRuntime:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
07-22 08:44:57.305  8412  8412 E AndroidRuntime:     com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
07-22 08:44:57.305  8412  8412 E AndroidRuntime:     com.tns.Runtime.callJSMethod(Runtime.java:970)
07-22 08:44:57.305  8412  8412 E AndroidRuntime:     com.tns.Runtime.callJSMethod(Runtime.java:954)
07-22 08:44:57.305  8412  8412 E AndroidRuntime:     com.tns.Runtime.callJSMethod(Runtime.java:946)
07-22 08:44:57.305  8412  8412 E AndroidRuntime:    at com.tns.Runtime.callJSMethodNative(Native Method)
07-22 08:44:57.305  8412  8412 E AndroidRuntime:    at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
07-22 08:44:57.305  8412  8412 E AndroidRuntime:    at com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
07-22 08:44:57.305  8412  8412 E AndroidRuntime:    at com.tns.Runtime.callJSMethod(Runtime.java:970)
07-22 08:44:57.305  8412  8412 E AndroidRuntime:    at com.tns.Runtime.callJSMethod(Runtime.java:954)
07-22 08:44:57.305  8412  8412 E AndroidRuntime:    at com.tns.Runtime.callJSMethod(Runtime.java:946)
System.err: com.tns.NativeScriptException: 
System.err: Calling js method onFailure failed
System.err: 
System.err: Error: java.lang.AbstractMethodError: abstract method "void com.transistorsoft.locationmanager.adapter.callback.TSCallback.onFailure(java.lang.String)"
System.err:     com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
System.err:     com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:970)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:954)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:946)
System.err:     com.tns.gen.com.transistorsoft.locationmanager.adapter.callback.TSCallback.onFailure(Unknown Source:10)
System.err:     com.transistorsoft.locationmanager.adapter.BackgroundGeolocation$24.onPermissionDenied(Unknown Source:12)
System.err:     com.transistorsoft.locationmanager.util.b$1.onPermissionDenied(Unknown Source:39)
System.err:     com.intentfilter.androidpermissions.PermissionHandler.informPermissionsDenied(PermissionHandler.java:93)
System.err:     com.intentfilter.androidpermissions.PermissionHandler.onPermissionsResult(PermissionHandler.java:53)
System.err:     com.intentfilter.androidpermissions.PermissionManager.onReceive(PermissionManager.java:58)
System.err:     android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:311)
System.err:     android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:47)
System.err:     android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:120)
System.err:     android.os.Handler.dispatchMessage(Handler.java:106)
christocracy commented 6 years ago

Will be fixed soon.

christocracy commented 6 years ago

Try 1.9.0-beta.4. There was indeed a bug with TSCallback instances. Those should have been onFailure.

However, I could not reproduce the error in the demo app. You must have been executing some different API methods in addition that I'm not in the demo.

bradseefeld commented 6 years ago

Its working! The app no longer crashes when I deny permissions. Thanks!!

christocracy commented 6 years ago

Good work finding that mistake on the TSCallback.