From 6f7c3e38a56844d8aa6391a11305fda44e5109dc Mon Sep 17 00:00:00 2001 From: Blake Williams Date: Mon, 13 Mar 2017 11:14:38 -0400 Subject: [PATCH] Check if phone is nil before adding it to args In our application tokenizedPayPalAccount.phone was nil and caused the application to crash. This changes the NSArray into a NSMutableArray so we can conditionally push the phone number if it's not nil. --- ios/RCTBraintree/RCTBraintree.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ios/RCTBraintree/RCTBraintree.m b/ios/RCTBraintree/RCTBraintree.m index 5181b5c1..94a0afd9 100644 --- a/ios/RCTBraintree/RCTBraintree.m +++ b/ios/RCTBraintree/RCTBraintree.m @@ -104,9 +104,13 @@ - (instancetype)init payPalDriver.viewControllerPresentingDelegate = self; [payPalDriver authorizeAccountWithCompletion:^(BTPayPalAccountNonce *tokenizedPayPalAccount, NSError *error) { - NSArray *args = @[[NSNull null]]; + NSMutableArray *args = @[[NSNull null]]; if ( error == nil && tokenizedPayPalAccount != nil ) { - args = @[[NSNull null], tokenizedPayPalAccount.nonce, tokenizedPayPalAccount.email, tokenizedPayPalAccount.firstName, tokenizedPayPalAccount.lastName, tokenizedPayPalAccount.phone]; + args = [@[[NSNull null], tokenizedPayPalAccount.nonce, tokenizedPayPalAccount.email, tokenizedPayPalAccount.firstName, tokenizedPayPalAccount.lastName] mutableCopy]; + + if (tokenizedPayPalAccount.phone != nil) { + [args addObject:tokenizedPayPalAccount.phone]; + } } else if ( error != nil ) { args = @[error.description, [NSNull null]]; }