2013-12-14 33 views
0

这是我在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; 
    } 
} 

}

上的任何提示我如何解决这个代码的工作?这是一个简单的修复?

+0

你会发布你的 - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)交易在这里,并检查里面是什么? – boreas

+0

我已添加代码。是否有代码我错过了发布,将帮助你解决我的问题?谢谢! – mmb316

+0

并且你是否在你的 - (void)completeTransaction :(SKPaymentTransaction *)事务中解锁/升级? – boreas

回答

0

那么,如果你没有触摸代码它肯定不会工作。购买应该能够完成但您必须执行

- (void)completeTransaction:(SKPaymentTransaction *)transaction 

更新购买后用户应该得到的内容。

+0

我已经搜查了我的代码,我确实在文件Mystoreobserver.h和mystoreobserver.m中有该行,是否需要将它添加到其他位置? – mmb316

+0

不,你需要在里面添加一些东西。购买后您希望用户拥有什么? – boreas

+0

用户将购买他们从赌场老虎机应用程序中获得的硬币/积分,以便在应用程序用完时再次使用它们。 – mmb316