Skip to content

Commit

Permalink
fix: fix canIExtract verification
Browse files Browse the repository at this point in the history
  • Loading branch information
1fabiopereira committed Aug 4, 2023
1 parent 0189167 commit cef705c
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.reactnative.pdf.extractor

import android.content.ContentResolver
import android.net.Uri
import androidx.core.content.FileProvider

import com.facebook.react.bridge.*
import com.reactnative.pdf.extractor.core.PdfHandler
Expand Down Expand Up @@ -61,12 +62,16 @@ class PdfExtractorModule(reactContext: ReactApplicationContext) : ReactContextBa
}

@ReactMethod
fun canIExtract(promise: Promise) {
fun canIExtract(promise: Promise): Any {
try {
val uri = getCurrentUri()
val resolver = getCurrentResolver()

return promise.resolve(uri !== null && resolver !== null)
if (uri !== null && resolver !== null) {
return promise.resolve(resolver.getType(uri).equals("application/pdf"))
}

return promise.resolve(false)
} catch (e: Exception) {
e.printStackTrace()
return promise.reject(e)
Expand Down

0 comments on commit cef705c

Please sign in to comment.