Created
April 23, 2020 17:38
-
-
Save felansu/cdfebbc60103cfda80af775ff060beca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.cloq.combateAFraude; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import com.combateafraude.documentdetector.DocumentDetector; | |
import com.combateafraude.documentdetector.DocumentDetectorActivity; | |
import com.combateafraude.documentdetector.controller.DocumentDetectorType; | |
import com.facebook.react.bridge.Callback; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.bridge.ReactContextBaseJavaModule; | |
import com.facebook.react.bridge.ReactMethod; | |
import org.jetbrains.annotations.NotNull; | |
public class CombateAFraudeModule extends ReactContextBaseJavaModule { | |
Context ctx; | |
static final int REQUEST_CODE = 50000; | |
private String MOBILE_TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI1ZThiMzc1Y2FlNWNlNDAwMDhmODBiOWUifQ.pBpsjZtPL7w1FB_bFj1ZodHhzOQbCfPK-lCw6GN5_2M"; | |
public CombateAFraudeModule(ReactApplicationContext reactContext) { | |
super(reactContext); | |
this.ctx = reactContext.getApplicationContext(); | |
} | |
@NotNull | |
@Override | |
public String getName() { | |
return "CombateAFraude"; | |
} | |
@ReactMethod | |
public void documentDetector(Callback cb) { | |
System.out.println("CHAMADO DOCUMENT DETECTOR"); | |
try { | |
// DocumentDetectorType.CNH | |
DocumentDetector documentDetector = new DocumentDetector.Builder(MOBILE_TOKEN) | |
.setDocumentType(DocumentDetectorType.RG) | |
.build(); | |
Intent intent = new Intent(ctx, DocumentDetectorActivity.class); | |
intent.putExtra(DocumentDetector.PARAMETER_NAME, documentDetector); | |
getReactApplicationContext().startActivityForResult(intent, REQUEST_CODE, Bundle.EMPTY); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
cb.invoke("pacoo!"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment