我正在尝试使用 Braintree iOS 标记信用卡。 这是我在 docs 中的代码.
self.braintree = [Braintree braintreeWithClientToken:self.clientToken];
BTClientCardRequest *request = [BTClientCardRequest new];
request.number = @"4111111111111111";
request.expirationMonth = @"12";
request.expirationYear = @"2018";
[self.braintree tokenizeCard:request
completion:^(NSString *nonce, NSError *error){
}];
不幸的是,我没有在项目中找到 BTClientCardRequest 类,尽管它在 Braintree API header directory 中.
我的 Podfile 看起来像这样:
# Uncomment this line to define a global platform for your project
# platform :ios, "6.0"
source 'https://github.com/CocoaPods/Specs.git'
target "myproj" do
pod 'Braintree'
pod "Braintree/API"
end
target "myprojTests" do
pod 'Braintree'
pod "Braintree/API"
end
我的 Podfile.lock 看起来像这样:
PODS:
- Braintree (3.3.1):
- Braintree/API
- Braintree/Drop-In
- Braintree/Payments
- Braintree/PayPal
- Braintree/UI
- Braintree/Venmo
- Braintree/API (3.3.1)
- Braintree/Drop-In (3.3.1):
- Braintree/API
- Braintree/Payments
- Braintree/PayPal
- Braintree/UI
- Braintree/Venmo
- Braintree/Payments (3.3.1):
- Braintree/API
- Braintree/PayPal
- Braintree/Venmo
- Braintree/PayPal (3.3.1):
- Braintree/API
- Braintree/UI
- Braintree/UI (3.3.1)
- Braintree/Venmo (3.3.1):
- Braintree/API
DEPENDENCIES:
- Braintree
- Braintree/API
SPEC CHECKSUMS:
Braintree: 34538ea612eb8aa2a1187fb273ac80fd496f0628
COCOAPODS: 0.34.1
我真的很困惑,为什么我的项目工作区中没有这个类以及其他几个类。
最佳答案
根据您的 Podfile.lock
,您似乎已经引入了旧版本的 Braintree iOS (3.3.1
)。在这个版本中,-[Braintree tokenizeCard…]
有一个 slightly different signature来自您使用的那个,它基于 [Braintree 的在线文档][2]。
我建议通过在终端中运行此命令来升级到最新版本:
$ cd /path/to/your/project
$ pod update Braintree
有一个changelog here .
或者,如果您不想升级,可以将代码更改为 this :
[braintree tokenizeCardWithNumber:@"4111111111111111"
expirationMonth:@"12"
expirationYear:@"2020"
completion:^(NSString *nonce, NSError *error) {
/* Check for errors and use the `nonce` here. */
}];
关于ios - Braintree iOS 无法标记卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26659310/