这是我在iOS
与应用程序内购买我的第一个应用程序。我在测试应用内购买时遇到了困难。这是一款复古游戏,所以功能已经集成。我准备将游戏提交给苹果公司,但我试图确认应用程序内购买工作正常。在iOS上的应用程序购买没有错误
我有一个测试用户帐户我与签署我购买应用程序内购买的与测试用户。它读取“购买”,然后消失,但从来没有购买功能,它是假设?没有错误信息!?功能是假设购买额外的硬币,但这些硬币在“购买”后不显示。
这是否应该在应用程序购买测试时工作?
Reachability* reachability = [Reachability reachabilityWithHostName:@"www.google.com"];
NetworkStatus internetStatus = [reachability currentReachabilityStatus];
if (internetStatus != ReachableViaWiFi && internetStatus != ReachableViaWWAN) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection"
message:@"You require an internet connection via WiFi or cellular network for connecting to online store"
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
[alert release];
bErrorOnConnection = YES;
}
if ([SKPaymentQueue canMakePayments])
{
[self requestProductData];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"In-App Purchases are disabled"
message:@"Please check your restrictions for In-App Purchases in Settings->General->Restrictions."
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
[alert release];
bErrorOnConnection = YES;
}
- (IBAction) closePressed:(id) sender {
[mainGameParent GameStoreClosed];
[self.view removeFromSuperview];
}
- (IBAction) purchaseUnlock:(id) sender {
bool bPaymentInQueue = NO;
for (SKPaymentTransaction *transaction in [SKPaymentQueue defaultQueue].transactions) {
if ([transaction.payment.productIdentifier isEqualToString:kPayoutUnlockProduct]) {
bPaymentInQueue = YES;
NSLog(@"Payment already in queue!");
break;
}
}
if (!bPaymentInQueue) {
NSLog(@"Adding new payment...");
SKPayment *payment = [SKPayment paymentWithProductIdentifier:kPayoutUnlockProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
(IBAction) restore:(id)sender {
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
- (IBAction) moreGames:(id)sender {
SurfSlotMachineAppDelegate* del = (SurfSlotMachineAppDelegate*)[UIApplication sharedApplication].delegate;
[del dispMoreApps];
}
- (void)requestProductData {
//lblLoading.hidden = NO;
[activityIndicatorView setHidden:YES];
//[activityIndicatorView startAnimating];
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:kPayoutUnlockProduct]];
NSLog(@"%@",kPayoutUnlockProduct);
request.delegate = self;
[request start];
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
NSLog(@"Transaction Purchased");
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
NSLog(@"Transaction Failed");
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
NSLog(@"Transaction Restored");
[self restoreTransaction:transaction];
default:
break;
}
}
}
上的任何提示我如何解决这个代码的工作?这是一个简单的修复?
你会发布你的 - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)交易在这里,并检查里面是什么? – boreas
我已添加代码。是否有代码我错过了发布,将帮助你解决我的问题?谢谢! – mmb316
并且你是否在你的 - (void)completeTransaction :(SKPaymentTransaction *)事务中解锁/升级? – boreas