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

Crasher: Drop In > Payment Button > Retry #48

Closed
mickeyreiss opened this issue Sep 15, 2014 · 1 comment
Closed

Crasher: Drop In > Payment Button > Retry #48

mickeyreiss opened this issue Sep 15, 2014 · 1 comment
Assignees

Comments

@mickeyreiss
Copy link
Contributor

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[BTPaymentButton sendActionsForControlEvents:]: unrecognized selector sent to instance 0x14ec38a0'

Description

This exception is thrown when the user taps on a payment option above the card form in BTDropInViewController and an error (e.g. network error) occurs. When Drop In receives an error, the user is given a choice via a UIAlertView to "Cancel" or "Retry". If the user taps "Retry", an exception is thrown in the most recent release, 3.3.0.

Temporary Workaround

Modify BTDropInViewController to remove retry logic for Drop In:

diff --git a/Braintree/Drop-In/Braintree-Drop-In/BTDropInViewController.m b/Braintree/Drop-In/Braintree-Dr
op-In/BTDropInViewController.m                                                                            
index 7ccf475..0743d9a 100644                                                                             
--- a/Braintree/Drop-In/Braintree-Drop-In/BTDropInViewController.m                                        
+++ b/Braintree/Drop-In/Braintree-Drop-In/BTDropInViewController.m                                        
@@ -441,11 +441,7 @@                                                                                      
             // Use the paymentMethods setter to update state                                             
             [self setPaymentMethods:_paymentMethods];                                                    
             self.savePayPalAccountErrorAlert = nil;                                                      
-        } retry:^{                                                                                       
-            [sender sendActionsForControlEvents:UIControlEventTouchUpInside];                            
-            [self setPaymentMethods:_paymentMethods];                                                    
-            self.savePayPalAccountErrorAlert = nil;                                                      
-        }];                                                                                              
+        } retry:nil];                                                                                    
         self.savePayPalAccountErrorAlert.title = savePaymentMethodErrorAlertTitle;                       
         [self.savePayPalAccountErrorAlert show];                                                         
     }                                                                                                    

Technical Explanation

When the user taps "Retry" after Drop In fails, Drop In performs retry by emulating a tap on the payment button, as if the user tapped it again, by sending the button sendActionsForControlEvents:. Before 3.3.0, the payment button could only be a BTPayPalButton, which was a subclass of UIControl. In 3.3.0, the button is now a BTPaymentButton, which is a UIView subclass. Since BTPaymentButton does not respond to sendActionsForControlEvents:, the runtime throws an exception in this case.

Full stack trace

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[BTPaymentButton sendActionsForControlEvents:]: unrecognized selector sent to instance 0x14ec38a0'

Last Exception Backtrace:
0   CoreFoundation                       0x2e703ecb __exceptionPreprocess + 131
1   libobjc.A.dylib                      0x38e9ece7 objc_exception_throw + 36
2   CoreFoundation                       0x2e7077f7 -[NSObject(NSObject) doesNotRecognizeSelector:] + 200
3   CoreFoundation                       0x2e7060f7 ___forwarding___ + 704
4   CoreFoundation                       0x2e655058 _CF_forwarding_prep_0 + 22
5   Braintree-Demo                       0x001b8403 __64-[BTDropInViewController paymentMethodCreator:didFailWithError:]_block_invoke349 (BTDropInViewController.m:445)
6   Braintree-Demo                       0x001b3cd3 -[BTDropInErrorAlert alertView:clickedButtonAtIndex:] (BTDropInErrorAlert.m:47)
7   UIKit                                0x3114c209 -[_UIModalItemsCoordinator _notifyDelegateModalItem:tappedButtonAtIndex:] + 142
8   UIKit                                0x3114bedb -[_UIModalItemAlertContentView tableView:didSelectRowAtIndexPath:] + 376
9   UIKit                                0x310537d3 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1076
10  UIKit                                0x31105c93 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 212
11  UIKit                                0x30fb4de9 _applyBlockToCFArrayCopiedToStack + 314
12  UIKit                                0x30f2db37 _afterCACommitHandler + 428
13  CoreFoundation                       0x2e6ceff9 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
14  CoreFoundation                       0x2e6cc987 __CFRunLoopDoObservers + 284
15  CoreFoundation                       0x2e6cccd3 __CFRunLoopRun + 736
16  CoreFoundation                       0x2e637729 CFRunLoopRunSpecific + 522
17  CoreFoundation                       0x2e63750b CFRunLoopRunInMode + 104
18  GraphicsServices                     0x335a66d3 GSEventRunModal + 136
19  UIKit                                0x30f98871 UIApplicationMain + 1134
20  Braintree-Demo                       0x0004b3d3 main (main.m:8)
21  libdyld.dylib                        0x3939cab7 start + 0

Fix in 3.3.1

A bugfix will be released in version 3.3.1, during the week of 9/15/14.

@mickeyreiss
Copy link
Contributor Author

Fixed in 3.3.1 release via 055d658

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

No branches or pull requests

1 participant