在应用程序购买沙箱不提示我的登录/通行证 [英] In App Purchase sandbox not prompting for my login/pass
问题描述
我们正在开发一款(当然)用于应用购买 (IAP) 的应用.我已完成指南中的所有操作以启用 iap,并且一切正常,直到我想购买为止.
部分代码:
We're developing an app which (ofcourse) uses in app purchases (IAP).
I've done everything in the guide to enable iap and everything works fine, untill I want to make purchase.
Some of the code:
MainViewController.m
-(void)viewDidLoad {
if ([SKPaymentQueue canMakePayments]) {
MyStoreObserver *observer = [[MyStoreObserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObjects: @"com.company.app.product1", @"com.company.app.product1", nil]];
request.delegate = self;
[request start];
}
};
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
for (SKProduct *prod in response.products) {
NSLog(@"%@ (%@)", prod.localizedTitle, prod.price);
}
[request release];
};
-(IBAction)clickBuy:(UIButton *)__sender {
SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"com.company.app.product1"];
[[SKPaymentQueue defaultQueue] addPayment:payment];
};
MyStoreObserver.m
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased:
NSLog(@"SKPaymentTransactionStatePurchased");
break;
case SKPaymentTransactionStateFailed:
NSLog(@"SKPaymentTransactionStateFailed");
break;
case SKPaymentTransactionStateRestored:
NSLog(@"SKPaymentTransactionStateRestored");
break;
case SKPaymentTransactionStatePurchasing:
NSLog(@"SKPaymentTransactionStatePurchasing");
default:
break;
}
}
};
productRequest:
委托方法显示 2 个产品及其名称/价格.就像我在 iTunes 连接站点中输入的一样.
The productRequest:
delegate method shows 2 products with their name / price. Like I entered in the iTunes connect site.
但是一旦我单击购买"按钮,就不会弹出任何对话框或询问我的凭据.仅记录SKPaymentTransactionStatePurchasing".
而我:
- ...已在设置/商店窗格中注销
- ...正在使用正确的配置文件
- ...我很绝望
But once I click the 'buy' button, no dialog pops up or asks me for my credentials. Only "SKPaymentTransactionStatePurchasing" is logged.
And I:
- ... have logged out in the settings/store pane
- ... am using the right provisioning profiles
- ... am desperate
有人吗?
推荐答案
我遇到了类似的问题,但我的问题更像是一个愚蠢的举动.我已经重构"了对 finishTransaction
的调用,以便为 transactionState
中的每个状态调用它:
I encountered a similar problem, but mine was more of a boneheaded move on my part. I had 'refactored' the call to finishTransaction
so that it was being called for every state in transactionState
:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchased:
// do stuff
break;
case SKPaymentTransactionStateFailed:
// do stuff
break;
case SKPaymentTransactionStateRestored:
// do stuff
break;
default:
break;
}
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}
}
结果是™,这也会在 SKPaymentTransactionStatePurchasing
上调用 finishTransaction
,这将导致崩溃.将 finishTransaction
移回 switch 语句的每种情况都解决了这个问题.
Turns out™, this will also call finishTransaction
on SKPaymentTransactionStatePurchasing
, which will cause a crash. Moving finishTransaction
back into each case of the switch statement fixed that.
这篇关于在应用程序购买沙箱不提示我的登录/通行证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!