Humxaa Khan
Humxaa Khan

Reputation: 59

Braintree iOS SDK saying no known class method

I m getting this error. Anyone?

-(void)clientToken{

NSURL *clientTokenURL = [NSURL URLWithString:@"http://tectutiveclients.com/projects/carboss/api/getToken"];

 NSMutableURLRequest *clientTokenRequest = [NSMutableURLRequest requestWithURL:clientTokenURL];

[clientTokenRequest setValue:@"text/plain" forHTTPHeaderField:@"Accept"];

 [NSURLConnection
 sendAsynchronousRequest:clientTokenRequest
 queue:[NSOperationQueue mainQueue]
 completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
     // TODO: Handle errors in [(NSHTTPURLResponse *)response statusCode] and connectionError
   clientToken = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

     // Initialize `Braintree` once per checkout session


       [Braintree setupWithClientToken:clientToken
       completion:^(Braintree *braintree, NSError *error) {
           UIViewController *dropin = [braintree dropInViewControllerWithDelegate:self];
           [self presentViewController:[[UINavigationController alloc] initWithRootViewController:dropin]
                              animated:YES
                            completion:nil];

       // No known class method for selector setupwithClientToken Error

       }];


     UIViewController *dropin = [self.braintree dropInViewControllerWithDelegate:self];
     [self presentViewController:[[UINavigationController alloc] initWithRootViewController:dropin]
                        animated:YES
                      completion:nil];
     }];
}

Upvotes: 0

Views: 1375

Answers (1)

Elliot
Elliot

Reputation: 6136

I work at Braintree. If you have any more problems, please get in touch with our support team.

This is an inaccuracy in the docs. Instead, please use braintreeWithClientToken:

Example:

NSString *clientToken = [[NSString alloc] initWithData:data 
                                              encoding:NSUTF8StringEncoding];

// Initialize `Braintree` once per checkout session
self.braintree = [Braintree braintreeWithClientToken:clientToken];

Thanks for pointing this out! The docs will be updated shortly.

Upvotes: 4

Related Questions