-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
camera no longer captures images after the method confirmSetupIntent is called #93
Comments
Sorry, I don't have my laptop to reproduce this or confirm the problem, but I'm suspicious it's because you are calling In You could try setting a timer instead of displaying the alert directly, and then display the alert once everything has settled down. |
Actually I have the |
I'm facing the same issue with the standard implementation! @carlosanjos Did you find a workaround? |
@luke-hawk I changed my flow so camera and payment cards wouldn't mix. It's been a while, but according to my notes, the lines where |
@carlosanjos Cheers! Yep, I've already suspected that |
@RobertGardner I think I found the cause for this bug which seems to have it's root here: nativescript-stripe/src/standard/standard.android.ts Lines 167 to 188 in b967da0
...more specifically, the activity.onActivityResult = function (requestCode, resultCode, data) {
console.log('onActivityResult from nativescript-stripe')
// if (oldResultCallback) oldResultCallback(requestCode, resultCode, data);
session.native.handlePaymentData(requestCode, resultCode, data);
}; ...Also, when completely commenting out the above mentioned function, nativescript-camera and nativescript-imagepicker work as expected. Any idea what we can do about it? P.S.: These seem to be the relavant snippets for nativescript-camera appModule.android.foregroundActivity.startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); application.android.foregroundActivity.startActivityForResult(intent, RESULT_CODE_PICKER_IMAGES); |
Unfortunately, that code is necessary for the "standard" charge flow to work. It's how messages pass between the Stripe SDK and the client. I'm not an Android developer, so I'm not sure if there's a better way to do activity result chaining. I had written code trying to do the chaining, but when I call Also, Stripe completely changed the way the activity result callback works in their Android v12.8 release. It completely eliminates this callback and the need to use an activity at all. I'm sure it would fix the problem. Unfortunately, due to the {NS} bugs with their Kotlin integration (see NativeScript/android#1604), I'm not able to upgrade to the v12.8 release until that's fixed. There hasn't been any activity on that bug since I filed it almost a month ago. Maybe people can put some pressure on {NS} to work on it? |
@RobertGardner Hm. I see! Any idea how I can remove / reset
does the same job. (But also causes the same bug) |
@RobertGardner Would you mind if we chance the before mentioned callback to an event listener of the following kind: application_1.android.on('activityResult', (args) => {
if (args.requestCode === 6000 && args.resultCode === android.app.Activity.RESULT_OK) {
session.native.handlePaymentData(args.requestCode, args.resultCode, args.intent);
}
}) This way I can unmount the event listener when not needed and checking for the requestCode prevents from crashing if the same callback is fired from other plugins. I'd be glad to add a PR for this if you're fine with changing it this way. |
I did some debugging to see if I could figure out what's going on. The activity result handler is registered in the The activity handler is removed (as best as I can tell -- I believe it's actually the Stripe SDK that removes it) in I am getting the current activity by calling This suggests that the foreground activity is the home page. I tried waiting until the page containing the payment form was completely drawn before creating There are some possible solutions I could recommend until I'm able to get rid of all this activity registration stuff. One is that you figure out how to create a foreground activity that is created and destroyed on your Stripe form page. The other is that I expose the register/unregister functions so you can call them directly. Let me know how you'd like to proceed. Note that while debugging I discovered a bug in my |
@RobertGardner Ok, sounds like good! I would prefer the option to register/unregister manually – this is exactly what I was looking for all the time and would suit my integration nicely :-) ...let me know if you need any help! Thanks a lot :-) |
I submitted the change to the The technique I'm using is replacing the |
Ok, I'm quite busy at the moment but I will have a look at it next week for sure and will get back to you then. Cheers! |
Which platform(s) does your issue occur on?
Please, provide the following version numbers that your issue occurs with:
tns --version
6.3.0"nativescript-camera": "^4.5.0"
"nativescript-stripe": "~6.2.1"
Please, tell us how to recreate the issue in as much detail as possible.
Tap on the button to take a photo a capture any photo; Notice the Image widget will be populated with the photo just taken
Fill in with a valid stripe testing card information, you can find them here https://stripe.com/docs/testing
Tap on save payment card button
A pop-up will be displayed informing the operation succeeded
Refer to step one and take another photo; Notice the photo won't be captured this time
Is there any code involved?
The text was updated successfully, but these errors were encountered: