Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close camera programatically #207

Open
feardarkness opened this issue Jan 11, 2023 · 4 comments
Open

Close camera programatically #207

feardarkness opened this issue Jan 11, 2023 · 4 comments

Comments

@feardarkness
Copy link

I'm using blinkid-react-native 5.17.0 and I couldn't find a way to close the camera programatically. Is there any way to do it?

I would like to call something like BlinkIDReactNative.BlinkID.closeCamera()

@somyaguptagit
Copy link

Hello @feardarkness,

Thank you for reaching out!

Just to keep you informed, that we do not have exact solution in React-Native to close the camera programmatically, but you can customize our Java wrapper since it is an open-source.

I suggest that you fork the repository and make the change in the following file:
BlinkID/src/android/src/main/java/com/microblink/reactnative/MicroblinkModule.java

In line 76, you can add a handler which, after 10 seconds, closes the scanning activity:

(new Handler(Looper.getMainLooper())).postDelayed(new Runnable() {
@OverRide
public void run() {
getCurrentActivity().finishActivity(REQUEST_CODE);
}
}, 10000);

Let us know if you find this helpful.

@feardarkness
Copy link
Author

Hi @somyaguptagit, thank you for the answer. I will test it tomorrow, but, what can I do on IOS?

@somyaguptagit
Copy link

Hello @feardarkness,
Thank you for your response!

We will look into how can we implement it on iOS from our end and reach out once we we have gathered more information.

@mparadina
Copy link
Contributor

Hi @feardarkness

Allow me to jump in.

You can, for instance, add an NSTimer in the MBBlinkIDModule.m in the path:
.../node_modules/blinkid-react-native/src/ios/MicroblinkModule/MicroblinkModule/MBBlinkIDModule.m

Below line 99, you can add:

NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:10 repeats:NO block:^(NSTimer * _Nonnull timer) {
        [rootViewController dismissViewControllerAnimated:YES completion:nil];
}];

This will close the scanning controller in 10 seconds.
Please test it out and let me know if it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants