tradle / react-native-facetec-zoom

10 stars 13 forks source link

.MainApplication casting to .Activity in getSdkStatusString() call [Android] #4

Closed eahrold closed 5 years ago

eahrold commented 5 years ago

Config

RN 0.59 react-native-facetec-zoom@1.2.0

ZoomSDK version NOT set as referenced in, so using latest.

ext {
  // ...
  zoomSdkVersion = '7.0.11' // <--- whichever version you want to use
  // ...
}

Issue

ZoomSDKStatus status = ZoomSDK.getStatus(reactContext.getApplicationContext());

At https://github.com/tradle/react-native-facetec-zoom/blob/master/android/src/main/java/com/reactlibrary/RNReactNativeZoomSdkModule.java#L220

Causes the app to crash.

05-17 09:38:30.253 32613 32660 E AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
05-17 09:38:30.253 32613 32660 E AndroidRuntime: Process: testapp.com, PID: 32613
05-17 09:38:30.253 32613 32660 E AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
05-17 09:38:30.253 32613 32660 E AndroidRuntime: Process: testapp.com, PID: 32613
05-17 09:38:30.253 32613 32660 E AndroidRuntime: java.lang.ClassCastException: testapp.com.MainApplication cannot be cast to android.app.Activity
05-17 09:38:30.253 32613 32660 E AndroidRuntime:    at com.facetec.zoom.sdk.au.ˋ(:228)
05-17 09:38:30.253 32613 32660 E AndroidRuntime:    at com.facetec.zoom.sdk.ZoomSDK.getStatus(:112)
05-17 09:38:30.253 32613 32660 E AndroidRuntime:    at com.reactlibrary.RNReactNativeZoomSdkModule.getSdkStatusString(RNReactNativeZoomSdkModule.java:220)
05-17 09:38:30.253 32613 32660 E AndroidRuntime:    at com.reactlibrary.RNReactNativeZoomSdkModule.access$400(RNReactNativeZoomSdkModule.java:45)
05-17 09:38:30.253 32613 32660 E AndroidRuntime:    at com.reactlibrary.RNReactNativeZoomSdkModule$2$1.onCompletion(RNReactNativeZoomSdkModule.java:132)
05-17 09:38:30.253 32613 32660 E AndroidRuntime:    at com.facetec.zoom.sdk.au$10.run(:209)
05-17 09:38:30.253 32613 32660 E AndroidRuntime:    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
05-17 09:38:30.253 32613 32660 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
05-17 09:38:30.253 32613 32660 E AndroidRuntime:    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
05-17 09:38:30.253 32613 32660 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:762)

Possible Fix

Changing it to use the current activity fixes the issue.

    Activity activity = getCurrentActivity();
    ZoomSDKStatus status = ZoomSDK.getStatus(activity);