2012-02-04 46 views
1

代碼如下 - 這個代碼昨天工作正在提供無效的ID現在不再工作,我已經受夠了代碼的10倍左右SKProductsRequest - 無應答現在(是工作 - 同樣的代碼)

.M

#import <UIKit/UIKit.h> 
#import <StoreKit/StoreKit.h> 

@interface InAppViewController : UIViewController <SKProductsRequestDelegate, SKPaymentTransactionObserver> { 

    SKProduct *proUpgradeProduct; 
    SKProductsRequest *productsRequest; 
} 

.H

#import "InAppViewController.h" 


@implementation InAppViewController 

- (void)viewDidLoad{ 
    [self requestProUpgradeProductData]; 
} 

- (void)dealloc { 
    [super dealloc]; 
} 

- (void)requestProUpgradeProductData 
{ 
    NSLog(@"called productsRequest"); 

    NSSet *productIdentifiers = [NSSet setWithObject:@"com.okz8.investor.gem15" ]; 
    productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers]; 
    productsRequest.delegate = self; 
    [productsRequest start]; 

    // we will release the request object in the delegate callback 
} 

#pragma mark - 
#pragma mark SKProductsRequestDelegate methods 

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response 
{ 
    NSArray *products = response.products; 
    proUpgradeProduct = [products count] == 1 ? [[products firstObject] retain] : nil; 
    if (proUpgradeProduct) 
    { 
     NSLog(@"Product title: %@" , proUpgradeProduct.localizedTitle); 
     NSLog(@"Product description: %@" , proUpgradeProduct.localizedDescription); 
     NSLog(@"Product price: %@" , proUpgradeProduct.price); 
     NSLog(@"Product id: %@" , proUpgradeProduct.productIdentifier); 
    } 

    for (NSString *invalidProductId in response.invalidProductIdentifiers) 
    { 
     NSLog(@"Invalid product id: %@" , invalidProductId); 
    } 

    // finally release the reqest we alloc/init’ed in requestProUpgradeProductData 
    [productsRequest release]; 

    //[[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerProductsFetchedNotification object:self userInfo:nil]; 
} 

這只是不返回響應我所做的一切都在這裏http://troybrant.net/blog/2010/01/invalid-product-ids/

是越來越無效的ID現在我這裏沒有得到任何

回答

6

基礎的在user178379響應,嘗試實現這個方法:

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error { 
    NSLog(@"request - didFailWithError: %@", [[error userInfo] objectForKey:@"NSLocalizedDescription"]); 
} 

我的問題是:Cannot connect to iTunes Store,這是爲:

StoreKit (In-App purchases) will not work in the Simulator. 13962338 
+0

在應用程序購買不工作在模擬器。 – damithH 2014-03-12 09:37:31

0

順便說一句,似乎是在情況下,當一個SKProductsRequest施工過程中傳遞的集產品標識符是空的,沒有的SKProductsRequestDelegate委託函數被調用。