我的应用程序FourFourTwo Stats Zone刚刚去住在App Store今天晚上:iPhone 3G 4.2.1 - SKProductsRequest委托方法不会被调用
我问了几个人来测试应用程序内购买和获得成功除iPhone 3G之外的所有设备(运行4.2.1 - 尚未与其他iOS版本进行测试)。我试过在我有的设备上调试它,看起来没有任何SKProductsRequest委托方法被调用。这里是我的代码:
- (void)requestPurchaseOfCompetition:(Competition*)competition {
DLog("");
if ([SKPaymentQueue canMakePayments]) {
DLog(@"do store");
NSString* productIdentifier = [NSString stringWithFormat:@"%@%@_%@", kPRODUCT_IDENTIFIER_PREFIX, competition.competitionId, competition.season];
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject:productIdentifier]];
[[NSNotificationCenter defaultCenter] postNotificationOnMainThread:[NSNotification notificationWithName:kStoreKitHandlerNotificationRequestProductInfo object:nil userInfo:[NSDictionary dictionaryWithObject:request forKey:@"request"]]];
request.delegate = self;
[request start];
[request release];
} else {
DLog(@"no store");
// Warn the user that purchases are disabled.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Store", @"Store") message:NSLocalizedString(@"In app purchasing is disabled for this device (in Settings > General > Restrictions). Please enable this setting to purchase more competitions.", @"In app purchasing is disabled for this device (in Settings > General > Restrictions). Please enable this setting to purchase more competitions.") delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
}
...
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
DLog(@"response: %@", response);
DLog(@"invalid product identifiers: %@", response.invalidProductIdentifiers);
for (SKProduct *product in response.products) {
DLog(@"product: %@", product);
[[NSNotificationCenter defaultCenter] postNotificationOnMainThread:[NSNotification notificationWithName:kStoreKitHandlerNotificationGotProductInfo object:nil userInfo:[NSDictionary dictionaryWithObject:product forKey:@"product"]]];
SKPayment *payment = [SKPayment paymentWithProduct:product];
SKPaymentQueue *paymentQueue = [SKPaymentQueue defaultQueue];
[paymentQueue addTransactionObserver:self];
[paymentQueue addPayment:payment];
}
}
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error {
DLog(@"request failed: %@, %@", request, error);
[[NSNotificationCenter defaultCenter] postNotificationOnMainThread:[NSNotification notificationWithName:kStoreKitHandlerNotificationRequestProductInfoFailed object:nil userInfo:[NSDictionary dictionaryWithObject:error forKey:@"error"]]];
}
- (void)requestDidFinish:(SKRequest *)request {
DLog(@"request finished: %@", request);
}
这三个委托方法中的日志消息都没有出现。
这适用于3GS,iPhone 4,iPad等,但不适用于运行4.2.1的iPhone 3G。
任何人都可以提供任何见解吗?
感谢@MatejBalantič同样的事情发生,你的修复是伟大的。 –